记得上下班打卡 | 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
c2a6385e
Commit
c2a6385e
authored
Nov 12, 2021
by
zhengfuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抖音查询订单。
parent
5c007492
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
9 deletions
+76
-9
DragonErrorCodeEnum.java
...iquidnet/service/dragon/constant/DragonErrorCodeEnum.java
+1
-1
DouYinPayBiz.java
...et/service/dragon/channel/douyinpay/biz/DouYinPayBiz.java
+67
-0
AbstractDouYinPayStrategy.java
...el/douyinpay/strategy/impl/AbstractDouYinPayStrategy.java
+7
-7
DouYinPayStrategyAppletImpl.java
.../douyinpay/strategy/impl/DouYinPayStrategyAppletImpl.java
+1
-1
No files found.
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/constant/DragonErrorCodeEnum.java
View file @
c2a6385e
...
@@ -31,7 +31,7 @@ public enum DragonErrorCodeEnum {
...
@@ -31,7 +31,7 @@ public enum DragonErrorCodeEnum {
TRADE_DOUYINPAY_SIGN_ERROR
(
"PAY0030001"
,
"抖音签名异常!"
),
TRADE_DOUYINPAY_SIGN_ERROR
(
"PAY0030001"
,
"抖音签名异常!"
),
TRADE_DOUYINPAY_QUERY_ERROR
(
"PAY0030002"
,
"抖音查询
退款
异常!"
),
TRADE_DOUYINPAY_QUERY_ERROR
(
"PAY0030002"
,
"抖音查询
支付订单
异常!"
),
TRADE_WEPAY_QUERY_ERROR
(
"PAY0020002"
,
"微信订单查询失败!"
);
TRADE_WEPAY_QUERY_ERROR
(
"PAY0020002"
,
"微信订单查询失败!"
);
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/douyinpay/biz/DouYinPayBiz.java
0 → 100644
View file @
c2a6385e
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
douyinpay
.
biz
;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.service.dragon.utils.PayDouYinpayUtils
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
com.liquidnet.service.dragon.utils.XmlUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
/**
* @author zhangfuxin
* @Description:
* @date 2021/11/12 上午11:15
*/
@Slf4j
@Component
public
class
DouYinPayBiz
{
@Value
(
"${liquidnet.dragon.wepay.merchantId}"
)
private
String
merchantId
;
/**
* @author zhangfuxin
* @Description:抖音订单查询 实现
* @date 2021/11/12 上午11:27
*/
public
Map
<
String
,
Object
>
tradeQuery
(
String
outOrderNo
,
String
appid
)
{
Map
<
String
,
Object
>
respMap
=
new
HashMap
<>();
log
.
info
(
"DouYinPayBiz.tradeQuery-->> request out_order_no:{} appid:{} "
,
outOrderNo
,
appid
);
SortedMap
<
String
,
Object
>
parameters
=
new
TreeMap
<>();
parameters
.
put
(
"app_id"
,
appid
);
parameters
.
put
(
"out_order_no"
,
outOrderNo
);
//生成签名
String
sign
=
PayDouYinpayUtils
.
getInstance
().
createSign
(
parameters
);
parameters
.
put
(
"sign"
,
sign
);
//map转string
String
data
=
JSON
.
toJSONString
(
parameters
);
log
.
info
(
"抖音订单查询请求参数:{}"
,
data
);
try
{
HttpPost
httpost
=
new
HttpPost
(
"https://developer.toutiao.com/api/apps/ecpay/v1/query_order"
);
httpost
.
setEntity
(
new
StringEntity
(
data
,
"UTF-8"
));
CloseableHttpClient
httpClient
=
PayDouYinpayUtils
.
getInstance
().
getHttpClient
();
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpost
);
HttpEntity
entity
=
response
.
getEntity
();
//接受到返回信息
String
json
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
log
.
info
(
"抖音订单查询接口返回:{}"
,
json
);
EntityUtils
.
consume
(
entity
);
respMap
=
JSON
.
parseObject
(
json
,
HashMap
.
class
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
}
return
respMap
;
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/douyinpay/strategy/impl/AbstractDouYinPayStrategy.java
View file @
c2a6385e
...
@@ -5,6 +5,7 @@ import com.liquidnet.common.exception.LiquidnetServiceException;
...
@@ -5,6 +5,7 @@ import com.liquidnet.common.exception.LiquidnetServiceException;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.channel.douyinpay.biz.DouYinPayBiz
;
import
com.liquidnet.service.dragon.channel.douyinpay.constant.DouYinpayConstant
;
import
com.liquidnet.service.dragon.channel.douyinpay.constant.DouYinpayConstant
;
import
com.liquidnet.service.dragon.channel.douyinpay.strategy.IDouYinpayStrategy
;
import
com.liquidnet.service.dragon.channel.douyinpay.strategy.IDouYinpayStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
...
@@ -50,7 +51,7 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
...
@@ -50,7 +51,7 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
// 订单过期时间(秒); 最小 15 分钟,最大两天
// 订单过期时间(秒); 最小 15 分钟,最大两天
private
int
valid_time
=
60
*
60
*
24
*
2
;
private
int
valid_time
=
60
*
60
*
24
*
2
;
@Autowired
@Autowired
private
WepayBiz
wep
ayBiz
;
private
DouYinPayBiz
douYinP
ayBiz
;
@Autowired
@Autowired
private
DataUtils
dataUtils
;
private
DataUtils
dataUtils
;
...
@@ -74,7 +75,7 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
...
@@ -74,7 +75,7 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
String
sign
=
PayDouYinpayUtils
.
getInstance
().
createSign
(
parameters
);
String
sign
=
PayDouYinpayUtils
.
getInstance
().
createSign
(
parameters
);
parameters
.
put
(
"sign"
,
sign
);
parameters
.
put
(
"sign"
,
sign
);
//
构造支付请求xml
//
map转string
String
data
=
JSON
.
toJSONString
(
parameters
);
String
data
=
JSON
.
toJSONString
(
parameters
);
log
.
info
(
"dragonPay:douYinPay:"
+
dragonPayBaseReqDto
.
getDeviceFrom
()+
" request jsondata: {} "
,
data
);
log
.
info
(
"dragonPay:douYinPay:"
+
dragonPayBaseReqDto
.
getDeviceFrom
()+
" request jsondata: {} "
,
data
);
...
@@ -134,7 +135,6 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
...
@@ -134,7 +135,6 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
* @return
* @return
*/
*/
protected
SortedMap
<
String
,
Object
>
buildRequestParamMap
(
DragonPayBaseReqDto
dragonPayBaseReqDto
){
protected
SortedMap
<
String
,
Object
>
buildRequestParamMap
(
DragonPayBaseReqDto
dragonPayBaseReqDto
){
String
nonceStr
=
PayWepayUtils
.
getInstance
().
getNonceStr
();
SortedMap
<
String
,
Object
>
parameters
=
new
TreeMap
<>();
SortedMap
<
String
,
Object
>
parameters
=
new
TreeMap
<>();
parameters
.
put
(
"total_amount"
,
dragonPayBaseReqDto
.
getPrice
().
multiply
(
BigDecimal
.
valueOf
(
100L
)).
intValue
());
parameters
.
put
(
"total_amount"
,
dragonPayBaseReqDto
.
getPrice
().
multiply
(
BigDecimal
.
valueOf
(
100L
)).
intValue
());
//商品描述; 长度限制 128 字节,不超过 42 个汉字
//商品描述; 长度限制 128 字节,不超过 42 个汉字
...
@@ -175,13 +175,13 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
...
@@ -175,13 +175,13 @@ public abstract class AbstractDouYinPayStrategy implements IDouYinpayStrategy {
@Override
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
DragonOrdersDto
ordersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
DragonOrdersDto
ordersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
Map
<
String
,
Object
>
resultMap
=
wep
ayBiz
.
tradeQuery
(
code
,
this
.
getAppid
());
Map
<
String
,
Object
>
resultMap
=
douYinP
ayBiz
.
tradeQuery
(
code
,
this
.
getAppid
());
DragonPayOrderQueryRespDto
respDto
=
dragonPayBiz
.
buildPayOrderQueryRespDto
(
ordersDto
);
DragonPayOrderQueryRespDto
respDto
=
dragonPayBiz
.
buildPayOrderQueryRespDto
(
ordersDto
);
Object
returnCode
=
resultMap
.
get
(
"return_code
"
);
Object
orderStatus
=
resultMap
.
get
(
"order_status
"
);
// 查询失败
// 查询失败
if
(
null
==
returnCode
||
"FAIL"
.
equals
(
returnCode
))
{
if
(
null
==
orderStatus
||
"FAIL"
.
equals
(
orderStatus
))
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_
WEPAY_QUERY_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_WE
PAY_QUERY_ERROR
.
getMessage
());
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_
DOUYINPAY_QUERY_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_DOUYIN
PAY_QUERY_ERROR
.
getMessage
());
}
}
// 当trade_state为SUCCESS时才返回result_code
// 当trade_state为SUCCESS时才返回result_code
if
(
"SUCCESS"
.
equals
(
resultMap
.
get
(
"trade_state"
)))
{
if
(
"SUCCESS"
.
equals
(
resultMap
.
get
(
"trade_state"
)))
{
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/douyinpay/strategy/impl/DouYinPayStrategyAppletImpl.java
View file @
c2a6385e
...
@@ -56,6 +56,6 @@ public class DouYinPayStrategyAppletImpl extends AbstractDouYinPayStrategy {
...
@@ -56,6 +56,6 @@ public class DouYinPayStrategyAppletImpl extends AbstractDouYinPayStrategy {
@Override
@Override
protected
String
getAppid
()
{
protected
String
getAppid
()
{
return
Pay
We
payUtils
.
getInstance
().
getAPP_ID
();
return
Pay
DouYin
payUtils
.
getInstance
().
getAPP_ID
();
}
}
}
}
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