记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
baa4fcc0
Commit
baa4fcc0
authored
Jul 27, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交配置
parent
94ed4c07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
3 deletions
+82
-3
DragonPayBiz.java
...net/service/dragon/channel/strategy/biz/DragonPayBiz.java
+13
-3
DragonPayTest.java
...pl/src/test/java/com/liquidnet/service/DragonPayTest.java
+69
-0
No files found.
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/biz/DragonPayBiz.java
View file @
baa4fcc0
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
biz
;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.bo.PayNotifyReqBo
;
...
...
@@ -9,6 +9,7 @@ import com.liquidnet.service.dragon.constant.DragonConstant;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.dto.PayNotifyDto
;
import
com.liquidnet.service.dragon.utils.ObjectUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.config.RequestConfig
;
...
...
@@ -27,6 +28,7 @@ import java.io.IOException;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
...
...
@@ -142,7 +144,7 @@ public class DragonPayBiz {
nvps
.
add
(
new
BasicNameValuePair
(
"price"
,
payNotifyDto
.
getPrice
().
toString
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentType"
,
payNotifyDto
.
getPaymentType
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentAt"
,
payNotifyDto
.
getPaymentAt
()));
jsonData
=
J
SON
.
toJSONString
(
nvps
);
jsonData
=
J
sonUtils
.
toJson
(
covertNVPS2Params
(
nvps
)
);
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
));
...
...
@@ -151,7 +153,7 @@ public class DragonPayBiz {
CloseableHttpResponse
responseObj
=
httpclient
.
execute
(
httpPost
);
String
response
=
EntityUtils
.
toString
(
responseObj
.
getEntity
(),
"utf-8"
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
if
(
response
.
equals
(
"success"
))
{
if
(
response
.
equals
IgnoreCase
(
"success"
))
{
dragonServiceCommonBiz
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知成功
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_SUCCESS
.
getCode
()));
...
...
@@ -190,4 +192,12 @@ public class DragonPayBiz {
public
String
getPaymentType
(
String
payType
,
String
deviceFrom
){
return
(
deviceFrom
+
payType
).
toUpperCase
();
}
private
static
Map
<
String
,
Object
>
covertNVPS2Params
(
List
<
NameValuePair
>
nvpList
)
{
Map
<
String
,
Object
>
rsMap
=
ObjectUtil
.
cloneHashMapStringAndObj
();
for
(
NameValuePair
nameValuePair
:
nvpList
)
{
rsMap
.
put
(
nameValuePair
.
getName
(),
nameValuePair
.
getValue
());
}
return
rsMap
;
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/test/java/com/liquidnet/service/DragonPayTest.java
0 → 100644
View file @
baa4fcc0
package
com
.
liquidnet
.
service
;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.message.BasicNameValuePair
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: DragonPayTest
* @Package com.liquidnet.service
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/27 13:47
*/
//@RunWith(SpringJUnit4ClassRunner.class)
//@SpringBootTest
public
class
DragonPayTest
{
public
static
void
testMap
(){
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
nvps
.
add
(
new
BasicNameValuePair
(
"status"
,
"1"
));
nvps
.
add
(
new
BasicNameValuePair
(
"type"
,
"TICKET"
));
nvps
.
add
(
new
BasicNameValuePair
(
"code"
,
"PAY20210727111746415639688"
));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentId"
,
"4200001121202107274119605305"
));
nvps
.
add
(
new
BasicNameValuePair
(
"orderCode"
,
"11766977997930496418880635"
));
nvps
.
add
(
new
BasicNameValuePair
(
"price"
,
"0.01"
));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentType"
,
"APPWEPAY"
));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentAt"
,
"2021-07-27 11:18:03"
));
String
jsonData
=
JSON
.
toJSONString
(
nvps
);
System
.
out
.
println
(
"jsonDate === "
+
jsonData
);
System
.
out
.
println
(
"covertNVPS2Params jsonDate === "
+
covertNVPS2Params
(
nvps
));
System
.
out
.
println
(
"covertNVPS2Params jsonDate === "
+
JsonUtils
.
toJson
(
covertNVPS2Params
(
nvps
)));
System
.
out
.
println
(
"covertNVPS2Params jsonDate === "
+
covertNVPS2KeyValue
(
nvps
));
}
private
static
ArrayList
<
NameValuePair
>
covertParams2NVPS
(
Map
<
String
,
Object
>
params
)
{
ArrayList
<
NameValuePair
>
pairs
=
new
ArrayList
<
NameValuePair
>();
for
(
Map
.
Entry
<
String
,
Object
>
param
:
params
.
entrySet
())
{
pairs
.
add
(
new
BasicNameValuePair
(
param
.
getKey
(),
String
.
valueOf
(
param
.
getValue
())));
}
return
pairs
;
}
private
static
Map
<
String
,
Object
>
covertNVPS2Params
(
List
<
NameValuePair
>
nvpList
)
{
Map
<
String
,
Object
>
rsMap
=
new
HashMap
<>();
for
(
NameValuePair
nameValuePair
:
nvpList
)
{
rsMap
.
put
(
nameValuePair
.
getName
(),
nameValuePair
.
getValue
());
}
return
rsMap
;
}
private
static
String
covertNVPS2KeyValue
(
List
<
NameValuePair
>
nvpList
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
NameValuePair
nameValuePair
:
nvpList
)
{
sb
.
append
(
nameValuePair
.
getName
()+
":"
+
nameValuePair
.
getValue
()+
"\n"
);
}
return
sb
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
testMap
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment