fix 手动发起分账重试参数修正

This commit is contained in:
DaxPay
2024-06-19 20:29:42 +08:00
parent 8186486355
commit bd11adee36
4 changed files with 23 additions and 8 deletions

View File

@@ -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<Void> retryAllocation(String bizAllocNo){
AllocationParam param = new AllocationParam();
param.setBizAllocNo(bizAllocNo);
allocationService.allocation(param);
allocationService.retry(bizAllocNo);
return Res.ok();
}
}

View File

@@ -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);
}

View File

@@ -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);
}
}