记得上下班打卡 | 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
69a2a630
Commit
69a2a630
authored
Jul 19, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
ee162f60
82c6319d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
276 additions
and
219 deletions
+276
-219
DragonPayOrderQueryRespDto.java
...uidnet/service/dragon/dto/DragonPayOrderQueryRespDto.java
+1
-0
PayNotifyDto.java
...n/java/com/liquidnet/service/dragon/dto/PayNotifyDto.java
+1
-0
DragonServiceCommonBiz.java
.../liquidnet/service/dragon/biz/DragonServiceCommonBiz.java
+199
-0
AbstractAlipayStrategy.java
.../channel/alipay/strategy/impl/AbstractAlipayStrategy.java
+6
-4
DragonPayBiz.java
...net/service/dragon/channel/strategy/biz/DragonPayBiz.java
+23
-184
AbstractPayChannelStrategyImpl.java
...channel/strategy/impl/AbstractPayChannelStrategyImpl.java
+10
-6
PayChannelStrategyAlipayImpl.java
...n/channel/strategy/impl/PayChannelStrategyAlipayImpl.java
+14
-11
PayChannelStrategyWepayImpl.java
...on/channel/strategy/impl/PayChannelStrategyWepayImpl.java
+10
-11
AbstractWepayStrategy.java
...on/channel/wepay/strategy/impl/AbstractWepayStrategy.java
+5
-1
DragonOrdersServiceImpl.java
.../service/dragon/service/impl/DragonOrdersServiceImpl.java
+7
-2
No files found.
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/dto/DragonPayOrderQueryRespDto.java
View file @
69a2a630
...
@@ -22,4 +22,5 @@ public class DragonPayOrderQueryRespDto {
...
@@ -22,4 +22,5 @@ public class DragonPayOrderQueryRespDto {
private
String
orderCode
;
private
String
orderCode
;
private
BigDecimal
price
;
private
BigDecimal
price
;
private
String
paymentType
;
private
String
paymentType
;
private
String
paymentAt
;
}
}
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/dto/PayNotifyDto.java
View file @
69a2a630
...
@@ -13,4 +13,5 @@ public class PayNotifyDto {
...
@@ -13,4 +13,5 @@ public class PayNotifyDto {
private
String
orderCode
;
private
String
orderCode
;
private
BigDecimal
price
;
private
BigDecimal
price
;
private
String
paymentType
;
private
String
paymentType
;
private
String
paymentAt
;
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/biz/DragonServiceCommonBiz.java
0 → 100644
View file @
69a2a630
package
com
.
liquidnet
.
service
.
dragon
.
biz
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.dragon.bo.PayNotifyReqBo
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
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.PayNotifyDto
;
import
com.liquidnet.service.dragon.entity.DragonOrders
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.MqHandleUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: DragonServiceCommonBiz
* @Package com.liquidnet.service.dragon.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/19 18:06
*/
@Slf4j
@Component
public
class
DragonServiceCommonBiz
{
private
MqHandleUtil
mqHandleUtil
;
@Autowired
private
DataUtils
dataUtils
;
public
DragonOrders
buildPayOrders
(
DragonPayBaseReqDto
dragonPayBaseReqDto
,
DragonPayBaseRespDto
respDto
){
//构造订单
DragonOrders
orders
=
new
DragonOrders
();
// orders.setMid();
orders
.
setOrderId
(
IDGenerator
.
nextTimeId
());
orders
.
setStatus
(
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_UNPAID
.
getCode
()));
orders
.
setCode
(
respDto
.
getCode
());
orders
.
setType
(
dragonPayBaseReqDto
.
getType
());
orders
.
setPrice
(
dragonPayBaseReqDto
.
getPrice
());
orders
.
setName
(
dragonPayBaseReqDto
.
getName
());
orders
.
setDetail
(
dragonPayBaseReqDto
.
getDetail
());
orders
.
setOrderCode
(
dragonPayBaseReqDto
.
getOrderCode
());
orders
.
setClientIp
(
dragonPayBaseReqDto
.
getClientIp
());
orders
.
setNotifyUrl
(
dragonPayBaseReqDto
.
getNotifyUrl
());
orders
.
setNotifyStatus
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_INIT
.
getCode
());
orders
.
setPaymentType
((
dragonPayBaseReqDto
.
getDeviceFrom
()+
dragonPayBaseReqDto
.
getPayType
()).
toUpperCase
());
// orders.setPaymentId();
orders
.
setPaymentAt
(
LocalDateTime
.
now
());
// orders.setFinishedAt();
orders
.
setCreatedAt
(
LocalDateTime
.
now
());
// orders.setUpdatedAt();
DragonOrdersDto
ordersDto
=
new
DragonOrdersDto
();
BeanUtil
.
copy
(
orders
,
ordersDto
);
//放到redis缓存中
dataUtils
.
createPayOrder
(
orders
.
getCode
(),
ordersDto
);
// 持久化到数据库
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_orders.insert"
),
new
Object
[]{
orders
.
getOrderId
(),
orders
.
getStatus
(),
orders
.
getCode
(),
orders
.
getType
()
,
orders
.
getPrice
(),
orders
.
getName
(),
orders
.
getDetail
()
,
orders
.
getOrderCode
(),
orders
.
getClientIp
()
,
orders
.
getNotifyUrl
(),
orders
.
getNotifyStatus
(),
orders
.
getPaymentType
(),
orders
.
getPaymentId
(),
orders
.
getPaymentAt
()
,
orders
.
getFinishedAt
(),
orders
.
getCreatedAt
()
,
orders
.
getUpdatedAt
(),
orders
.
getDeletedAt
()}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
);
return
orders
;
}
/**
* 更新支付状态
* @param code
* @param paymentId
* @return
*/
public
boolean
updateOrderStatus
(
String
code
,
Integer
status
,
String
paymentId
){
try
{
LocalDateTime
finishedAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
//t.status = ? ,t.payment_id = ?,t.finished_at = ?,t.updated_at =? where t.code = ?
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_orders.updateOrderStatus"
),
new
Object
[]{
status
,
paymentId
,
finishedAt
,
updateAt
,
code
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
);
if
(
insertResult
)
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:updateDragonOrderStatus:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
return
false
;
}
/**
* 更新支付通知状态
* @param code
* @return
*/
public
boolean
updateNotifyStatus
(
String
code
,
Integer
status
){
try
{
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
//update dragon_orders t set t.notify_status = ? ,t.updated_at =? where t.code = ?
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_orders.updateNotifyStatus"
),
new
Object
[]{
status
,
updateAt
,
code
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
);
if
(
insertResult
)
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:updateNotifyStatus:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
return
false
;
}
/**
* 三方异步通知入库
* @param paymentType
* @param content
*/
public
void
createDragonOrderLogs
(
String
code
,
String
paymentType
,
String
content
){
try
{
String
orderId
=
IDGenerator
.
nextTimeId
();
LocalDateTime
createAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
null
;
LocalDateTime
deleteAt
=
null
;
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_order_logs.insert"
),
new
Object
[]{
code
,
paymentType
,
content
,
createAt
,
updateAt
,
deleteAt
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_NOTIFY_KEY
.
getCode
()
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:createOrderLog:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
}
/**
* 商户异步通知入库
* @param payNotifyReqBo
* @param notifyParam
*/
public
void
createDragonPayNotify
(
PayNotifyReqBo
payNotifyReqBo
,
String
notifyParam
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
try
{
String
code
=
payNotifyDto
.
getCode
();
String
orderCode
=
payNotifyDto
.
getOrderCode
();
String
notifyUrl
=
payNotifyReqBo
.
getNotifyUrl
();
String
notifyData
=
notifyParam
;
LocalDateTime
createAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_pay_notify.insert"
),
new
Object
[]{
code
,
orderCode
,
notifyUrl
,
notifyData
,
createAt
,
updateAt
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
PAY_MCH_NOTIFY_KEY
.
getCode
()
);
log
.
info
(
"dragon:createDragonPayNotify:success code:{}"
,
code
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:createDragonPayNotify:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
}
/**
* 商户异步通知失败入库
* @param payNotifyReqBo
* @param notifyParam
*/
public
void
createDragonPayNotifyFail
(
PayNotifyReqBo
payNotifyReqBo
,
String
notifyParam
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
try
{
String
code
=
payNotifyDto
.
getCode
();
String
orderCode
=
payNotifyDto
.
getOrderCode
();
String
notifyUrl
=
payNotifyReqBo
.
getNotifyUrl
();
String
notifyData
=
notifyParam
;
String
failDesc
=
"通知失败"
;
LocalDateTime
createAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_pay_notify_fail.insert"
),
new
Object
[]{
code
,
orderCode
,
notifyUrl
,
notifyData
,
failDesc
,
createAt
,
updateAt
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
PAY_MCH_NOTIFY_ERROR_KEY
.
getCode
()
);
log
.
info
(
"dragon:createDragonPayNotifyFail:success code:{}"
,
code
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:createDragonPayNotifyFail:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/strategy/impl/AbstractAlipayStrategy.java
View file @
69a2a630
...
@@ -3,7 +3,7 @@ package com.liquidnet.service.dragon.channel.alipay.strategy.impl;
...
@@ -3,7 +3,7 @@ package com.liquidnet.service.dragon.channel.alipay.strategy.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
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.
channel.alipay.biz.Alipay
Biz
;
import
com.liquidnet.service.dragon.
biz.DragonServiceCommon
Biz
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.IAlipayStrategy
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.IAlipayStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
...
@@ -25,12 +25,14 @@ import java.util.Map;
...
@@ -25,12 +25,14 @@ import java.util.Map;
*/
*/
@Slf4j
@Slf4j
public
abstract
class
AbstractAlipayStrategy
implements
IAlipayStrategy
{
public
abstract
class
AbstractAlipayStrategy
implements
IAlipayStrategy
{
@Autowired
private
AlipayBiz
alipayBiz
;
@Autowired
@Autowired
private
DragonPayBiz
dragonPayBiz
;
private
DragonPayBiz
dragonPayBiz
;
@Autowired
private
DragonServiceCommonBiz
dragonServiceCommonBiz
;
protected
String
productCode
=
"QUICK_WAP_PAY"
;
protected
String
productCode
=
"QUICK_WAP_PAY"
;
@Override
@Override
...
@@ -59,7 +61,7 @@ public abstract class AbstractAlipayStrategy implements IAlipayStrategy {
...
@@ -59,7 +61,7 @@ public abstract class AbstractAlipayStrategy implements IAlipayStrategy {
respDto
=
this
.
buildResponseDto
(
respDto
,
result
);
respDto
=
this
.
buildResponseDto
(
respDto
,
result
);
//支付订单持久化
//支付订单持久化
dragon
Pay
Biz
.
buildPayOrders
(
dragonPayBaseReqDto
,
respDto
);
dragon
ServiceCommon
Biz
.
buildPayOrders
(
dragonPayBaseReqDto
,
respDto
);
return
ResponseDto
.
success
(
respDto
);
return
ResponseDto
.
success
(
respDto
);
}
}
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/biz/DragonPayBiz.java
View file @
69a2a630
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
biz
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
biz
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.commons.lang.util.
Bean
Util
;
import
com.liquidnet.commons.lang.util.
Date
Util
;
import
com.liquidnet.commons.lang.util.
IDGenerator
;
import
com.liquidnet.commons.lang.util.
StringUtil
;
import
com.liquidnet.service.
base.SqlMapping
;
import
com.liquidnet.service.
dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.bo.PayNotifyReqBo
;
import
com.liquidnet.service.dragon.bo.PayNotifyReqBo
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
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.PayNotifyDto
;
import
com.liquidnet.service.dragon.dto.PayNotifyDto
;
import
com.liquidnet.service.dragon.entity.DragonOrders
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.MqHandleUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.config.RequestConfig
;
...
@@ -45,97 +40,8 @@ import java.util.List;
...
@@ -45,97 +40,8 @@ import java.util.List;
@Component
@Component
public
class
DragonPayBiz
{
public
class
DragonPayBiz
{
@Autowired
@Autowired
private
MqHandleUtil
mqHandleUtil
;
private
DragonServiceCommonBiz
dragonServiceCommonBiz
;
@Autowired
private
DataUtils
dataUtils
;
public
DragonOrders
buildPayOrders
(
DragonPayBaseReqDto
dragonPayBaseReqDto
,
DragonPayBaseRespDto
respDto
){
//构造订单
DragonOrders
orders
=
new
DragonOrders
();
// orders.setMid();
orders
.
setOrderId
(
IDGenerator
.
nextTimeId
());
orders
.
setStatus
(
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_UNPAID
.
getCode
()));
orders
.
setCode
(
respDto
.
getCode
());
orders
.
setType
(
dragonPayBaseReqDto
.
getType
());
orders
.
setPrice
(
dragonPayBaseReqDto
.
getPrice
());
orders
.
setName
(
dragonPayBaseReqDto
.
getName
());
orders
.
setDetail
(
dragonPayBaseReqDto
.
getDetail
());
orders
.
setOrderCode
(
dragonPayBaseReqDto
.
getOrderCode
());
orders
.
setClientIp
(
dragonPayBaseReqDto
.
getClientIp
());
orders
.
setNotifyUrl
(
dragonPayBaseReqDto
.
getNotifyUrl
());
orders
.
setNotifyStatus
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_INIT
.
getCode
());
orders
.
setPaymentType
((
dragonPayBaseReqDto
.
getDeviceFrom
()+
dragonPayBaseReqDto
.
getPayType
()).
toUpperCase
());
// orders.setPaymentId();
orders
.
setPaymentAt
(
LocalDateTime
.
now
());
// orders.setFinishedAt();
orders
.
setCreatedAt
(
LocalDateTime
.
now
());
// orders.setUpdatedAt();
DragonOrdersDto
ordersDto
=
new
DragonOrdersDto
();
BeanUtil
.
copy
(
orders
,
ordersDto
);
//放到redis缓存中
dataUtils
.
createPayOrder
(
orders
.
getCode
(),
ordersDto
);
// 持久化到数据库
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_orders.insert"
),
new
Object
[]{
orders
.
getOrderId
(),
orders
.
getStatus
(),
orders
.
getCode
(),
orders
.
getType
()
,
orders
.
getPrice
(),
orders
.
getName
(),
orders
.
getDetail
()
,
orders
.
getOrderCode
(),
orders
.
getClientIp
()
,
orders
.
getNotifyUrl
(),
orders
.
getNotifyStatus
(),
orders
.
getPaymentType
(),
orders
.
getPaymentId
(),
orders
.
getPaymentAt
()
,
orders
.
getFinishedAt
(),
orders
.
getCreatedAt
()
,
orders
.
getUpdatedAt
(),
orders
.
getDeletedAt
()}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
);
return
orders
;
}
/**
* 更新支付状态
* @param code
* @param paymentId
* @return
*/
public
boolean
updateOrderStatus
(
String
code
,
Integer
status
,
String
paymentId
){
try
{
LocalDateTime
finishedAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
//t.status = ? ,t.payment_id = ?,t.finished_at = ?,t.updated_at =? where t.code = ?
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_orders.updateOrderStatus"
),
new
Object
[]{
status
,
paymentId
,
finishedAt
,
updateAt
,
code
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
);
if
(
insertResult
)
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:updateDragonOrderStatus:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
return
false
;
}
/**
* 更新支付通知状态
* @param code
* @return
*/
public
boolean
updateNotifyStatus
(
String
code
,
Integer
status
){
try
{
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
//update dragon_orders t set t.notify_status = ? ,t.updated_at =? where t.code = ?
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_orders.updateNotifyStatus"
),
new
Object
[]{
status
,
updateAt
,
code
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
);
if
(
insertResult
)
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:updateNotifyStatus:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
return
false
;
}
public
PayNotifyReqBo
buildPayNotifyReqBo
(
DragonOrdersDto
dragonOrdersDto
){
public
PayNotifyReqBo
buildPayNotifyReqBo
(
DragonOrdersDto
dragonOrdersDto
){
PayNotifyReqBo
payNotifyReqBo
=
new
PayNotifyReqBo
();
PayNotifyReqBo
payNotifyReqBo
=
new
PayNotifyReqBo
();
...
@@ -148,85 +54,15 @@ public class DragonPayBiz {
...
@@ -148,85 +54,15 @@ public class DragonPayBiz {
payNotifyDto
.
setOrderCode
(
dragonOrdersDto
.
getOrderCode
());
payNotifyDto
.
setOrderCode
(
dragonOrdersDto
.
getOrderCode
());
payNotifyDto
.
setPrice
(
dragonOrdersDto
.
getPrice
());
payNotifyDto
.
setPrice
(
dragonOrdersDto
.
getPrice
());
payNotifyDto
.
setPaymentType
(
dragonOrdersDto
.
getPaymentType
());
payNotifyDto
.
setPaymentType
(
dragonOrdersDto
.
getPaymentType
());
if
(
StringUtil
.
isNotNull
(
dragonOrdersDto
.
getPaymentAt
())){
payNotifyDto
.
setPaymentAt
(
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
dragonOrdersDto
.
getPaymentAt
()));
}
else
{
payNotifyDto
.
setPaymentAt
(
""
);
}
payNotifyReqBo
.
setPayNotifyDto
(
payNotifyDto
);
payNotifyReqBo
.
setPayNotifyDto
(
payNotifyDto
);
return
payNotifyReqBo
;
return
payNotifyReqBo
;
}
}
/**
* 三方异步通知入库
* @param paymentType
* @param content
*/
public
void
createDragonOrderLogs
(
String
code
,
String
paymentType
,
String
content
){
try
{
String
orderId
=
IDGenerator
.
nextTimeId
();
LocalDateTime
createAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
null
;
LocalDateTime
deleteAt
=
null
;
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_order_logs.insert"
),
new
Object
[]{
code
,
paymentType
,
content
,
createAt
,
updateAt
,
deleteAt
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_NOTIFY_KEY
.
getCode
()
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:createOrderLog:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
}
/**
* 商户异步通知入库
* @param payNotifyReqBo
* @param notifyParam
*/
public
void
createDragonPayNotify
(
PayNotifyReqBo
payNotifyReqBo
,
String
notifyParam
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
try
{
String
code
=
payNotifyDto
.
getCode
();
String
orderCode
=
payNotifyDto
.
getOrderCode
();
String
notifyUrl
=
payNotifyReqBo
.
getNotifyUrl
();
String
notifyData
=
notifyParam
;
LocalDateTime
createAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_pay_notify.insert"
),
new
Object
[]{
code
,
orderCode
,
notifyUrl
,
notifyData
,
createAt
,
updateAt
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
PAY_MCH_NOTIFY_KEY
.
getCode
()
);
log
.
info
(
"dragon:createDragonPayNotify:success code:{}"
,
code
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:createDragonPayNotify:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
}
/**
* 商户异步通知失败入库
* @param payNotifyReqBo
* @param notifyParam
*/
public
void
createDragonPayNotifyFail
(
PayNotifyReqBo
payNotifyReqBo
,
String
notifyParam
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
try
{
String
code
=
payNotifyDto
.
getCode
();
String
orderCode
=
payNotifyDto
.
getOrderCode
();
String
notifyUrl
=
payNotifyReqBo
.
getNotifyUrl
();
String
notifyData
=
notifyParam
;
String
failDesc
=
"通知失败"
;
LocalDateTime
createAt
=
LocalDateTime
.
now
();
LocalDateTime
updateAt
=
LocalDateTime
.
now
();
boolean
insertResult
=
mqHandleUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_pay_notify_fail.insert"
),
new
Object
[]{
code
,
orderCode
,
notifyUrl
,
notifyData
,
failDesc
,
createAt
,
updateAt
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
PAY_MCH_NOTIFY_ERROR_KEY
.
getCode
()
);
log
.
info
(
"dragon:createDragonPayNotifyFail:success code:{}"
,
code
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:createDragonPayNotifyFail:error msg:{}"
,
e
);
e
.
printStackTrace
();
}
}
// public void sendNotifyBackup(PayNotifyReqBo payNotifyReqBo){
// public void sendNotifyBackup(PayNotifyReqBo payNotifyReqBo){
// PayNotifyDto payNotifyDto = payNotifyReqBo.getPayNotifyDto();
// PayNotifyDto payNotifyDto = payNotifyReqBo.getPayNotifyDto();
...
@@ -265,7 +101,7 @@ public class DragonPayBiz {
...
@@ -265,7 +101,7 @@ public class DragonPayBiz {
// e.printStackTrace();
// e.printStackTrace();
// }
// }
// }
// }
public
void
sendNotify
(
PayNotifyReqBo
payNotifyReqBo
){
public
boolean
sendNotify
(
PayNotifyReqBo
payNotifyReqBo
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
...
@@ -287,6 +123,7 @@ public class DragonPayBiz {
...
@@ -287,6 +123,7 @@ public class DragonPayBiz {
nvps
.
add
(
new
BasicNameValuePair
(
"orderCode"
,
payNotifyDto
.
getOrderCode
()));
nvps
.
add
(
new
BasicNameValuePair
(
"orderCode"
,
payNotifyDto
.
getOrderCode
()));
nvps
.
add
(
new
BasicNameValuePair
(
"price"
,
payNotifyDto
.
getPrice
().
toString
()));
nvps
.
add
(
new
BasicNameValuePair
(
"price"
,
payNotifyDto
.
getPrice
().
toString
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentType"
,
payNotifyDto
.
getPaymentType
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentType"
,
payNotifyDto
.
getPaymentType
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentAt"
,
payNotifyDto
.
getPaymentAt
()));
jsonData
=
JSON
.
toJSONString
(
nvps
);
jsonData
=
JSON
.
toJSONString
(
nvps
);
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
...
@@ -297,27 +134,29 @@ public class DragonPayBiz {
...
@@ -297,27 +134,29 @@ public class DragonPayBiz {
String
response
=
EntityUtils
.
toString
(
responseObj
.
getEntity
(),
"utf-8"
);
String
response
=
EntityUtils
.
toString
(
responseObj
.
getEntity
(),
"utf-8"
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
if
(
response
.
equals
(
"success"
))
{
if
(
response
.
equals
(
"success"
))
{
this
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知成功
//更新通知状态-通知成功
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_SUCCESS
.
getCode
()));
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_SUCCESS
.
getCode
()));
return
true
;
}
else
{
}
else
{
this
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
//更新通知状态-通知失败
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
return
false
;
}
}
}
catch
(
ConnectTimeoutException
e
)
{
}
catch
(
ConnectTimeoutException
e
)
{
log
.
error
(
"dragon:sendNotify 请求超时"
,
e
);
log
.
error
(
"dragon:sendNotify 请求超时"
,
e
);
this
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
//更新通知状态-通知失败
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_EXPIRE
.
getCode
()));
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_EXPIRE
.
getCode
()));
return
false
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:sendNotify 请求失败"
,
e
);
log
.
error
(
"dragon:sendNotify 请求失败"
,
e
);
this
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
//更新通知状态-通知失败
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
return
false
;
}
finally
{
}
finally
{
//释放连接
//释放连接
try
{
try
{
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/AbstractPayChannelStrategyImpl.java
View file @
69a2a630
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
impl
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
...
@@ -32,6 +33,9 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
...
@@ -32,6 +33,9 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
@Autowired
@Autowired
private
DataUtils
dataUtils
;
private
DataUtils
dataUtils
;
@Autowired
private
DragonServiceCommonBiz
dragonServiceCommonBiz
;
@Override
@Override
public
abstract
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
public
abstract
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
...
@@ -49,7 +53,7 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
...
@@ -49,7 +53,7 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
* @param bankReturnMsg
* @param bankReturnMsg
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
protected
void
completeSuccessOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankTrxNo
,
LocalDateTime
timeEnd
,
String
bankReturnMsg
)
{
protected
boolean
completeSuccessOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankTrxNo
,
LocalDateTime
timeEnd
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付成功!"
);
log
.
info
(
"订单支付成功!"
);
dragonOrdersDto
.
setPaymentAt
(
timeEnd
);
dragonOrdersDto
.
setPaymentAt
(
timeEnd
);
dragonOrdersDto
.
setPaymentId
(
bankTrxNo
);
// 设置银行流水号
dragonOrdersDto
.
setPaymentId
(
bankTrxNo
);
// 设置银行流水号
...
@@ -57,9 +61,9 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
...
@@ -57,9 +61,9 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
//更新缓存
//更新缓存
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
//修改订单状态
//修改订单状态
dragon
Pay
Biz
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
.
getStatus
(),
bankTrxNo
);
dragon
ServiceCommon
Biz
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
.
getStatus
(),
bankTrxNo
);
//通知商户
//通知商户
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
dragonOrdersDto
));
return
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
dragonOrdersDto
));
}
}
/**
/**
...
@@ -67,7 +71,7 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
...
@@ -67,7 +71,7 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
* @param dragonOrdersDto
* @param dragonOrdersDto
* @param bankReturnMsg
* @param bankReturnMsg
*/
*/
protected
void
completeFailOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankReturnMsg
)
{
protected
boolean
completeFailOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付失败!"
);
log
.
info
(
"订单支付失败!"
);
// dragonOrdersDto.setPaymentAt(timeEnd);
// dragonOrdersDto.setPaymentAt(timeEnd);
// dragonOrdersDto.setPaymentId(bankTrxNo);// 设置银行流水号
// dragonOrdersDto.setPaymentId(bankTrxNo);// 设置银行流水号
...
@@ -75,9 +79,9 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
...
@@ -75,9 +79,9 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
//更新缓存
//更新缓存
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
//修改订单状态
//修改订单状态
dragon
Pay
Biz
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
.
getStatus
(),
null
);
dragon
ServiceCommon
Biz
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
.
getStatus
(),
null
);
//通知商户
//通知商户
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
dragonOrdersDto
));
return
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
dragonOrdersDto
));
}
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/PayChannelStrategyAlipayImpl.java
View file @
69a2a630
...
@@ -7,6 +7,7 @@ import com.liquidnet.common.exception.LiquidnetServiceException;
...
@@ -7,6 +7,7 @@ import com.liquidnet.common.exception.LiquidnetServiceException;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.channel.alipay.biz.AlipayBiz
;
import
com.liquidnet.service.dragon.channel.alipay.biz.AlipayBiz
;
import
com.liquidnet.service.dragon.channel.alipay.constant.AlipayConstant
;
import
com.liquidnet.service.dragon.channel.alipay.constant.AlipayConstant
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.AlipayStrategyContext
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.AlipayStrategyContext
;
...
@@ -20,7 +21,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
...
@@ -20,7 +21,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.service.impl.DragonOrderRefundsServiceImpl
;
import
com.liquidnet.service.dragon.service.impl.DragonOrderRefundsServiceImpl
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.MqHandleUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -57,7 +57,7 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
...
@@ -57,7 +57,7 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
private
DragonPayBiz
dragonPayBiz
;
private
DragonPayBiz
dragonPayBiz
;
@Autowired
@Autowired
private
MqHandleUtil
mqHandleUtil
;
private
DragonServiceCommonBiz
dragonServiceCommonBiz
;
@Autowired
@Autowired
private
DragonOrderRefundsServiceImpl
dragonOrderRefundsService
;
private
DragonOrderRefundsServiceImpl
dragonOrderRefundsService
;
...
@@ -88,11 +88,11 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
...
@@ -88,11 +88,11 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
log
.
info
(
"接收到{}支付结果{}"
,
payType
,
notifyMap
);
log
.
info
(
"接收到{}支付结果{}"
,
payType
,
notifyMap
);
String
returnStr
=
null
;
String
returnStr
=
"fail"
;
String
code
=
notifyMap
.
get
(
"out_trade_no"
);
String
code
=
notifyMap
.
get
(
"out_trade_no"
);
//持久化通知记录
//持久化通知记录
dragon
Pay
Biz
.
createDragonOrderLogs
(
code
,
dragonPayBiz
.
getPaymentType
(
payType
,
deviceFrom
),
JSON
.
toJSONString
(
notifyMap
));
dragon
ServiceCommon
Biz
.
createDragonOrderLogs
(
code
,
dragonPayBiz
.
getPaymentType
(
payType
,
deviceFrom
),
JSON
.
toJSONString
(
notifyMap
));
//退款
//退款
if
(
notifyMap
.
containsKey
(
"refund_fee"
)
||
notifyMap
.
containsKey
(
"gmt_refund"
)
||
notifyMap
.
containsKey
(
"out_biz_no"
))
{
if
(
notifyMap
.
containsKey
(
"refund_fee"
)
||
notifyMap
.
containsKey
(
"gmt_refund"
)
||
notifyMap
.
containsKey
(
"out_biz_no"
))
{
...
@@ -112,6 +112,7 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
...
@@ -112,6 +112,7 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
try
{
try
{
if
(
AlipaySignature
.
rsaCheckV1
(
notifyMap
,
merchantPubKey
,
"UTF-8"
,
"RSA2"
)){
if
(
AlipaySignature
.
rsaCheckV1
(
notifyMap
,
merchantPubKey
,
"UTF-8"
,
"RSA2"
)){
String
tradeStatus
=
notifyMap
.
get
(
"trade_status"
);
String
tradeStatus
=
notifyMap
.
get
(
"trade_status"
);
boolean
notifyResult
=
false
;
if
(
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_SUCCESS
.
name
().
equals
(
tradeStatus
)
if
(
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_SUCCESS
.
name
().
equals
(
tradeStatus
)
||
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_FINISHED
.
name
().
equals
(
tradeStatus
))
{
||
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_FINISHED
.
name
().
equals
(
tradeStatus
))
{
...
@@ -121,18 +122,20 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
...
@@ -121,18 +122,20 @@ public class PayChannelStrategyAlipayImpl extends AbstractPayChannelStrategyImpl
if
(!
StringUtil
.
isEmpty
(
gmtPaymentStr
))
{
if
(!
StringUtil
.
isEmpty
(
gmtPaymentStr
))
{
timeEnd
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
parse
(
gmtPaymentStr
);
timeEnd
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
parse
(
gmtPaymentStr
);
}
}
this
.
completeSuccessOrder
(
dragonOrdersDto
,
notifyMap
.
get
(
"trade_no"
),
timeEnd
,
notifyMap
.
toString
());
notifyResult
=
this
.
completeSuccessOrder
(
dragonOrdersDto
,
notifyMap
.
get
(
"trade_no"
),
timeEnd
,
notifyMap
.
toString
());
returnStr
=
"success"
;
}
else
{
}
else
{
this
.
completeFailOrder
(
dragonOrdersDto
,
notifyMap
.
toString
());
notifyResult
=
this
.
completeFailOrder
(
dragonOrdersDto
,
notifyMap
.
toString
());
returnStr
=
"fail"
;
}
if
(
notifyResult
){
returnStr
=
"success"
;
}
}
}
else
{
// 验证失败
}
else
{
// 验证失败
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getMessage
());
log
.
error
(
"alipay notify fail code:{} msg:{} "
,
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getMessage
());
return
returnStr
;
}
}
}
catch
(
AlipayApiException
e
)
{
}
catch
(
AlipayApiException
e
)
{
log
.
error
(
"
验签失败:
"
,
e
);
log
.
error
(
"
alipay notify fail 验签失败:e:{}
"
,
e
);
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getMessage
());
log
.
error
(
"alipay notify fail 验签失败:code:{} msg:{}"
,
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getMessage
());
}
}
log
.
info
(
"返回支付通道{}信息{}"
,
payType
,
returnStr
);
log
.
info
(
"返回支付通道{}信息{}"
,
payType
,
returnStr
);
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/PayChannelStrategyWepayImpl.java
View file @
69a2a630
...
@@ -5,9 +5,9 @@ import com.liquidnet.common.exception.LiquidnetServiceException;
...
@@ -5,9 +5,9 @@ import com.liquidnet.common.exception.LiquidnetServiceException;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
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.wepay.biz.WepayBiz
;
import
com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant
;
import
com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant
;
import
com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext
;
import
com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
...
@@ -17,7 +17,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
...
@@ -17,7 +17,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.MqHandleUtil
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -50,10 +49,7 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
...
@@ -50,10 +49,7 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
private
DataUtils
dataUtils
;
private
DataUtils
dataUtils
;
@Autowired
@Autowired
private
MqHandleUtil
mqHandleUtil
;
private
DragonServiceCommonBiz
dragonServiceCommonBiz
;
@Autowired
private
WepayBiz
wepayBiz
;
@Autowired
@Autowired
private
DragonPayBiz
dragonPayBiz
;
private
DragonPayBiz
dragonPayBiz
;
...
@@ -78,7 +74,7 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
...
@@ -78,7 +74,7 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
String
code
=
notifyMap
.
get
(
"out_trade_no"
);
String
code
=
notifyMap
.
get
(
"out_trade_no"
);
//持久化通知记录
//持久化通知记录
dragon
Pay
Biz
.
createDragonOrderLogs
(
code
,
dragonPayBiz
.
getPaymentType
(
payType
,
deviceFrom
),
JSON
.
toJSONString
(
notifyMap
));
dragon
ServiceCommon
Biz
.
createDragonOrderLogs
(
code
,
dragonPayBiz
.
getPaymentType
(
payType
,
deviceFrom
),
JSON
.
toJSONString
(
notifyMap
));
// 根据银行订单号获取支付信息
// 根据银行订单号获取支付信息
DragonOrdersDto
dragonOrdersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
DragonOrdersDto
dragonOrdersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
...
@@ -91,6 +87,7 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
...
@@ -91,6 +87,7 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
}
}
String
sign
=
notifyMap
.
remove
(
"sign"
);
String
sign
=
notifyMap
.
remove
(
"sign"
);
boolean
notifyResult
=
false
;
if
(
PayWepayUtils
.
getInstance
().
notifySign
(
notifyMap
,
sign
))
{
// 根据配置信息验证签名
if
(
PayWepayUtils
.
getInstance
().
notifySign
(
notifyMap
,
sign
))
{
// 根据配置信息验证签名
if
(
WepayConstant
.
WeixinTradeStateEnum
.
SUCCESS
.
getCode
().
equals
(
notifyMap
.
get
(
"result_code"
)))
{
// 业务结果
if
(
WepayConstant
.
WeixinTradeStateEnum
.
SUCCESS
.
getCode
().
equals
(
notifyMap
.
get
(
"result_code"
)))
{
// 业务结果
// 成功
// 成功
...
@@ -99,13 +96,15 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
...
@@ -99,13 +96,15 @@ public class PayChannelStrategyWepayImpl extends AbstractPayChannelStrategyImpl
if
(!
StringUtil
.
isEmpty
(
timeEndStr
))
{
if
(!
StringUtil
.
isEmpty
(
timeEndStr
))
{
timeEnd
=
DateUtil
.
Formatter
.
yyyyMMddHHmmssTrim
.
parse
(
timeEndStr
);
timeEnd
=
DateUtil
.
Formatter
.
yyyyMMddHHmmssTrim
.
parse
(
timeEndStr
);
}
}
this
.
completeSuccessOrder
(
dragonOrdersDto
,
notifyMap
.
get
(
"transaction_id"
),
timeEnd
,
notifyMap
.
toString
());
notifyResult
=
this
.
completeSuccessOrder
(
dragonOrdersDto
,
notifyMap
.
get
(
"transaction_id"
),
timeEnd
,
notifyMap
.
toString
());
returnStr
=
"<xml>\n"
+
" <return_code><![CDATA[SUCCESS]]></return_code>\n"
+
" <return_msg><![CDATA[OK]]></return_msg>\n"
+
"</xml>"
;
}
else
{
}
else
{
this
.
completeFailOrder
(
dragonOrdersDto
,
notifyMap
.
toString
());
notifyResult
=
this
.
completeFailOrder
(
dragonOrdersDto
,
notifyMap
.
toString
());
}
if
(
notifyResult
){
returnStr
=
"<xml>\n"
+
" <return_code><![CDATA[SUCCESS]]></return_code>\n"
+
" <return_msg><![CDATA[OK]]></return_msg>\n"
+
"</xml>"
;
}
}
}
else
{
}
else
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_WEPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_WEPAY_SIGN_ERROR
.
getMessage
());
log
.
error
(
"wepay notify fail code:{} msg:{} "
,
DragonErrorCodeEnum
.
TRADE_WEPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_WEPAY_SIGN_ERROR
.
getMessage
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/impl/AbstractWepayStrategy.java
View file @
69a2a630
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.channel.wepay.strategy.impl;
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.channel.wepay.strategy.impl;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
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.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.wepay.biz.WepayBiz
;
import
com.liquidnet.service.dragon.channel.wepay.biz.WepayBiz
;
import
com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant
;
import
com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant
;
...
@@ -46,6 +47,9 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
...
@@ -46,6 +47,9 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
@Autowired
@Autowired
private
DragonPayBiz
dragonPayBiz
;
private
DragonPayBiz
dragonPayBiz
;
@Autowired
private
DragonServiceCommonBiz
dragonServiceCommonBiz
;
@Override
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
...
@@ -78,7 +82,7 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
...
@@ -78,7 +82,7 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
this
.
buildResponseDto
(
respPayDto
,
respWepayDto
);
this
.
buildResponseDto
(
respPayDto
,
respWepayDto
);
//支付订单持久化
//支付订单持久化
dragon
Pay
Biz
.
buildPayOrders
(
dragonPayBaseReqDto
,
respPayDto
);
dragon
ServiceCommon
Biz
.
buildPayOrders
(
dragonPayBaseReqDto
,
respPayDto
);
return
ResponseDto
.
success
(
respPayDto
);
return
ResponseDto
.
success
(
respPayDto
);
}
else
{
}
else
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_PARAM_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_PARAM_ERROR
.
getMessage
());
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_PARAM_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_PARAM_ERROR
.
getMessage
());
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrdersServiceImpl.java
View file @
69a2a630
package
com
.
liquidnet
.
service
.
dragon
.
service
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
service
.
impl
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
...
@@ -65,6 +66,11 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
...
@@ -65,6 +66,11 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
queryRespDto
.
setOrderCode
(
ordersDto
.
getOrderCode
());
queryRespDto
.
setOrderCode
(
ordersDto
.
getOrderCode
());
queryRespDto
.
setPrice
(
ordersDto
.
getPrice
());
queryRespDto
.
setPrice
(
ordersDto
.
getPrice
());
queryRespDto
.
setPaymentType
(
ordersDto
.
getPaymentType
());
queryRespDto
.
setPaymentType
(
ordersDto
.
getPaymentType
());
if
(
StringUtil
.
isNotNull
(
ordersDto
.
getPaymentAt
())){
queryRespDto
.
setPaymentAt
(
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
ordersDto
.
getPaymentAt
()));
}
else
{
queryRespDto
.
setPaymentAt
(
""
);
}
return
queryRespDto
;
return
queryRespDto
;
}
}
//如果未支付进行三方查询
//如果未支付进行三方查询
...
@@ -79,7 +85,6 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
...
@@ -79,7 +85,6 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
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
());
}
}
//通知商户
//通知商户
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
ordersDto
));
return
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
ordersDto
));
return
false
;
}
}
}
}
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