fix: 修复简单退款选择全部退款时报错问题

This commit is contained in:
xxm1995
2024-02-26 15:37:17 +08:00
parent a64928ff5c
commit 2c7eff24ee
6 changed files with 23 additions and 24 deletions

View File

@@ -9,8 +9,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
/**
* 简单退款参数,只可以用于非组合的支付订单
* @author xxm
@@ -44,7 +42,6 @@ public class SimpleRefundParam extends PaymentCommonParam {
@Schema(description = "退款金额")
@NotNull(message = "退款金额不可为空")
private Integer amount;
/**

View File

@@ -127,9 +127,10 @@ public class RefundAssistService {
throw new PayFailureException("当前状态["+statusEnum.getName()+"]不允许发起退款操作");
}
// 过滤掉金额为0的退款参数
// 过滤掉金额为空和0的退款参数
List<RefundChannelParam> channelParams = param.getRefundChannels()
.stream()
.filter(r -> Objects.nonNull(r.getAmount()))
.filter(r -> r.getAmount() > 0)
.collect(Collectors.toList());
param.setRefundChannels(channelParams);

View File

@@ -74,8 +74,10 @@ public class RefundService {
// 构建退款参数
RefundParam refundParam = new RefundParam();
BeanUtil.copyProperties(param,refundParam);
RefundChannelParam channelParam = new RefundChannelParam().setAmount(param.getAmount());
refundParam.setRefundChannels(Collections.singletonList(channelParam));
if (!param.isRefundAll()){
RefundChannelParam channelParam = new RefundChannelParam().setAmount(param.getAmount());
refundParam.setRefundChannels(Collections.singletonList(channelParam));
}
return this.refundAdapter(refundParam,true);
}