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

@@ -8,18 +8,19 @@
- 支持现金支付和流水记录功能
- 增加支付宝流水记录功能
- 增加微信流水记录功能
- 变更废弃调用接口时的`version`字段调用时不再进行传输SDK中同步进行删除
- 优化订单支持关闭时间记录
- 优化增加退款订单扩展记录
- 优化SDK增加简单退款、多通道退款等多中测试样例
- fix同步支付通道订单不能正确生成
- fix修复聚合条码支付时付款码未传输问题
- fix修复微信退款同步时, 错误信息未保存问题
- fix修复手动发起退款时上下文未进行初始化的问题
- 变更: 废弃调用接口时的`version`字段调用时不再进行传输SDK中同步进行删除
- 优化: 订单支持关闭时间记录
- 优化: 增加退款订单扩展记录
- 优化: SDK增加简单退款、多通道退款等多中测试样例
- fix: 同步支付通道订单不能正确生成
- fix: 修复聚合条码支付时付款码未传输问题
- fix: 修复微信退款同步时, 错误信息未保存问题
- fix: 修复手动发起退款时上下文未进行初始化的问题
- fix: 修复简单退款选择全部退款时报错问题
## [v2.0.0]
- 支持支付宝支付扫码支付、付款码支付、PC支付、H5支付
- 支持微信支付扫码支付、WAP支付、公众号支付
- 支持支付宝支付: 扫码支付、付款码支付、PC支付、H5支付
- 支持微信支付: 扫码支付、WAP支付、公众号支付
- 增加聚合支付演示功能,支持支付宝和微信支付
- 增加PC收银台演示功能各种类型的支付
- 增加手机收银台演示功能,支持在微信、支付宝、浏览器中发起对应的请求

View File

@@ -55,14 +55,13 @@ public class SimplePayOrderTest {
@Test
public void simplePayCallback() {
SimplePayParam param = new SimplePayParam();
param.setBusinessNo("P"+ RandomUtil.randomNumbers(5));
param.setBusinessNo("P" + RandomUtil.randomNumbers(5));
param.setAmount(12);
param.setTitle("测试接口支付");
param.setChannel(PayChannelEnum.CASH.getCode());
param.setPayWay(PayWayEnum.NORMAL.getCode());
param.setClientIp("127.0.0.1");
param.setAttach("Attach");
param.setNotifyUrl("http://127.0.0.1:9000/demo/callback/pay");
param.setNotifyUrl("http://127.0.0.1:9000/demo/callback/payObject");
DaxPayResult<PayOrderModel> execute = DaxPayKit.execute(param);
System.out.println(execute);

View File

@@ -5,6 +5,7 @@ import cn.bootx.platform.daxpay.sdk.net.DaxPayConfig;
import cn.bootx.platform.daxpay.sdk.net.DaxPayKit;
import cn.bootx.platform.daxpay.sdk.param.refund.SimpleRefundParam;
import cn.bootx.platform.daxpay.sdk.response.DaxPayResult;
import cn.hutool.core.util.RandomUtil;
import org.junit.Before;
import org.junit.Test;
@@ -36,11 +37,9 @@ public class SimpleRefundOrderTest {
public void refundAllOrder(){
SimpleRefundParam param = new SimpleRefundParam();
param.setClientIp("127.0.0.1");
param.setBusinessNo("P0001");
param.setRefundNo("R0001");
param.setPaymentId(1762014603543281664L);
param.setRefundNo("R" + RandomUtil.randomNumbers(5));
param.setRefundAll(true);
DaxPayResult<RefundModel> execute = DaxPayKit.execute(param);
System.out.println(execute);
System.out.println(execute.getData());
@@ -54,9 +53,9 @@ public class SimpleRefundOrderTest {
SimpleRefundParam param = new SimpleRefundParam();
param.setClientIp("127.0.0.1");
param.setBusinessNo("P0001");
param.setPaymentId(1762018229581910016L);
param.setRefundAll(false);
param.setRefundNo("R0001");
param.setRefundNo("R" + RandomUtil.randomNumbers(5));
// 设置具体的退款参数
param.setAmount(1);

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