From bd11adee3628da2bae62bdb9f6eb02b81697f1a7 Mon Sep 17 00:00:00 2001 From: DaxPay Date: Wed, 19 Jun 2024 20:29:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=89=8B=E5=8A=A8=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E5=88=86=E8=B4=A6=E9=87=8D=E8=AF=95=E5=8F=82=E6=95=B0=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _doc/Task.md | 4 ++-- .../order/AllocationOrderController.java | 5 +---- .../service/AllocationAssistService.java | 1 - .../allocation/service/AllocationService.java | 21 ++++++++++++++++++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/_doc/Task.md b/_doc/Task.md index a3bff487a..1bda7adb6 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -5,8 +5,8 @@ - [ ] 转账订单功能 - [ ] DEMO增加转账演示功能 - [ ] 转账同步接口 -- [ ] 手动发起分账是参数修正 -- [ ] 细分各种支付异常类和编码(部分) +- [x] 手动发起分账重试参数修正 +- [x] 细分各种支付异常类和编码(部分+初版) - [x] 支付宝支持JSAPI方式支付 - [x] 支付宝SDK修改为官方SDK - [x] 增加扫码获取微信OpenID和支付宝OpenId功能 diff --git a/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/order/AllocationOrderController.java b/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/order/AllocationOrderController.java index 35336ff13..c1b30ccd1 100644 --- a/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/order/AllocationOrderController.java +++ b/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/order/AllocationOrderController.java @@ -8,7 +8,6 @@ import cn.bootx.platform.common.core.rest.param.PageParam; import cn.daxpay.single.core.code.PaymentApiCode; import cn.daxpay.single.core.param.payment.allocation.AllocFinishParam; import cn.daxpay.single.core.param.payment.allocation.AllocSyncParam; -import cn.daxpay.single.core.param.payment.allocation.AllocationParam; import cn.daxpay.single.service.annotation.InitPaymentContext; import cn.daxpay.single.service.core.order.allocation.service.AllocOrderQueryService; import cn.daxpay.single.service.core.payment.allocation.service.AllocationService; @@ -103,9 +102,7 @@ public class AllocationOrderController { @Operation(summary = "重新发起分账") @PostMapping("/retry") public ResResult retryAllocation(String bizAllocNo){ - AllocationParam param = new AllocationParam(); - param.setBizAllocNo(bizAllocNo); - allocationService.allocation(param); + allocationService.retry(bizAllocNo); return Res.ok(); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationAssistService.java index 0db3956a7..f92583a19 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationAssistService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationAssistService.java @@ -30,7 +30,6 @@ public class AllocationAssistService { orderExtra.setClientIp(allocationParam.getClientIp()) .setNotifyUrl(allocationParam.getNotifyUrl()) .setAttach(allocationParam.getAttach()) - .setClientIp(allocationParam.getClientIp()) .setReqTime(allocationParam.getReqTime()); allocationOrderManager.updateById(orderExtra); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java index 1c03f316c..2a4035b2b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/allocation/service/AllocationService.java @@ -3,6 +3,7 @@ package cn.daxpay.single.service.core.payment.allocation.service; import cn.bootx.platform.common.core.exception.DataNotExistException; import cn.bootx.platform.common.core.exception.RepetitiveOperationException; import cn.bootx.platform.common.core.util.CollUtil; +import cn.bootx.platform.common.spring.util.WebServletUtil; import cn.daxpay.single.core.code.AllocDetailResultEnum; import cn.daxpay.single.core.code.AllocOrderResultEnum; import cn.daxpay.single.core.code.AllocOrderStatusEnum; @@ -29,6 +30,7 @@ import cn.daxpay.single.service.core.payment.allocation.entity.AllocationGroup; import cn.daxpay.single.service.dto.allocation.AllocationGroupReceiverResult; import cn.daxpay.single.service.func.AbsAllocationStrategy; import cn.daxpay.single.service.util.PayStrategyFactory; +import cn.hutool.extra.servlet.ServletUtil; import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; import lombok.RequiredArgsConstructor; @@ -39,6 +41,7 @@ import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; import static cn.daxpay.single.core.code.AllocOrderStatusEnum.ALLOCATION_END; @@ -176,7 +179,6 @@ public class AllocationService { } catch (Exception e) { log.error("重新分账出现错误:", e); - // TODO 失败 order.setStatus(AllocOrderStatusEnum.ALLOCATION_FAILED.getCode()) .setErrorMsg(e.getMessage()); } @@ -314,4 +316,21 @@ public class AllocationService { .filter(detail -> !Objects.equals(detail.getResult(), AllocDetailResultEnum.IGNORE.getCode())) .collect(Collectors.toList()); } + + /** + * 手动重试 + */ + public void retry(String bizAllocNo) { + AllocOrder allocOrder = allocationOrderManager.findByBizAllocNo(bizAllocNo) + .orElseThrow(() -> new DataErrorException("未查询到分账单")); + String ip = Optional.ofNullable(WebServletUtil.getRequest()) + .map(ServletUtil::getClientIP) + .orElse("未知"); + AllocationParam param = new AllocationParam(); + param.setBizAllocNo(allocOrder.getBizAllocNo()); + param.setAttach(allocOrder.getAttach()); + param.setNotifyUrl(allocOrder.getNotifyUrl()); + param.setClientIp(ip); + this.retryAllocation(param, allocOrder); + } }