Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8be5f23c
authored
Oct 29, 2025
by
Jony.L
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新支付功能测试7.0 完成回调接口的开发,api模块支付待重构
parent
48277ba8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
88 deletions
+24
-88
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/admin/notify/ComputeWpgjPayController.java
+1
-75
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/resourceorder/ResourceOrderServiceImpl.java
+23
-13
No files found.
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/controller/admin/notify/ComputeWpgjPayController.java
View file @
8be5f23c
...
@@ -45,42 +45,6 @@ public class ComputeWpgjPayController {
...
@@ -45,42 +45,6 @@ public class ComputeWpgjPayController {
@Resource
@Resource
private
WpgjPayProperties
wpgjPayProperties
;
private
WpgjPayProperties
wpgjPayProperties
;
@PostMapping
(
"/notify"
)
@PermitAll
@Operation
(
summary
=
"WPGJ支付异步回调通知 - 算力资源模块"
)
public
CommonResult
<
WpgjPayNotifyRespDTO
>
notifyWpgjPay
(
@RequestBody
WpgjPayNotifyDTO
notifyDTO
)
{
WpgjPayNotifyRespDTO
response
=
new
WpgjPayNotifyRespDTO
();
try
{
log
.
info
(
"[notifyWpgjPay][Compute] 收到WPGJ支付回调: {}"
,
JsonUtils
.
toJsonString
(
notifyDTO
));
// 1. 验证签名
if
(!
verifyWpgjSignature
(
notifyDTO
))
{
log
.
error
(
"[notifyWpgjPay][Compute] WPGJ回调签名验证失败"
);
response
.
setCode
(
"99"
);
response
.
setMsg
(
"签名验证失败"
);
response
.
setTimestamp
(
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmssSSS"
)));
return
CommonResult
.
success
(
response
);
}
// 2. 处理支付结果通知
handleWpgjPaymentResult
(
notifyDTO
);
log
.
info
(
"[notifyWpgjPay][Compute] WPGJ支付回调处理完成"
);
response
.
setCode
(
"00"
);
response
.
setMsg
(
"成功"
);
response
.
setTimestamp
(
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmssSSS"
)));
return
CommonResult
.
success
(
response
);
}
catch
(
Exception
e
)
{
log
.
error
(
"[notifyWpgjPay][Compute] WPGJ支付回调处理失败"
,
e
);
response
.
setCode
(
"99"
);
response
.
setMsg
(
"处理失败"
);
response
.
setTimestamp
(
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmssSSS"
)));
return
CommonResult
.
success
(
response
);
}
}
@PostMapping
(
"/new-notify"
)
@PostMapping
(
"/new-notify"
)
@PermitAll
@PermitAll
@Operation
(
summary
=
"WPGJ支付异步回调通知(新) - 按文档通用验签"
)
@Operation
(
summary
=
"WPGJ支付异步回调通知(新) - 按文档通用验签"
)
...
@@ -106,7 +70,7 @@ public class ComputeWpgjPayController {
...
@@ -106,7 +70,7 @@ public class ComputeWpgjPayController {
// 2. 幂等处理:根据订单状态更新(与老接口保持一致逻辑)
// 2. 幂等处理:根据订单状态更新(与老接口保持一致逻辑)
if
(
WpgjOrderStatusEnum
.
isSuccess
(
orderStatus
))
{
if
(
WpgjOrderStatusEnum
.
isSuccess
(
orderStatus
))
{
resourceOrderService
.
updateOrderPaidByWpgj
(
Long
.
parseLong
(
merOrderId
),
notifyDTO
);
resourceOrderService
.
updateOrderPaidByWpgj
(
Long
.
parseLong
(
merOrderId
),
notifyDTO
);
log
.
info
(
"[notifyWpgjPayNew] 支付成功处理完成,商户订单号: {}"
,
merOrderId
);
log
.
info
(
"[notifyWpgjPayNew] 支付成功处理完成,商户订单号: {}"
,
merOrderId
);
}
else
if
(
WpgjOrderStatusEnum
.
isFailedOrClosed
(
orderStatus
))
{
}
else
if
(
WpgjOrderStatusEnum
.
isFailedOrClosed
(
orderStatus
))
{
resourceOrderService
.
updateOrderFailedByWpgj
(
Long
.
parseLong
(
merOrderId
),
notifyDTO
);
resourceOrderService
.
updateOrderFailedByWpgj
(
Long
.
parseLong
(
merOrderId
),
notifyDTO
);
...
@@ -198,42 +162,4 @@ public class ComputeWpgjPayController {
...
@@ -198,42 +162,4 @@ public class ComputeWpgjPayController {
map
.
put
(
"sign"
,
dto
.
getSign
());
map
.
put
(
"sign"
,
dto
.
getSign
());
return
map
;
return
map
;
}
}
/**
* 处理WPGJ支付结果
*/
private
void
handleWpgjPaymentResult
(
WpgjPayNotifyDTO
notifyDTO
)
{
try
{
String
merOrderId
=
notifyDTO
.
getMerOrderId
();
String
orderStatus
=
notifyDTO
.
getOrderStatus
();
log
.
info
(
"[handleWpgjPaymentResult] 处理WPGJ支付结果,商户订单号: {}, 订单状态: {}"
,
merOrderId
,
orderStatus
);
// 根据WPGJ订单状态更新算力资源订单
if
(
WpgjOrderStatusEnum
.
isSuccess
(
orderStatus
))
{
// 支付成功
resourceOrderService
.
updateOrderPaidByWpgj
(
Long
.
parseLong
(
merOrderId
),
notifyDTO
);
log
.
info
(
"[handleWpgjPaymentResult] 算力资源订单支付成功处理完成,商户订单号: {}"
,
merOrderId
);
}
else
if
(
WpgjOrderStatusEnum
.
isFailedOrClosed
(
orderStatus
))
{
// 支付失败或关闭
resourceOrderService
.
updateOrderFailedByWpgj
(
Long
.
parseLong
(
merOrderId
),
notifyDTO
);
log
.
info
(
"[handleWpgjPaymentResult] 算力资源订单支付失败处理完成,商户订单号: {}"
,
merOrderId
);
}
else
{
// 其他状态(处理中等),暂不处理
log
.
info
(
"[handleWpgjPaymentResult] WPGJ订单状态无需处理,商户订单号: {}, 状态: {}"
,
merOrderId
,
orderStatus
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"[handleWpgjPaymentResult] 处理WPGJ支付结果异常"
,
e
);
throw
e
;
}
}
/**
* 验证WPGJ回调签名
*/
private
boolean
verifyWpgjSignature
(
WpgjPayNotifyDTO
notifyDTO
)
{
// 复用 Map 验签,确保与文档一致(ASCII 排序 + key)
return
verifyWpgjSignature
(
toPayloadMap
(
notifyDTO
));
}
}
}
computility-module-compute/computility-module-compute-biz/src/main/java/com/luhu/computility/module/compute/service/resourceorder/ResourceOrderServiceImpl.java
View file @
8be5f23c
...
@@ -24,14 +24,17 @@ import com.luhu.computility.module.compute.service.resourcesku.ResourceSkuServic
...
@@ -24,14 +24,17 @@ import com.luhu.computility.module.compute.service.resourcesku.ResourceSkuServic
import
com.luhu.computility.module.compute.service.resourcespu.ResourceSpuService
;
import
com.luhu.computility.module.compute.service.resourcespu.ResourceSpuService
;
import
com.luhu.computility.module.pay.api.order.PayOrderApi
;
import
com.luhu.computility.module.pay.api.order.PayOrderApi
;
import
com.luhu.computility.module.pay.api.order.dto.PayOrderCreateReqDTO
;
import
com.luhu.computility.module.pay.api.order.dto.PayOrderCreateReqDTO
;
import
com.luhu.computility.module.pay.api.order.dto.PayOrderRespDTO
;
import
com.luhu.computility.module.pay.api.wpgj.PayOrderWpgjApi
;
import
com.luhu.computility.module.pay.api.wpgj.PayOrderWpgjApi
;
import
com.luhu.computility.module.pay.api.wpgj.dto.PayOrderWpgjCreateReqDTO
;
import
com.luhu.computility.module.pay.api.wpgj.dto.PayOrderWpgjCreateReqDTO
;
import
com.luhu.computility.module.pay.api.order.dto.PayOrderRespDTO
;
import
com.luhu.computility.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO
;
import
com.luhu.computility.module.pay.api.wpgj.vo.WpgjPayOrderSubmitReqVO
;
import
com.luhu.computility.module.pay.api.wpgj.vo.WpgjPayOrderSubmitReqVO
;
import
com.luhu.computility.module.pay.controller.admin.notify.vo.WpgjPayNotifyDTO
;
import
com.luhu.computility.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO
;
import
com.luhu.computility.module.pay.dal.dataobject.wpgj.PayOrderWpgjDO
;
import
com.luhu.computility.module.pay.dal.mysql.wpgj.PayOrderWpgjMapper
;
import
com.luhu.computility.module.pay.enums.WpgjOrderStatusEnum
;
import
com.luhu.computility.module.pay.enums.order.PayOrderStatusEnum
;
import
com.luhu.computility.module.pay.enums.order.PayOrderStatusEnum
;
import
com.luhu.computility.module.pay.framework.pay.core.client.impl.wpgj.WpgjPayProperties
;
import
com.luhu.computility.module.pay.framework.pay.core.client.impl.wpgj.WpgjPayProperties
;
import
com.luhu.computility.module.pay.controller.admin.notify.vo.WpgjPayNotifyDTO
;
import
com.luhu.computility.module.pay.service.order.PayOrderService
;
import
com.luhu.computility.module.pay.service.order.PayOrderService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -65,6 +68,9 @@ import static com.luhu.computility.module.compute.enums.ResourceOrderRefundStatu
...
@@ -65,6 +68,9 @@ import static com.luhu.computility.module.compute.enums.ResourceOrderRefundStatu
public
class
ResourceOrderServiceImpl
implements
ResourceOrderService
{
public
class
ResourceOrderServiceImpl
implements
ResourceOrderService
{
@Resource
@Resource
private
PayOrderWpgjMapper
payOrderWpgjMapper
;
@Resource
private
ResourceOrderMapper
resourceOrderMapper
;
private
ResourceOrderMapper
resourceOrderMapper
;
@Resource
@Resource
...
@@ -83,9 +89,6 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -83,9 +89,6 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
private
PayOrderWpgjApi
payOrderWpgjApi
;
private
PayOrderWpgjApi
payOrderWpgjApi
;
@Resource
@Resource
private
PayOrderService
payOrderService
;
@Resource
private
ResourceOrderProperties
resourceOrderProperties
;
private
ResourceOrderProperties
resourceOrderProperties
;
@Resource
@Resource
...
@@ -561,13 +564,20 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
...
@@ -561,13 +564,20 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
orderId
,
wpgjOrderAmt
,
resourceOrderAmt
);
orderId
,
wpgjOrderAmt
,
resourceOrderAmt
);
// 4. 更新算力资源订单状态为已支付
// 4. 更新算力资源订单状态为已支付
ResourceOrderDO
updateOrder
=
new
ResourceOrderDO
();
ResourceOrderDO
updateResourceOrder
=
new
ResourceOrderDO
();
updateOrder
.
setId
(
orderId
);
updateResourceOrder
.
setId
(
orderId
);
updateOrder
.
setStatus
(
ResourceOrderStatus
.
PAID
.
getValue
());
updateResourceOrder
.
setStatus
(
ResourceOrderStatus
.
PAID
.
getValue
());
updateOrder
.
setPayTime
(
LocalDateTime
.
now
());
updateResourceOrder
.
setPayTime
(
LocalDateTime
.
now
());
resourceOrderMapper
.
updateById
(
updateOrder
);
//更新支付订单状态为已支付
PayOrderWpgjDO
updatePayOrder
=
new
PayOrderWpgjDO
();
updatePayOrder
.
setId
(
order
.
getPayOrderId
());
updatePayOrder
.
setOrderId
(
notifyDTO
.
getOrderId
());
updatePayOrder
.
setOrderStatus
(
WpgjOrderStatusEnum
.
SUCCESS
.
getStatus
());
updatePayOrder
.
setTradeTime
(
notifyDTO
.
getTradeTime
());
resourceOrderMapper
.
updateById
(
updateResourceOrder
);
payOrderWpgjMapper
.
updateById
(
updatePayOrder
);
log
.
info
(
"[updateOrderPaidByWpgj] WPGJ支付成功回调处理完成,订单ID: {}, WPGJ订单号: {}"
,
log
.
info
(
"[updateOrderPaidByWpgj] WPGJ支付成功回调处理完成,订单ID: {}, WPGJ订单号: {}"
,
orderId
,
notifyDTO
.
getOrderId
());
orderId
,
notifyDTO
.
getOrderId
());
...
...
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