记得上下班打卡 | 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
67e4a3eb
Commit
67e4a3eb
authored
Mar 10, 2022
by
zhengfuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改支付。 扫码
parent
0800694d
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
363 additions
and
28 deletions
+363
-28
AlipayBiz.java
...iquidnet/service/dragon/channel/alipay/biz/AlipayBiz.java
+51
-1
AlipayTradePayReq.java
.../service/dragon/channel/alipay/req/AlipayTradePayReq.java
+1
-0
AbstractAlipayStrategy.java
.../channel/alipay/strategy/impl/AbstractAlipayStrategy.java
+4
-0
AlipayStrategyMicropayImpl.java
...nnel/alipay/strategy/impl/AlipayStrategyMicropayImpl.java
+61
-0
AbstractPayChannelStrategyImpl.java
...channel/strategy/impl/AbstractPayChannelStrategyImpl.java
+2
-2
PayChannelStrategyAlipayImpl.java
...n/channel/strategy/impl/PayChannelStrategyAlipayImpl.java
+10
-0
WepayBiz.java
.../liquidnet/service/dragon/channel/wepay/biz/WepayBiz.java
+29
-0
WepayPayRespDto.java
...et/service/dragon/channel/wepay/resp/WepayPayRespDto.java
+38
-7
WepayStrategyMicropayImpl.java
...hannel/wepay/strategy/impl/WepayStrategyMicropayImpl.java
+126
-0
PayController.java
...om/liquidnet/service/dragon/controller/PayController.java
+8
-11
DragonOrderRefundsServiceImpl.java
...ce/dragon/service/impl/DragonOrderRefundsServiceImpl.java
+3
-3
DragonOrdersServiceImpl.java
.../service/dragon/service/impl/DragonOrdersServiceImpl.java
+4
-3
PayWepayUtils.java
...ava/com/liquidnet/service/dragon/utils/PayWepayUtils.java
+7
-1
XmlUtil.java
...main/java/com/liquidnet/service/dragon/utils/XmlUtil.java
+19
-0
No files found.
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/biz/AlipayBiz.java
View file @
67e4a3eb
...
...
@@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSONObject;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.request.AlipayTradeAppPayRequest
;
import
com.alipay.api.request.AlipayTradePayRequest
;
import
com.alipay.api.request.AlipayTradeQueryRequest
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
com.alipay.api.response.AlipayTradeAppPayResponse
;
import
com.alipay.api.response.AlipayTradePayResponse
;
import
com.alipay.api.response.AlipayTradeQueryResponse
;
import
com.alipay.api.response.AlipayTradeWapPayResponse
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
...
@@ -33,13 +35,61 @@ import java.util.*;
@Slf4j
@Component
public
class
AlipayBiz
{
/**
* tradeMicroPay
* @param alipayTradePayReq
* @return
*/
public
static
Map
<
String
,
Object
>
tradeMicroPay
(
AlipayTradePayReq
alipayTradePayReq
)
{
log
.
info
(
"AlipayBiz.tradeMicroPay-->> req : {}"
,
alipayTradePayReq
.
toString
());
AlipayClient
alipayClient
=
PayAlipayUtils
.
getInstance
().
getHttpClient
();
SortedMap
<
String
,
Object
>
paramMap
=
new
TreeMap
<>();
paramMap
.
put
(
"out_trade_no"
,
alipayTradePayReq
.
getOutTradeNo
());
paramMap
.
put
(
"total_amount"
,
alipayTradePayReq
.
getTotalAmount
().
toString
());
paramMap
.
put
(
"subject"
,
alipayTradePayReq
.
getSubject
());
paramMap
.
put
(
"scene"
,
"bar_code"
);
paramMap
.
put
(
"auth_code"
,
alipayTradePayReq
.
getAuthCode
());
AlipayTradePayRequest
request
=
new
AlipayTradePayRequest
();
log
.
info
(
"bizContent :{}"
,
JsonUtils
.
toJson
(
paramMap
));
request
.
setBizContent
(
JsonUtils
.
toJson
(
paramMap
));
try
{
long
startTime
=
System
.
currentTimeMillis
();
AlipayTradePayResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"alipay-alipayClient.sdkExecut->耗时:{}"
,(
System
.
currentTimeMillis
()
-
startTime
)+
"毫秒"
);
startTime
=
System
.
currentTimeMillis
();
Map
<
String
,
Object
>
responseJSON
=
ObjectUtil
.
cloneHashMapStringAndObj
();
log
.
info
(
"AlipayUtil-->tradeMicroPay-->cloneHashMapStringAndObj 耗时:{}"
,(
System
.
currentTimeMillis
()
-
startTime
)+
"毫秒"
);
responseJSON
.
put
(
"code"
,
response
.
getCode
());
responseJSON
.
put
(
"msg"
,
response
.
getMsg
());
responseJSON
.
put
(
"subCode"
,
response
.
getSubCode
());
responseJSON
.
put
(
"subMsg"
,
response
.
getSubMsg
());
responseJSON
.
put
(
"body"
,
response
.
getBody
());
//responseJSON.put("merchantOrderNo",response.getMerchantOrderNo());
responseJSON
.
put
(
"outTradeNo"
,
response
.
getOutTradeNo
());
//responseJSON.put("sellerId",response.getSellerId());
responseJSON
.
put
(
"totalAmount"
,
response
.
getTotalAmount
());
responseJSON
.
put
(
"tradeNo"
,
response
.
getTradeNo
());
startTime
=
System
.
currentTimeMillis
();
log
.
info
(
"AlipayUtil-->tradeMicroPay-->支付宝返回结果:{}"
,
JsonUtils
.
toJson
(
response
));
log
.
info
(
"AlipayUtil-->tradeMicroPay-->支付宝返回结果 耗时:{}"
,(
System
.
currentTimeMillis
()
-
startTime
)+
"毫秒"
);
return
responseJSON
;
}
catch
(
Exception
e
)
{
log
.
error
(
"支付宝支付异常:{}"
,
e
);
JSONObject
resultJSON
=
ObjectUtil
.
cloneJsonObjectObj
();
resultJSON
.
put
(
"outTradeNo"
,
alipayTradePayReq
.
getOutTradeNo
());
resultJSON
.
put
(
"totalAmount"
,
alipayTradePayReq
.
getTotalAmount
().
toString
());
resultJSON
.
put
(
"errorCode"
,
"9999"
);
return
resultJSON
;
}
}
/**
* tradeWapPay
* @param alipayTradePayReq
* @return
*/
public
static
Map
<
String
,
Object
>
tradeWapPay
(
AlipayTradePayReq
alipayTradePayReq
)
{
log
.
info
(
"AlipayBiz.tradeWapPay-->> req : {}"
,
alipayTradePayReq
.
toString
());
log
.
info
(
"AlipayBiz.tradeWapPay
tradeWapPay
-->> req : {}"
,
alipayTradePayReq
.
toString
());
String
timeExpress
=
"5m"
;
// 支付超时,线下扫码交易定义为5分钟
AlipayClient
alipayClient
=
PayAlipayUtils
.
getInstance
().
getHttpClient
();
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/req/AlipayTradePayReq.java
View file @
67e4a3eb
...
...
@@ -26,6 +26,7 @@ public class AlipayTradePayReq implements Serializable, Cloneable{
private
String
timeExpire
;
private
String
notifyUrl
;
private
String
timestamp
;
private
String
authCode
;
@Override
public
String
toString
(){
return
JSON
.
toJSONString
(
this
);
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/strategy/impl/AbstractAlipayStrategy.java
View file @
67e4a3eb
...
...
@@ -51,12 +51,16 @@ public abstract class AbstractAlipayStrategy implements IAlipayStrategy {
alipayTradePayReq
.
setTimeExpire
(
timeExpire
);
alipayTradePayReq
.
setNotifyUrl
(
this
.
getNotifyUrl
());
alipayTradePayReq
.
setTimestamp
(
dragonPayBaseReqDto
.
getCreateDate
());
alipayTradePayReq
.
setAuthCode
(
dragonPayBaseReqDto
.
getAuthCode
());
//调用支付
long
startTime
=
System
.
currentTimeMillis
();
Map
<
String
,
Object
>
result
=
this
.
executePay
(
alipayTradePayReq
);
// log.info("dragonPay:alipay:"+dragonPayBaseReqDto.getDeviceFrom()+" response xmlStr: {} ", JSON.toJSONString(result));
log
.
info
(
"alipay-dragonPay->耗时:{}"
,(
System
.
currentTimeMillis
()
-
startTime
)+
"毫秒"
);
if
(
null
!=
result
.
get
(
"code"
)&&
result
.
get
(
"code"
).
toString
().
equals
(
"40004"
)){
return
null
;
}
//拼接返回参数
DragonPayBaseRespDto
respDto
=
buildCommonRespDto
(
dragonPayBaseReqDto
);
respDto
=
this
.
buildResponseDto
(
respDto
,
result
);
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/strategy/impl/AlipayStrategyMicropayImpl.java
0 → 100644
View file @
67e4a3eb
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
strategy
.
impl
;
import
com.liquidnet.service.dragon.channel.alipay.biz.AlipayBiz
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.annotation.StrategyAlipayHandler
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayStrategyWapImpl
* @Package com.liquidnet.service.dragon.channel.alipay.strategy.impl
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/10 14:34
*/
@Slf4j
@Service
@StrategyAlipayHandler
(
DragonConstant
.
DeviceFromEnum
.
MICROPAY
)
public
class
AlipayStrategyMicropayImpl
extends
AbstractAlipayStrategy
{
@Value
(
"${liquidnet.dragon.alipay.gataway-url}"
)
private
String
alipayGatewayUrl
;
@Value
(
"${liquidnet.dragon.url}"
)
private
String
notifyUrl
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
AlipayBiz
alipayBiz
;
@Override
protected
Map
<
String
,
Object
>
executePay
(
AlipayTradePayReq
alipayTradePayReq
)
{
return
alipayBiz
.
tradeMicroPay
(
alipayTradePayReq
);
}
protected
void
setProductCode
()
{
this
.
productCode
=
"QUICK_WAP_PAY"
;
}
@Override
protected
String
getNotifyUrl
()
{
// notifyUrl = "/notify/wap/alipay/1";
return
notifyUrl
+
"/notify/alipay/wap"
;
}
@Override
DragonPayBaseRespDto
buildResponseDto
(
DragonPayBaseRespDto
payBaseRespDto
,
Map
<
String
,
Object
>
respResult
)
{
// payBaseRespDto.getPayData().setRedirectUrl(alipayGatewayUrl + "?" + respResult.get("body"));
return
payBaseRespDto
;
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/AbstractPayChannelStrategyImpl.java
View file @
67e4a3eb
...
...
@@ -53,7 +53,7 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
* @param bankReturnMsg
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
p
rotected
boolean
completeSuccessOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankTrxNo
,
LocalDateTime
timeEnd
,
String
bankReturnMsg
)
{
p
ublic
boolean
completeSuccessOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankTrxNo
,
LocalDateTime
timeEnd
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付成功!"
);
dragonOrdersDto
.
setPaymentAt
(
timeEnd
);
dragonOrdersDto
.
setPaymentId
(
bankTrxNo
);
// 设置银行流水号
...
...
@@ -71,7 +71,7 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
* @param dragonOrdersDto
* @param bankReturnMsg
*/
p
rotected
boolean
completeFailOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankReturnMsg
)
{
p
ublic
boolean
completeFailOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付失败!"
);
// dragonOrdersDto.setPaymentAt(timeEnd);
// dragonOrdersDto.setPaymentId(bankTrxNo);// 设置银行流水号
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/PayChannelStrategyAlipayImpl.java
View file @
67e4a3eb
...
...
@@ -149,6 +149,9 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
/* DragonOrdersDto ordersDto = dataUtils.getPayOrderByCode(code);
DragonPayOrderQueryRespDto respDto = alipayStrategyContext.getStrategy(DragonConstant.PayTypeEnum.getEnumByCode(ordersDto.getPaymentType()).getDeviceFrom()).checkOrderStatus(code);
*/
DragonOrdersDto
ordersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
Map
<
String
,
Object
>
resultMap
=
alipayBiz
.
tradeQuery
(
code
);
DragonPayOrderQueryRespDto
respDto
=
dragonPayBiz
.
buildPayOrderQueryRespDto
(
ordersDto
);
...
...
@@ -157,8 +160,14 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
if
(
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_SUCCESS
.
getCode
().
equals
(
resultMap
.
get
(
"tradeStatus"
))
||
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_FINISHED
.
getCode
().
equals
(
resultMap
.
get
(
"tradeStatus"
)))
{
respDto
.
setStatus
(
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
()));
if
(
ordersDto
.
getPaymentType
().
equals
(
DragonConstant
.
PayTypeEnum
.
PAYMENT_TYPE_MICROPAY_ALIPAY
.
getCode
())){
this
.
completeSuccessOrder
(
ordersDto
,
resultMap
.
get
(
"tradeNo"
).
toString
(),
LocalDateTime
.
now
(),
resultMap
.
toString
());
}
}
else
{
respDto
.
setStatus
(
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAY_FAIL
.
getCode
()));
if
(
ordersDto
.
getPaymentType
().
equals
(
DragonConstant
.
PayTypeEnum
.
PAYMENT_TYPE_MICROPAY_ALIPAY
.
getCode
())){
this
.
completeFailOrder
(
ordersDto
,
resultMap
.
toString
());
}
}
// throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getMessage());
}
else
if
(
"40004"
.
equals
(
resultMap
.
get
(
"code"
))&&
"ACQ.TRADE_NOT_EXIST"
.
equalsIgnoreCase
(
resultMap
.
get
(
"subCode"
).
toString
())){
...
...
@@ -168,4 +177,5 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
}
return
respDto
;
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/biz/WepayBiz.java
View file @
67e4a3eb
...
...
@@ -63,6 +63,35 @@ public class WepayBiz{
log
.
error
(
e
.
getMessage
());
}
return
respMap
;
}
public
Map
<
String
,
String
>
tradeQueryString
(
String
outTradeNo
,
String
appid
)
{
log
.
info
(
"WepayBiz.tradeQuery-->> request outTradeNo:{} appid:{} "
,
outTradeNo
,
appid
);
Map
<
String
,
String
>
respMap
=
new
HashMap
<>();
SortedMap
<
String
,
Object
>
paramMap
=
new
TreeMap
<>();
paramMap
.
put
(
"appid"
,
appid
);
paramMap
.
put
(
"mch_id"
,
merchantId
);
String
nonce_str
=
PayWepayUtils
.
getInstance
().
getNonceStr
();
paramMap
.
put
(
"nonce_str"
,
nonce_str
);
paramMap
.
put
(
"out_trade_no"
,
outTradeNo
);
String
sign
=
PayWepayUtils
.
getInstance
().
createSign
(
paramMap
);
paramMap
.
put
(
"sign"
,
sign
);
String
data
=
PayWepayUtils
.
getInstance
().
getRequestXml
(
paramMap
);
try
{
HttpPost
httpost
=
new
HttpPost
(
"https://api.mch.weixin.qq.com/pay/orderquery"
);
httpost
.
setEntity
(
new
StringEntity
(
data
,
"UTF-8"
));
CloseableHttpResponse
response
=
PayWepayUtils
.
getInstance
().
getHttpClient
().
execute
(
httpost
);
HttpEntity
entity
=
response
.
getEntity
();
//接受到返回信息
String
xmlStr
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
log
.
info
(
"WepayBiz.tradeQuery-->> response xmlStr: {} "
,
xmlStr
);
respMap
=
XmlUtil
.
xmlToMapString
(
xmlStr
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
}
return
respMap
;
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/resp/WepayPayRespDto.java
View file @
67e4a3eb
...
...
@@ -36,19 +36,50 @@ public class WepayPayRespDto {
private
String
tradeType
;
//MWEB
@XStreamAlias
(
"mweb_url"
)
private
String
mwebUrl
;
//https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx111130490949693ab00f679072ea730000&package=2011082926
@XStreamAlias
(
"openid"
)
private
String
openid
;
@XStreamAlias
(
"is_subscribe"
)
private
String
is_subscribe
;
@XStreamAlias
(
"bank_type"
)
private
String
bank_type
;
@XStreamAlias
(
"fee_type"
)
private
String
fee_type
;
@XStreamAlias
(
"total_fee"
)
private
String
total_fee
;
@XStreamAlias
(
"cash_fee_type"
)
private
String
cash_fee_type
;
@XStreamAlias
(
"cash_fee"
)
private
String
cash_fee
;
@XStreamAlias
(
"transaction_id"
)
private
String
transaction_id
;
@XStreamAlias
(
"out_trade_no"
)
private
String
out_trade_no
;
@XStreamAlias
(
"attach"
)
private
String
attach
;
@XStreamAlias
(
"time_end"
)
private
String
time_end
;
public
static
void
xmlToBean
(){
String
xmlStr
=
"<xml><return_code><![CDATA[SUCCESS]]></return_code>\n"
+
"<return_msg><![CDATA[OK]]></return_msg>\n"
+
"<result_code><![CDATA[SUCCESS]]></result_code>\n"
+
"<mch_id><![CDATA[1551961491]]></mch_id>\n"
+
"<appid><![CDATA[wx3498304dda39c5a1]]></appid>\n"
+
"<nonce_str><![CDATA[Y6Czfx4lhuSv0yUD]]></nonce_str>\n"
+
"<sign><![CDATA[97001E77813055D03E3009F67A836D62]]></sign>\n"
+
"<prepay_id><![CDATA[wx111130490949693ab00f679072ea730000]]></prepay_id>\n"
+
"<trade_type><![CDATA[MWEB]]></trade_type>\n"
+
"<mweb_url><![CDATA[https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx111130490949693ab00f679072ea730000&package=2011082926]]></mweb_url>\n"
+
"</xml> "
;
"<appid><![CDATA[wx86f9777acf2cb585]]></appid>\n"
+
"<nonce_str><![CDATA[sBhYlCmhZYveVghZ]]></nonce_str>\n"
+
"<sign><![CDATA[C3760928A28B51A74A41F856D0B0B034]]></sign>\n"
+
"<openid><![CDATA[oWadFuJlPcQS_iD1YQGfJ-cfVKQI]]></openid>\n"
+
"<is_subscribe><![CDATA[N]]></is_subscribe>\n"
+
"<trade_type><![CDATA[MICROPAY]]></trade_type>\n"
+
"<bank_type><![CDATA[OTHERS]]></bank_type>\n"
+
"<fee_type><![CDATA[CNY]]></fee_type>\n"
+
"<total_fee>1</total_fee>\n"
+
"<cash_fee_type><![CDATA[CNY]]></cash_fee_type>\n"
+
"<cash_fee>1</cash_fee>\n"
+
"<transaction_id><![CDATA[4200001413202202214878147508]]></transaction_id>\n"
+
"<out_trade_no><![CDATA[PAY202202211642184423445159]]></out_trade_no>\n"
+
"<attach><![CDATA[]]></attach>\n"
+
"<time_end><![CDATA[20220221164220]]></time_end>\n"
+
"</xml> "
;
WepayPayRespDto
respDto
=
XmlUtil
.
toBean
(
xmlStr
,
WepayPayRespDto
.
class
);
System
.
out
.
println
(
"respDto.getAppid()=="
+
respDto
.
getAppid
());
System
.
out
.
println
(
"respDto.getMwebUrl()==="
+
respDto
.
getMwebUrl
());
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/impl/WepayStrategyMicropayImpl.java
0 → 100644
View file @
67e4a3eb
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
wepay
.
strategy
.
impl
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.impl.PayChannelStrategyWepayImpl
;
import
com.liquidnet.service.dragon.channel.wepay.biz.WepayBiz
;
import
com.liquidnet.service.dragon.channel.wepay.resp.WepayPayRespDto
;
import
com.liquidnet.service.dragon.channel.wepay.strategy.annotation.StrategyWepayHandler
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonErrorCodeEnum
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.util.Map
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayStrategyWapImpl
* @Package com.liquidnet.service.dragon.channel.alipay.strategy.impl
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/10 14:34
*/
@Slf4j
@Component
@StrategyWepayHandler
(
DragonConstant
.
DeviceFromEnum
.
MICROPAY
)
public
class
WepayStrategyMicropayImpl
extends
AbstractWepayStrategy
{
@Value
(
"${liquidnet.dragon.url}"
)
private
String
notifyUrl
;
@Autowired
private
DataUtils
dataUtils
;
@Autowired
private
WepayBiz
wepayBiz
;
@Autowired
private
DragonPayBiz
dragonPayBiz
;
@Autowired
private
PayChannelStrategyWepayImpl
payChannelStrategyWepay
;
@Override
SortedMap
<
String
,
Object
>
appendRequestParam
(
SortedMap
<
String
,
Object
>
requestMap
,
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
// requestMap.put("trade_type", "MICROPAY");
requestMap
.
put
(
"appid"
,
PayWepayUtils
.
getInstance
().
getAPP_ID
());
requestMap
.
remove
(
"notify_url"
);
requestMap
.
put
(
"auth_code"
,
dragonPayBaseReqDto
.
getAuthCode
());
return
requestMap
;
}
@Override
DragonPayBaseRespDto
buildResponseDto
(
DragonPayBaseRespDto
payBaseRespDto
,
WepayPayRespDto
respDto
)
{
payBaseRespDto
.
getPayData
().
setPackages
(
"Sign=WXPay"
);
//设置签名
SortedMap
<
String
,
Object
>
paramMap
=
new
TreeMap
<
String
,
Object
>();
paramMap
.
put
(
"appid"
,
payBaseRespDto
.
getPayData
().
getAppId
());
paramMap
.
put
(
"partnerid"
,
payBaseRespDto
.
getPayData
().
getPartnerId
());
paramMap
.
put
(
"prepayid"
,
payBaseRespDto
.
getPayData
().
getPrepayId
());
paramMap
.
put
(
"package"
,
payBaseRespDto
.
getPayData
().
getPackages
());
paramMap
.
put
(
"noncestr"
,
payBaseRespDto
.
getPayData
().
getNonceStr
());
paramMap
.
put
(
"timestamp"
,
payBaseRespDto
.
getPayData
().
getTimeStamp
());
log
.
info
(
"wepay sercond sign param :{} "
,
JsonUtils
.
toJson
(
paramMap
));
String
sign
=
PayWepayUtils
.
getInstance
().
createSign
(
paramMap
);
payBaseRespDto
.
getPayData
().
setPaySign
(
sign
);
return
payBaseRespDto
;
}
@Override
protected
String
getRequestUrl
()
{
return
"https://api.mch.weixin.qq.com/pay/micropay"
;
}
@Override
protected
String
getNotifyUrl
()
{
return
notifyUrl
+
""
;
}
@Override
protected
String
getAppid
()
{
return
PayWepayUtils
.
getInstance
().
getAPP_ID
();
}
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
DragonOrdersDto
ordersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
//持久化通知记录
// 根据银行订单号获取支付信息
DragonOrdersDto
dragonOrdersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
if
(
dragonOrdersDto
==
null
)
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getMessage
());
}
if
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
().
equals
(
dragonOrdersDto
.
getStatus
()))
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getMessage
());
}
Map
<
String
,
String
>
resultMap
=
wepayBiz
.
tradeQueryString
(
code
,
this
.
getAppid
());
DragonPayOrderQueryRespDto
respDto
=
dragonPayBiz
.
buildPayOrderQueryRespDto
(
ordersDto
);
Object
returnCode
=
resultMap
.
get
(
"return_code"
);
// 查询失败
if
(
null
==
returnCode
||
"FAIL"
.
equals
(
returnCode
))
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_WEPAY_QUERY_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_WEPAY_QUERY_ERROR
.
getMessage
());
}
// 当trade_state为SUCCESS时才返回result_code
if
(
"SUCCESS"
.
equals
(
resultMap
.
get
(
"trade_state"
)))
{
String
sign
=
resultMap
.
remove
(
"sign"
);
if
(
PayWepayUtils
.
getInstance
().
notifySign
(
resultMap
,
sign
)){
// 修改订单状态等。
payChannelStrategyWepay
.
completeSuccessOrder
(
dragonOrdersDto
,
resultMap
.
get
(
"transaction_id"
),
LocalDateTime
.
now
(),
resultMap
.
toString
());
respDto
.
setStatus
(
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
()));
}
else
{
payChannelStrategyWepay
.
completeFailOrder
(
dragonOrdersDto
,
resultMap
.
toString
());
}
}
return
respDto
;
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/controller/PayController.java
View file @
67e4a3eb
/*
package
com
.
liquidnet
.
service
.
dragon
.
controller
;
import
com.liquidnet.commons.lang.util.StringUtil
;
...
...
@@ -21,7 +20,6 @@ import java.math.BigDecimal;
import
java.util.HashMap
;
import
java.util.Map
;
*/
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
...
...
@@ -30,8 +28,7 @@ import java.util.Map;
* @Package com.liquidnet.service.dragon.controller
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 12:29
*//*
*/
@Slf4j
@RestController
@RequestMapping
(
"pay"
)
...
...
@@ -39,19 +36,17 @@ public class PayController {
@Autowired
private
IDragonOrdersService
dragonOrdersService
;
*/
/**
/**
* 电脑网页支付宝支付
*
* @return
*//*
*/
@PostMapping
(
"/dragonPay"
)
@ApiOperation
(
"Dragon支付"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"payType"
,
value
=
"支付类型:alipay,wepay,unionpay,applepay"
,
example
=
"unionpay"
),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "deviceFrom", value = "设备来源:web,wap,app,js,apple", example = "wap"),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"deviceFrom"
,
value
=
"设备来源:web,wap,app,js,apple
,micropay
"
,
example
=
"wap"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"type"
,
value
=
"业务类型:TICKET,PRODUCT,COST,MBEANS,LIVE,VIDEO,VIP,CLUB,STRAWBERRY"
,
example
=
"TICKET"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"price"
,
value
=
"支付金额"
,
example
=
"0.1"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"name"
,
value
=
"订单名称"
,
example
=
"测试订单001"
),
...
...
@@ -62,6 +57,7 @@ public class PayController {
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"notifyUrl"
,
value
=
"通知url"
,
example
=
"devdragon.zhengzai.tv"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"createDate"
,
value
=
"订单创建时间"
,
example
=
"2021-11-10 13:00:00"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"expireTime"
,
value
=
"订单过期时间"
,
example
=
"1000"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
false
,
dataType
=
"String"
,
name
=
"authCode"
,
value
=
"付款码"
,
example
=
"1000"
),
})
@ResponseBody
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
...
...
@@ -81,7 +77,8 @@ public class PayController {
@RequestParam
(
value
=
"showUrl"
,
required
=
false
)
String
showUrl
,
// @RequestParam(value = "code",required = false) String code,
@RequestParam
(
value
=
"createDate"
,
required
=
true
)
String
createDate
,
@RequestParam(value = "expireTime", required = true) String expireTime) {
@RequestParam
(
value
=
"expireTime"
,
required
=
true
)
String
expireTime
,
@RequestParam
(
value
=
"authCode"
,
required
=
false
)
String
authCode
)
{
long
startTime
=
System
.
currentTimeMillis
();
//为什么在js和applet中才需要判断open_id?
if
(
payType
.
equalsIgnoreCase
(
DragonConstant
.
PayChannelEnum
.
WEPAY
.
getCode
()))
{
...
...
@@ -97,6 +94,7 @@ public class PayController {
dragonPayBaseReqDto
.
setOpenId
(
openId
);
dragonPayBaseReqDto
.
setType
(
type
);
dragonPayBaseReqDto
.
setPrice
(
price
);
dragonPayBaseReqDto
.
setAuthCode
(
authCode
);
// if(StringUtil.isNotNull(name)&&name.length()>=32){
// name = name.substring(0,32);
// }
...
...
@@ -161,4 +159,3 @@ public class PayController {
return
ResponseDto
.
success
(
rs
);
}
}
*/
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrderRefundsServiceImpl.java
View file @
67e4a3eb
...
...
@@ -100,12 +100,12 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
case
DragonConstant
.
REFUND_TYPE_WEB_ALIPAY
:
dto
=
aliPayRefund
(
code
,
orderRefundCode
,
code
,
reason
,
price
,
paymentId
,
paymentType
,
nowTime
);
break
;
case
DragonConstant
.
REFUND_TYPE_MICROPAY_ALIPAY
:
dto
=
aliPayRefund
(
code
,
orderRefundCode
,
code
,
reason
,
price
,
paymentId
,
paymentType
,
nowTime
);
break
;
case
DragonConstant
.
REFUND_TYPE_APP_WEPAY
:
dto
=
weyPayRefund
(
code
,
orderRefundCode
,
code
,
reason
,
price
,
priceTotal
,
paymentId
,
paymentType
,
localWePayCallBackUrl
,
nowTime
);
break
;
case
DragonConstant
.
REFUND_TYPE_MICROPAY_ALIPAY
:
dto
=
aliPayRefund
(
code
,
orderRefundCode
,
code
,
reason
,
price
,
paymentId
,
paymentType
,
nowTime
);
break
;
case
DragonConstant
.
REFUND_TYPE_WAP_WEPAY
:
dto
=
weyPayRefund
(
code
,
orderRefundCode
,
code
,
reason
,
price
,
priceTotal
,
paymentId
,
paymentType
,
localWePayCallBackUrl
,
nowTime
);
break
;
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrdersServiceImpl.java
View file @
67e4a3eb
...
...
@@ -55,11 +55,12 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
if
(
StringUtil
.
isEmpty
(
ordersDto
)){
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getMessage
());
}
//如果已支付 直接返回结果
if
(!
ordersDto
.
getStatus
().
toString
().
equals
(
DragonConstant
.
PayStatusEnum
.
STATUS_UNPAID
.
getCode
())){
//如果已支付 直接返回结果 // MICROPAYWEPAY MICROPAYALIPAY
if
(!
ordersDto
.
getStatus
().
toString
().
equals
(
DragonConstant
.
PayStatusEnum
.
STATUS_UNPAID
.
getCode
())&&!
ordersDto
.
getPaymentType
().
equals
(
"MICROPAYALIPAY"
)&&!
ordersDto
.
getPaymentType
().
equals
(
"MICROPAYWEPAY"
)){
return
dragonPayBiz
.
buildPayOrderQueryRespDto
(
ordersDto
);
}
//如果未支付进行三方查询
//如果未支付进行三方查询
`
String
payType
=
DragonConstant
.
PayTypeEnum
.
getEnumByCode
(
ordersDto
.
getPaymentType
()).
getPayType
();
return
payChannelStrategyContext
.
getStrategy
(
payType
).
checkOrderStatus
(
code
);
}
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/utils/PayWepayUtils.java
View file @
67e4a3eb
...
...
@@ -2,6 +2,7 @@ package com.liquidnet.service.dragon.utils;
import
com.alipay.api.internal.util.file.IOUtils
;
import
com.liquidnet.commons.lang.util.MD5Utils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.config.Registry
;
import
org.apache.http.config.RegistryBuilder
;
...
...
@@ -265,7 +266,12 @@ public class PayWepayUtils {
SortedMap
<
String
,
Object
>
smap
=
new
TreeMap
<
String
,
Object
>(
map
);
StringBuffer
sb
=
new
StringBuffer
();
for
(
Map
.
Entry
<
String
,
Object
>
m
:
smap
.
entrySet
())
{
sb
.
append
(
m
.
getKey
()).
append
(
"="
).
append
(
m
.
getValue
()).
append
(
"&"
);
if
(
null
!=
m
.
getValue
()){
if
(
StringUtils
.
isNotBlank
(
m
.
getValue
().
toString
())){
sb
.
append
(
m
.
getKey
()).
append
(
"="
).
append
(
m
.
getValue
()).
append
(
"&"
);
}
}
}
sb
.
delete
(
sb
.
length
()
-
1
,
sb
.
length
());
return
sb
.
toString
();
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/utils/XmlUtil.java
View file @
67e4a3eb
...
...
@@ -131,6 +131,25 @@ public class XmlUtil{
}
return
xmlMap
;
}
public
static
Map
<
String
,
String
>
xmlToMapString
(
String
xmlDoc
)
throws
DocumentException
{
// 创建一个新的字符串
StringReader
read
=
new
StringReader
(
xmlDoc
);
// 创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入
InputSource
source
=
new
InputSource
(
read
);
// 创建一个新的SAXBuilder
SAXReader
saxReader
=
new
SAXReader
();
Map
<
String
,
String
>
xmlMap
=
new
HashMap
<
String
,
String
>();
Document
doc
=
saxReader
.
read
(
source
);
// 通过输入源构造一个Document
Element
root
=
doc
.
getRootElement
();
// 取的根元素
List
<
Element
>
elements
=
root
.
elements
();
// 得到根元素所有子元素的集合(根元素的子节点,不包括孙子节点)
for
(
Element
et
:
elements
)
{
xmlMap
.
put
(
et
.
getName
(),
et
.
getText
());
}
return
xmlMap
;
}
// /**
// * 从xml文件读取报文
...
...
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