记得上下班打卡 | 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
85e511d8
Commit
85e511d8
authored
Nov 16, 2021
by
zhengfuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
银联wap 支付回调
parent
7f086aca
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
73 deletions
+65
-73
DragonErrorCodeEnum.java
...iquidnet/service/dragon/constant/DragonErrorCodeEnum.java
+2
-0
PayChannelStrategyUnionpayImpl.java
...channel/strategy/impl/PayChannelStrategyUnionpayImpl.java
+48
-59
UnionpayBiz.java
...dnet/service/dragon/channel/unionpay/biz/UnionpayBiz.java
+15
-14
No files found.
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/constant/DragonErrorCodeEnum.java
View file @
85e511d8
...
@@ -29,6 +29,8 @@ public enum DragonErrorCodeEnum {
...
@@ -29,6 +29,8 @@ public enum DragonErrorCodeEnum {
TRADE_WEPAY_SIGN_ERROR
(
"PAY0020001"
,
"微信签名异常!"
),
TRADE_WEPAY_SIGN_ERROR
(
"PAY0020001"
,
"微信签名异常!"
),
TRADE_UNIONPAY_SIGN_ERROR
(
"PAY0040001"
,
"银联签名异常!"
),
TRADE_WEPAY_QUERY_ERROR
(
"PAY0020002"
,
"微信订单查询失败!"
);
TRADE_WEPAY_QUERY_ERROR
(
"PAY0020002"
,
"微信订单查询失败!"
);
private
String
code
;
private
String
code
;
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/PayChannelStrategyUnionpayImpl.java
View file @
85e511d8
...
@@ -8,6 +8,8 @@ import com.liquidnet.service.dragon.channel.alipay.constant.AlipayConstant;
...
@@ -8,6 +8,8 @@ import com.liquidnet.service.dragon.channel.alipay.constant.AlipayConstant;
import
com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler
;
import
com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.unionpay.biz.UnionpayBiz
;
import
com.liquidnet.service.dragon.channel.unionpay.biz.UnionpayBiz
;
import
com.liquidnet.service.dragon.channel.unionpay.sdk.AcpService
;
import
com.liquidnet.service.dragon.channel.unionpay.sdk.SDKConstants
;
import
com.liquidnet.service.dragon.channel.unionpay.strategy.UnionpayStrategyContext
;
import
com.liquidnet.service.dragon.channel.unionpay.strategy.UnionpayStrategyContext
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonErrorCodeEnum
;
import
com.liquidnet.service.dragon.constant.DragonErrorCodeEnum
;
...
@@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -55,6 +58,8 @@ public class PayChannelStrategyUnionpayImpl extends AbstractPayChannelStrategyIm
...
@@ -55,6 +58,8 @@ public class PayChannelStrategyUnionpayImpl extends AbstractPayChannelStrategyIm
@Autowired
@Autowired
private
DragonOrderRefundsServiceImpl
dragonOrderRefundsService
;
private
DragonOrderRefundsServiceImpl
dragonOrderRefundsService
;
@Autowired
private
AcpService
acpService
;
@Override
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
...
@@ -64,67 +69,51 @@ public class PayChannelStrategyUnionpayImpl extends AbstractPayChannelStrategyIm
...
@@ -64,67 +69,51 @@ public class PayChannelStrategyUnionpayImpl extends AbstractPayChannelStrategyIm
@Override
@Override
public
String
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
public
String
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
log
.
info
(
"unionpay-->notify-->begin payType:{} deviceFrom:{}"
,
payType
,
deviceFrom
);
log
.
info
(
"unionpay-->notify-->begin payType:{} deviceFrom:{}"
,
payType
,
deviceFrom
);
Map
<
String
,
String
[]>
requestParams
=
request
.
getParameterMap
();
try
{
Map
<
String
,
String
>
notifyMap
=
new
HashMap
<
String
,
String
>(
);
String
encoding
=
request
.
getParameter
(
SDKConstants
.
param_encoding
);
notifyMap
=
unionpayBiz
.
parseNotifyMsg
(
requestParams
);
Map
<
String
,
String
>
notifyMap
=
unionpayBiz
.
parseNotifyMsg
(
request
);
log
.
info
(
"dragonNotify-->unionpay json : {}"
,
JSON
.
toJSONString
(
notifyMap
));
log
.
info
(
"dragonNotify-->unionpay json : {}"
,
JSON
.
toJSONString
(
notifyMap
));
log
.
info
(
"接收到{}支付结果{}"
,
payType
,
notifyMap
);
log
.
info
(
"接收到{}支付结果{}"
,
payType
,
notifyMap
);
//商户订单号
String
code
=
notifyMap
.
get
(
"orderId"
);
//获取后台通知的数据
String
returnStr
=
"fail"
;
String
code
=
notifyMap
.
get
(
"out_trade_no"
);
//持久化通知记录
//持久化通知记录
dragonServiceCommonBiz
.
createDragonOrderLogs
(
code
,
dragonPayBiz
.
getPaymentType
(
payType
,
deviceFrom
),
JSON
.
toJSONString
(
notifyMap
));
dragonServiceCommonBiz
.
createDragonOrderLogs
(
code
,
dragonPayBiz
.
getPaymentType
(
payType
,
deviceFrom
),
JSON
.
toJSONString
(
notifyMap
));
//退款
if
(
notifyMap
.
containsKey
(
"refund_fee"
)
||
notifyMap
.
containsKey
(
"gmt_refund"
)
||
notifyMap
.
containsKey
(
"out_biz_no"
))
{
returnStr
=
dragonOrderRefundsService
.
aliPayRefundCallBack
(
JSON
.
toJSONString
(
notifyMap
));
return
returnStr
;
}
// 根据银行订单号获取支付信息
// 根据银行订单号获取支付信息
DragonOrdersDto
dragonOrdersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
DragonOrdersDto
dragonOrdersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
if
(
dragonOrdersDto
==
null
)
{
if
(
dragonOrdersDto
==
null
)
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getMessage
());
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getMessage
());
}
}
if
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
().
equals
(
dragonOrdersDto
.
getStatus
()))
{
if
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
().
equals
(
dragonOrdersDto
.
getStatus
()))
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getMessage
());
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getMessage
());
}
}
boolean
notifyResult
=
false
;
//1、验证签名
if
(
acpService
.
validate
(
notifyMap
,
encoding
))
{
//判断respCode=00、A6后,对涉及资金类的交易,请再发起查询接口查询,确定交易成功后更新数据库。
//因发现00 是成功 a6为有缺陷的成功,所以如果是a6则要再查一下
boolean
result
=
false
;
if
(
notifyMap
.
get
(
"respCode"
).
equals
(
"A6"
)){
//此处需要发起查询接口,要看下最终状态,等查询接口完毕后再写
result
=
true
;
}
else
if
(
notifyMap
.
get
(
"respCode"
).
equals
(
"00"
)){
result
=
true
;
}
else
{
result
=
false
;
try
{
}
// if (AlipaySignature.rsaCheckV1(notifyMap, merchantPubKey, "UTF-8", "RSA2")){
if
(
result
){
// String tradeStatus = notifyMap.get("trade_status");
notifyResult
=
this
.
completeSuccessOrder
(
dragonOrdersDto
,
notifyMap
.
get
(
"transaction_id"
),
LocalDateTime
.
now
(),
notifyMap
.
toString
());
// boolean notifyResult = false;
}
else
{
//
notifyResult
=
this
.
completeFailOrder
(
dragonOrdersDto
,
notifyMap
.
toString
());
// if (AlipayConstant.AlipayTradeStateEnum.TRADE_SUCCESS.name().equals(tradeStatus)
// ||AlipayConstant.AlipayTradeStateEnum.TRADE_FINISHED.name().equals(tradeStatus)) {
//
// String gmtPaymentStr = notifyMap.get("gmt_payment");// 付款时间
// LocalDateTime timeEnd = null;
// if (!StringUtil.isEmpty(gmtPaymentStr)) {
// timeEnd = DateUtil.Formatter.yyyyMMddHHmmss.parse(gmtPaymentStr);
// }
// notifyResult = this.completeSuccessOrder(dragonOrdersDto, notifyMap.get("trade_no"), timeEnd, notifyMap.toString());
// } else {
// notifyResult = this.completeFailOrder(dragonOrdersDto, notifyMap.toString());
// }
// if(notifyResult){
// returnStr = "success";
// }
// } else {// 验证失败
// log.error("unionpay notify fail code:{} msg:{} ",DragonErrorCodeEnum.TRADE_ALIPAY_SIGN_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_SIGN_ERROR.getMessage());
// return returnStr;
// }
}
catch
(
Exception
e
)
{
log
.
error
(
"unionpay notify fail 验签失败:e:{}"
,
e
);
log
.
error
(
"unionpay notify fail 验签失败:code:{} msg:{}"
,
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getMessage
());
}
}
log
.
info
(
"返回支付通道{}信息{}"
,
payType
,
returnStr
);
}
else
{
log
.
info
(
"unionpay-->notify-->end payType:{} deviceFrom:{}"
,
payType
,
deviceFrom
);
log
.
error
(
"unionPay notify fail code:{} msg:{} "
,
DragonErrorCodeEnum
.
TRADE_UNIONPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_UNIONPAY_SIGN_ERROR
.
getMessage
());
return
returnStr
;
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
"ok"
;
}
}
@Override
@Override
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/unionpay/biz/UnionpayBiz.java
View file @
85e511d8
...
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -452,21 +453,21 @@ public class UnionpayBiz {
...
@@ -452,21 +453,21 @@ public class UnionpayBiz {
return
sf
.
toString
();
return
sf
.
toString
();
}
}
public
static
Map
<
String
,
String
>
parseNotifyMsg
(
Map
<
String
,
String
[]>
requestParams
){
public
static
Map
<
String
,
String
>
parseNotifyMsg
(
HttpServletRequest
request
){
Map
<
String
,
String
>
res
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Enumeration
<?>
temp
=
request
.
getParameterNames
();
if
(
null
!=
temp
)
{
for
(
Iterator
iter
=
requestParams
.
keySet
().
iterator
();
iter
.
hasNext
();)
{
while
(
temp
.
hasMoreElements
())
{
String
name
=
(
String
)
iter
.
next
();
String
en
=
(
String
)
temp
.
nextElement
();
String
[]
values
=
requestParams
.
get
(
name
);
String
value
=
request
.
getParameter
(
en
);
String
valueStr
=
""
;
res
.
put
(
en
,
value
);
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
// 在报文上送时,如果字段的值为空,则不上送<下面的处理为在获取所有参数数据时,判断若值为空,则删除这个字段>
valueStr
=
(
i
==
values
.
length
-
1
)
?
valueStr
+
values
[
i
]
if
(
res
.
get
(
en
)
==
null
||
""
.
equals
(
res
.
get
(
en
)))
{
:
valueStr
+
values
[
i
]
+
","
;
// System.out.println("======为空的字段名===="+en);
res
.
remove
(
en
);
}
}
params
.
put
(
name
,
valueStr
);
}
}
}
return
param
s
;
return
re
s
;
}
}
}
}
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