From 22d1dd5bf30b76e95a7de8f39223680ce48b6012 Mon Sep 17 00:00:00 2001 From: bootx Date: Mon, 15 Apr 2024 23:11:48 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=88=86=E8=B4=A6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _doc/Task.md | 5 +++-- .../allocation/AllocationOrderController.java | 10 ++++++++++ .../alipay/service/AliPayAllocationService.java | 10 ++++++++-- .../wechat/service/WeChatPayAllocationService.java | 2 ++ .../order/allocation/entity/AllocationOrderDetail.java | 8 ++++++++ .../payment/allocation/service/AllocationService.java | 8 +++++++- 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/_doc/Task.md b/_doc/Task.md index dd85931bf..f515fcd74 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -8,12 +8,13 @@ - [x] 管理 - [x] 绑定 - [x] 默认分账组 -- [ ] 分账订单管理 +- [x] 分账订单管理 - [x] 订单创建 - [x] 发起分账 - - [ ] 分账完结 + - [x] 分账完结 - [x] 分账处理 - [x] 发起分账 + - [ ] 分账同步 - [x] 修复创建支付订单报错时, 订单保存数据不完整 2.0.6: 分账完善和去除组合支付 diff --git a/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/admin/controller/allocation/AllocationOrderController.java b/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/admin/controller/allocation/AllocationOrderController.java index 77173adbf..07b8d6c11 100644 --- a/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/admin/controller/allocation/AllocationOrderController.java +++ b/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/admin/controller/allocation/AllocationOrderController.java @@ -7,6 +7,7 @@ import cn.bootx.platform.common.core.rest.dto.LabelValue; import cn.bootx.platform.common.core.rest.param.PageParam; import cn.bootx.platform.daxpay.param.pay.AllocationSyncParam; import cn.bootx.platform.daxpay.param.pay.allocation.AllocationFinishParam; +import cn.bootx.platform.daxpay.param.pay.allocation.AllocationResetParam; import cn.bootx.platform.daxpay.service.core.order.allocation.service.AllocationOrderService; import cn.bootx.platform.daxpay.service.core.payment.allocation.service.AllocationService; import cn.bootx.platform.daxpay.service.core.payment.allocation.service.AllocationSyncService; @@ -87,4 +88,13 @@ public class AllocationOrderController { allocationService.finish(param); return Res.ok(); } + + @Operation(summary = "分账重试") + @PostMapping("/retry") + public ResResult retryAllocation(Long id){ + AllocationResetParam param = new AllocationResetParam(); + param.setOrderId(id); + allocationService.retryAllocation(param); + return Res.ok(); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayAllocationService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayAllocationService.java index b8e4e8892..bb6f06526 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayAllocationService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayAllocationService.java @@ -85,7 +85,6 @@ public class AliPayAllocationService { }) .collect(Collectors.toList()); model.setRoyaltyParameters(royaltyParameters); - AlipayTradeOrderSettleResponse response = AliPayApi.tradeOrderSettleToResponse(model); this.verifyErrorMsg(response); } @@ -104,7 +103,14 @@ public class AliPayAllocationService { // 验证 this.verifyErrorMsg(response); List royaltyDetailList = response.getRoyaltyDetailList(); - System.out.println(royaltyDetailList); + + // 转换成通用的明细详情 + for (RoyaltyDetail royaltyDetail : royaltyDetailList) { + System.out.println(royaltyDetail); + System.out.println(royaltyDetail.getState()); + System.out.println(royaltyDetail.getDetailId()); + + } } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WeChatPayAllocationService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WeChatPayAllocationService.java index d95fd355c..9b9ffc01b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WeChatPayAllocationService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/wechat/service/WeChatPayAllocationService.java @@ -8,6 +8,7 @@ import cn.bootx.platform.daxpay.service.core.order.allocation.entity.AllocationO import cn.bootx.platform.daxpay.service.core.order.allocation.entity.AllocationOrderDetail; import cn.hutool.core.codec.Base64; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.ijpay.core.enums.SignType; import com.ijpay.core.kit.WxPayKit; @@ -107,6 +108,7 @@ public class WeChatPayAllocationService { String xmlResult = WxPayApi.profitSharingQuery(params); Map result = WxPayKit.xmlToMap(xmlResult); this.verifyErrorMsg(result); + JSONUtil.parse(result.get("receivers")); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/allocation/entity/AllocationOrderDetail.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/allocation/entity/AllocationOrderDetail.java index aa48abc94..be85545d4 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/allocation/entity/AllocationOrderDetail.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/order/allocation/entity/AllocationOrderDetail.java @@ -61,6 +61,14 @@ public class AllocationOrderDetail extends MpBaseEntity implements EntityBaseFun @DbColumn(comment = "状态") private String status; + /** 错误代码 */ + @DbColumn(comment = "错误代码") + private String errorCode; + + /** 错误原因 */ + @DbColumn(comment = "错误原因") + private String errorMsg; + /** * 转换 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationService.java index 7f6a8e72c..89b8db978 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationService.java @@ -7,6 +7,7 @@ import cn.bootx.platform.daxpay.param.pay.allocation.AllocationFinishParam; import cn.bootx.platform.daxpay.param.pay.allocation.AllocationResetParam; import cn.bootx.platform.daxpay.param.pay.allocation.AllocationStartParam; import cn.bootx.platform.daxpay.result.allocation.AllocationResult; +import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal; import cn.bootx.platform.daxpay.service.core.order.allocation.dao.AllocationOrderDetailManager; import cn.bootx.platform.daxpay.service.core.order.allocation.dao.AllocationOrderManager; import cn.bootx.platform.daxpay.service.core.order.allocation.entity.AllocationOrder; @@ -96,6 +97,11 @@ public class AllocationService { order.setStatus(AllocationStatusEnum.PARTIAL_FAILED.getCode()) .setErrorMsg(e.getMessage()); } + // 网关分账号 + String gatewayNo = PaymentContextLocal.get() + .getAllocationInfo() + .getGatewayNo(); + order.setGatewayAllocationNo(gatewayNo); allocationOrderManager.updateById(order); return new AllocationResult().setOrderId(order.getId()) @@ -106,7 +112,7 @@ public class AllocationService { /** * 重新分账 */ - public void resetAllocation(AllocationResetParam param){ + public void retryAllocation(AllocationResetParam param){ AllocationOrder allocationOrder; if (Objects.nonNull(param.getOrderId())){ allocationOrder = allocationOrderManager.findById(param.getOrderId())