退款逻辑更新
This commit is contained in:
parent
0fb641bbd6
commit
37b255992c
|
@ -490,12 +490,12 @@ public class PayServiceImpl implements PayService {
|
|||
|
||||
// 增加退款中金额
|
||||
int addRefunding = payMapper.addRefundingAmount(dto.getId(), dto.getRefundAmount(), dto.getType());
|
||||
ServiceUtil.assertion(addRefunding != 1, "记录退款中的金额失败");
|
||||
ServiceUtil.assertion(addRefunding != 1, "ID为%s的支付单记录退款中的金额失败", dto.getId());
|
||||
|
||||
// 创建退款订单
|
||||
Refund refundPo = refundConverter.toPo(dto, pay);
|
||||
int refund = refundService.createRefund(refundPo);
|
||||
ServiceUtil.assertion(refund != 1, "申请退款失败");
|
||||
ServiceUtil.assertion(refund != 1, "ID为%s的支付单申请退款失败", dto.getId());
|
||||
|
||||
return refund;
|
||||
});
|
||||
|
|
|
@ -2,9 +2,7 @@ package com.ruoyi.bst.refund.service.impl;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
@ -25,6 +23,7 @@ import com.ruoyi.bst.refund.service.RefundService;
|
|||
import com.ruoyi.common.pay.PayApi;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
|
@ -135,6 +134,7 @@ public class RefundServiceImpl implements RefundService
|
|||
@Override
|
||||
public int createRefund(Refund refund) {
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 新增退款单
|
||||
refund.setStatus(RefundStatus.REFUNDING.getStatus());
|
||||
int insertRefund = this.insertRefund(refund);
|
||||
ServiceUtil.assertion(insertRefund != 1, "创建退款订单失败");
|
||||
|
@ -160,9 +160,7 @@ public class RefundServiceImpl implements RefundService
|
|||
|
||||
// 判断是否同步通知,若是则直接处理支付成功
|
||||
if (channelApiType.getIsRefundSync() != null && channelApiType.getIsRefundSync()) {
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
this.handleRefundSuccess(refund.getNo());
|
||||
}, 10, TimeUnit.SECONDS);
|
||||
this.handleRefundSuccess(refund.getNo());
|
||||
}
|
||||
|
||||
return insertRefund;
|
||||
|
@ -196,12 +194,12 @@ public class RefundServiceImpl implements RefundService
|
|||
query.setId(refund.getId());
|
||||
query.setStatus(RefundStatus.REFUNDING.getStatus());
|
||||
int rows = refundMapper.updateByQuery(data, query);
|
||||
ServiceUtil.assertion(rows != 1, "修改退款订单状态失败");
|
||||
ServiceUtil.assertion(rows != 1, "修改编号为%s的退款订单状态失败", no);
|
||||
|
||||
// 处理支付单
|
||||
RefundVO newRefund = this.selectRefundByNo(no);
|
||||
int handleResult = payService.handleRefundSuccess(newRefund);
|
||||
ServiceUtil.assertion(handleResult != 1, "修改支付单状态失败");
|
||||
ServiceUtil.assertion(handleResult != 1, "修改编号为%s的支付单状态失败", newRefund.getPayNo());
|
||||
|
||||
return rows;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user