Commit 6fcff0863a858a3e44ab26e46baac4e4a3021d7b

Authored by jason
1 parent 0f0e6eb8

支付宝统一退款接口 subCode == ACQ.SYSTEM_ERROR 返回 WAITING 状态

yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java
@@ -13,6 +13,11 @@ import java.time.LocalDateTime; @@ -13,6 +13,11 @@ import java.time.LocalDateTime;
13 @Data 13 @Data
14 public class PayTransferRespDTO { 14 public class PayTransferRespDTO {
15 15
  16 + /**
  17 + * 转账状态
  18 + *
  19 + * 关联 {@link PayTransferStatusRespEnum#getStatus()}
  20 + */
16 private Integer status; 21 private Integer status;
17 22
18 /** 23 /**
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java
@@ -51,7 +51,7 @@ public class PayTransferUnifiedReqDTO { @@ -51,7 +51,7 @@ public class PayTransferUnifiedReqDTO {
51 private String title; 51 private String title;
52 52
53 /** 53 /**
54 - * 收款方信息,转账类型不同信息不同 54 + * 收款方信息,转账类型不同,收款方信息不同
55 */ 55 */
56 @NotEmpty(message = "收款方信息 不能为空") 56 @NotEmpty(message = "收款方信息 不能为空")
57 private Map<String, String> payeeInfo; 57 private Map<String, String> payeeInfo;
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java
@@ -50,6 +50,8 @@ public class PayClientFactoryImpl implements PayClientFactory { @@ -50,6 +50,8 @@ public class PayClientFactoryImpl implements PayClientFactory {
50 clientClass.put(ALIPAY_APP, AlipayAppPayClient.class); 50 clientClass.put(ALIPAY_APP, AlipayAppPayClient.class);
51 clientClass.put(ALIPAY_PC, AlipayPcPayClient.class); 51 clientClass.put(ALIPAY_PC, AlipayPcPayClient.class);
52 clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class); 52 clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class);
  53 + // 支付包转账客户端
  54 + clientClass.put(ALIPAY_TRANSFER, AlipayTransferClient.class);
53 // Mock 支付客户端 55 // Mock 支付客户端
54 clientClass.put(MOCK, MockPayClient.class); 56 clientClass.put(MOCK, MockPayClient.class);
55 } 57 }
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java
@@ -151,7 +151,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa @@ -151,7 +151,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa
151 AlipayTradeRefundResponse response = client.execute(request); 151 AlipayTradeRefundResponse response = client.execute(request);
152 if (!response.isSuccess()) { 152 if (!response.isSuccess()) {
153 // 当出现 ACQ.SYSTEM_ERROR, 退款可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询 153 // 当出现 ACQ.SYSTEM_ERROR, 退款可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询
154 - if (Objects.equals(response.getSubCode(), "ACQ.SYSTEM_ERROR")) { 154 + if (ObjectUtils.equalsAny(response.getSubCode(), "ACQ.SYSTEM_ERROR", "SYSTEM_ERROR")) {
155 return PayRefundRespDTO.waitingOf(null, reqDTO.getOutRefundNo(), response); 155 return PayRefundRespDTO.waitingOf(null, reqDTO.getOutRefundNo(), response);
156 } 156 }
157 return PayRefundRespDTO.failureOf(response.getSubCode(), response.getSubMsg(), reqDTO.getOutRefundNo(), response); 157 return PayRefundRespDTO.failureOf(response.getSubCode(), response.getSubMsg(), reqDTO.getOutRefundNo(), response);
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayTransferClient.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
3 import cn.hutool.core.map.MapUtil; 3 import cn.hutool.core.map.MapUtil;
4 import cn.hutool.core.util.StrUtil; 4 import cn.hutool.core.util.StrUtil;
5 import cn.iocoder.yudao.framework.common.util.json.JsonUtils; 5 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
  6 +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
6 import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; 7 import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
7 import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; 8 import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
8 import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; 9 import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
@@ -18,8 +19,6 @@ import com.alipay.api.request.AlipayFundTransUniTransferRequest; @@ -18,8 +19,6 @@ import com.alipay.api.request.AlipayFundTransUniTransferRequest;
18 import com.alipay.api.response.AlipayFundTransUniTransferResponse; 19 import com.alipay.api.response.AlipayFundTransUniTransferResponse;
19 import lombok.extern.slf4j.Slf4j; 20 import lombok.extern.slf4j.Slf4j;
20 21
21 -import java.util.Objects;  
22 -  
23 import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; 22 import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
24 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; 23 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
25 24
@@ -82,12 +81,11 @@ public class AlipayTransferClient extends AbstractAlipayPayClient { @@ -82,12 +81,11 @@ public class AlipayTransferClient extends AbstractAlipayPayClient {
82 // 处理结果 81 // 处理结果
83 if (!response.isSuccess()) { 82 if (!response.isSuccess()) {
84 // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询 83 // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询
85 - if (Objects.equals(response.getSubCode(), "SYSTEM_ERROR")) { 84 + if (ObjectUtils.equalsAny(response.getSubCode(), "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) {
86 return PayTransferRespDTO.waitingOf(null, reqDTO.getOutTransferNo(), response); 85 return PayTransferRespDTO.waitingOf(null, reqDTO.getOutTransferNo(), response);
87 } 86 }
88 return PayTransferRespDTO.failureOf(response.getSubCode(), response.getSubMsg(), 87 return PayTransferRespDTO.failureOf(response.getSubCode(), response.getSubMsg(),
89 reqDTO.getOutTransferNo(), response); 88 reqDTO.getOutTransferNo(), response);
90 -  
91 } 89 }
92 return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()), 90 return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()),
93 response.getOutBizNo(), response); 91 response.getOutBizNo(), response);