Commit ffee1895898b724476d8f545a609c41acace645b

Authored by YunaiV
1 parent 5327d3a4

reactor:移除 PayClient 获取转账时的 type 字段,只有支付宝会区分,后续通过 channelExtras 区分

yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java
@@ -44,7 +44,6 @@ public class PayDemoTransferCreateReqVO { @@ -44,7 +44,6 @@ public class PayDemoTransferCreateReqVO {
44 @NotBlank(message = "微信 openId 不能为空", groups = {WxPay.class}) 44 @NotBlank(message = "微信 openId 不能为空", groups = {WxPay.class})
45 private String openid; 45 private String openid;
46 46
47 -  
48 // ========== 转账到银行卡和钱包相关字段 待补充 ========== 47 // ========== 转账到银行卡和钱包相关字段 待补充 ==========
49 48
50 public void validate(Validator validator) { 49 public void validate(Validator validator) {
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java
@@ -14,12 +14,11 @@ import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; @@ -14,12 +14,11 @@ import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
14 import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; 14 import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig;
15 import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; 15 import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
16 import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; 16 import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
17 -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;  
18 import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; 17 import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
19 import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; 18 import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
20 import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; 19 import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
21 -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;  
22 import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; 20 import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
  21 +import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
23 import cn.iocoder.yudao.module.pay.service.order.PayOrderService; 22 import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
24 import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; 23 import cn.iocoder.yudao.module.pay.service.refund.PayRefundService;
25 import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; 24 import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
@@ -188,7 +187,7 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> { @@ -188,7 +187,7 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> {
188 } 187 }
189 188
190 @Override 189 @Override
191 - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { 190 + protected PayTransferRespDTO doGetTransfer(String outTradeNo) {
192 throw new UnsupportedOperationException("待实现"); 191 throw new UnsupportedOperationException("待实现");
193 } 192 }
194 193
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java
@@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.pay.core.client.PayClient; @@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.pay.core.client.PayClient;
9 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; 9 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
10 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; 10 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
11 import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; 11 import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum;
12 -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;  
13 import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; 12 import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
14 import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; 13 import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
15 import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO; 14 import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO;
@@ -283,8 +282,7 @@ public class PayTransferServiceImpl implements PayTransferService { @@ -283,8 +282,7 @@ public class PayTransferServiceImpl implements PayTransferService {
283 log.error("[syncTransfer][渠道编号({}) 找不到对应的支付客户端]", transfer.getChannelId()); 282 log.error("[syncTransfer][渠道编号({}) 找不到对应的支付客户端]", transfer.getChannelId());
284 return false; 283 return false;
285 } 284 }
286 - PayTransferRespDTO resp = payClient.getTransfer(transfer.getNo(),  
287 - PayTransferTypeEnum.typeOf(transfer.getType())); 285 + PayTransferRespDTO resp = payClient.getTransfer(transfer.getNo());
288 286
289 // 2. 回调转账结果 287 // 2. 回调转账结果
290 notifyTransfer(transfer.getChannelId(), resp); 288 notifyTransfer(transfer.getChannelId(), resp);
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java
@@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; @@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
6 import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; 6 import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
7 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; 7 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
8 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; 8 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
9 -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;  
10 9
11 import java.util.Map; 10 import java.util.Map;
12 11
@@ -95,10 +94,9 @@ public interface PayClient { @@ -95,10 +94,9 @@ public interface PayClient {
95 * 获得转账订单信息 94 * 获得转账订单信息
96 * 95 *
97 * @param outTradeNo 外部订单号 96 * @param outTradeNo 外部订单号
98 - * @param type 转账类型  
99 * @return 转账信息 97 * @return 转账信息
100 */ 98 */
101 - PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type); 99 + PayTransferRespDTO getTransfer(String outTradeNo);
102 100
103 /** 101 /**
104 * 解析 transfer 回调数据 102 * 解析 transfer 回调数据
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java
1 package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; 1 package cn.iocoder.yudao.framework.pay.core.client.dto.transfer;
2 2
3 -import cn.iocoder.yudao.framework.common.validation.InEnum;  
4 -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;  
5 -import lombok.Data;  
6 -import org.hibernate.validator.constraints.Length;  
7 -  
8 import jakarta.validation.constraints.Min; 3 import jakarta.validation.constraints.Min;
9 import jakarta.validation.constraints.NotBlank; 4 import jakarta.validation.constraints.NotBlank;
10 import jakarta.validation.constraints.NotEmpty; 5 import jakarta.validation.constraints.NotEmpty;
11 import jakarta.validation.constraints.NotNull; 6 import jakarta.validation.constraints.NotNull;
  7 +import lombok.Data;
  8 +import org.hibernate.validator.constraints.Length;
12 import org.hibernate.validator.constraints.URL; 9 import org.hibernate.validator.constraints.URL;
13 10
14 import java.util.Map; 11 import java.util.Map;
15 12
16 -import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.*; 13 +import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.Alipay;
  14 +import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.WxPay;
17 15
18 /** 16 /**
19 * 统一转账 Request DTO 17 * 统一转账 Request DTO
@@ -24,15 +22,6 @@ import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferType @@ -24,15 +22,6 @@ import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferType
24 public class PayTransferUnifiedReqDTO { 22 public class PayTransferUnifiedReqDTO {
25 23
26 /** 24 /**
27 - * 转账类型  
28 - *  
29 - * 关联 {@link PayTransferTypeEnum#getType()}  
30 - */  
31 - @NotNull(message = "转账类型不能为空")  
32 - @InEnum(PayTransferTypeEnum.class)  
33 - private Integer type;  
34 -  
35 - /**  
36 * 用户 IP 25 * 用户 IP
37 */ 26 */
38 @NotEmpty(message = "用户 IP 不能为空") 27 @NotEmpty(message = "用户 IP 不能为空")
@@ -55,6 +44,7 @@ public class PayTransferUnifiedReqDTO { @@ -55,6 +44,7 @@ public class PayTransferUnifiedReqDTO {
55 @Length(max = 128, message = "转账标题不能超过 128") 44 @Length(max = 128, message = "转账标题不能超过 128")
56 private String subject; 45 private String subject;
57 46
  47 + // TODO @芋艿:userName、alipayLogonId、openid =》channelExtras;另外:validatePayTransferReqDTO 去掉;
58 /** 48 /**
59 * 收款人姓名 49 * 收款人姓名
60 */ 50 */
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java
@@ -188,7 +188,6 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen @@ -188,7 +188,6 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen
188 188
189 @Override 189 @Override
190 public final PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { 190 public final PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO) {
191 - validatePayTransferReqDTO(reqDTO);  
192 PayTransferRespDTO resp; 191 PayTransferRespDTO resp;
193 try { 192 try {
194 resp = doUnifiedTransfer(reqDTO); 193 resp = doUnifiedTransfer(reqDTO);
@@ -202,22 +201,6 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen @@ -202,22 +201,6 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen
202 } 201 }
203 return resp; 202 return resp;
204 } 203 }
205 - private void validatePayTransferReqDTO(PayTransferUnifiedReqDTO reqDTO) {  
206 - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(reqDTO.getType());  
207 - switch (transferType) {  
208 - case ALIPAY_BALANCE: {  
209 - ValidationUtils.validate(reqDTO, PayTransferTypeEnum.Alipay.class);  
210 - break;  
211 - }  
212 - case WX_BALANCE: {  
213 - ValidationUtils.validate(reqDTO, PayTransferTypeEnum.WxPay.class);  
214 - break;  
215 - }  
216 - default: {  
217 - throw exception(NOT_IMPLEMENTED);  
218 - }  
219 - }  
220 - }  
221 204
222 @Override 205 @Override
223 public final PayTransferRespDTO parseTransferNotify(Map<String, String> params, String body, Map<String, String> headers) { 206 public final PayTransferRespDTO parseTransferNotify(Map<String, String> params, String body, Map<String, String> headers) {
@@ -236,14 +219,14 @@ public abstract class AbstractPayClient&lt;Config extends PayClientConfig&gt; implemen @@ -236,14 +219,14 @@ public abstract class AbstractPayClient&lt;Config extends PayClientConfig&gt; implemen
236 throws Throwable; 219 throws Throwable;
237 220
238 @Override 221 @Override
239 - public final PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type) { 222 + public final PayTransferRespDTO getTransfer(String outTradeNo) {
240 try { 223 try {
241 - return doGetTransfer(outTradeNo, type); 224 + return doGetTransfer(outTradeNo);
242 } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 225 } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可
243 throw ex; 226 throw ex;
244 } catch (Throwable ex) { 227 } catch (Throwable ex) {
245 - log.error("[getTransfer][客户端({}) outTradeNo({}) type({}) 查询转账单异常]",  
246 - getId(), outTradeNo, type, ex); 228 + log.error("[getTransfer][客户端({}) outTradeNo({}) 查询转账单异常]",
  229 + getId(), outTradeNo, ex);
247 throw buildPayException(ex); 230 throw buildPayException(ex);
248 } 231 }
249 } 232 }
@@ -251,7 +234,7 @@ public abstract class AbstractPayClient&lt;Config extends PayClientConfig&gt; implemen @@ -251,7 +234,7 @@ public abstract class AbstractPayClient&lt;Config extends PayClientConfig&gt; implemen
251 protected abstract PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) 234 protected abstract PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO)
252 throws Throwable; 235 throws Throwable;
253 236
254 - protected abstract PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) 237 + protected abstract PayTransferRespDTO doGetTransfer(String outTradeNo)
255 throws Throwable; 238 throws Throwable;
256 239
257 // ========== 各种工具方法 ========== 240 // ========== 各种工具方法 ==========
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.date.LocalDateTimeUtil; 4 import cn.hutool.core.date.LocalDateTimeUtil;
5 import cn.hutool.core.lang.Assert; 5 import cn.hutool.core.lang.Assert;
6 import cn.hutool.core.map.MapUtil; 6 import cn.hutool.core.map.MapUtil;
  7 +import cn.hutool.core.util.ObjectUtil;
7 import cn.hutool.core.util.StrUtil; 8 import cn.hutool.core.util.StrUtil;
8 import cn.hutool.http.HttpUtil; 9 import cn.hutool.http.HttpUtil;
9 import cn.iocoder.yudao.framework.common.util.json.JsonUtils; 10 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
@@ -16,7 +17,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDT @@ -16,7 +17,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDT
16 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; 17 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
17 import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; 18 import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
18 import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; 19 import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
19 -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;  
20 import com.alipay.api.AlipayApiException; 20 import com.alipay.api.AlipayApiException;
21 import com.alipay.api.AlipayConfig; 21 import com.alipay.api.AlipayConfig;
22 import com.alipay.api.AlipayResponse; 22 import com.alipay.api.AlipayResponse;
@@ -40,8 +40,7 @@ import java.util.Objects; @@ -40,8 +40,7 @@ import java.util.Objects;
40 import java.util.function.Supplier; 40 import java.util.function.Supplier;
41 41
42 import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; 42 import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER;
43 -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.*;  
44 -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 43 +import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.ERROR_CONFIGURATION;
45 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; 44 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
46 import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; 45 import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE;
47 import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY; 46 import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY;
@@ -236,11 +235,12 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa @@ -236,11 +235,12 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa
236 235
237 @Override 236 @Override
238 protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) throws AlipayApiException { 237 protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) throws AlipayApiException {
239 - // 1.1 校验公钥类型 必须使用公钥证书模式  
240 - if (!Objects.equals(config.getMode(), MODE_CERTIFICATE)) { 238 + // 0. 校验公钥类型:必须使用公钥证书模式
  239 + if (ObjectUtil.notEqual(config.getMode(), MODE_CERTIFICATE)) {
241 throw exception0(ERROR_CONFIGURATION.getCode(), "支付宝单笔转账必须使用公钥证书模式"); 240 throw exception0(ERROR_CONFIGURATION.getCode(), "支付宝单笔转账必须使用公钥证书模式");
242 } 241 }
243 - // 1.2 构建 AlipayFundTransUniTransferModel 242 +
  243 + // 1.1 构建 AlipayFundTransUniTransferModel
244 AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel(); 244 AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
245 // ① 通用的参数 245 // ① 通用的参数
246 model.setTransAmount(formatAmount(reqDTO.getPrice())); // 转账金额 246 model.setTransAmount(formatAmount(reqDTO.getPrice())); // 转账金额
@@ -253,32 +253,16 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa @@ -253,32 +253,16 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa
253 } 253 }
254 // ② 个性化的参数 254 // ② 个性化的参数
255 Participant payeeInfo = new Participant(); 255 Participant payeeInfo = new Participant();
256 - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(reqDTO.getType());  
257 - switch (transferType) {  
258 - // TODO @jason:是不是不用传递 transferType 参数哈?因为应该已经明确是支付宝啦?  
259 - // @芋艿。 是不是还要考虑转账到银行卡。所以传 transferType 但是转账到银行卡不知道要如何测试??  
260 - case ALIPAY_BALANCE: {  
261 - payeeInfo.setIdentityType("ALIPAY_LOGON_ID");  
262 - payeeInfo.setIdentity(reqDTO.getAlipayLogonId()); // 支付宝登录号  
263 - payeeInfo.setName(reqDTO.getUserName()); // 支付宝账号姓名  
264 - model.setPayeeInfo(payeeInfo);  
265 - break;  
266 - }  
267 - case BANK_CARD: {  
268 - payeeInfo.setIdentityType("BANKCARD_ACCOUNT");  
269 - // TODO 待实现  
270 - throw exception(NOT_IMPLEMENTED);  
271 - }  
272 - default: {  
273 - throw exception0(BAD_REQUEST.getCode(), "不正确的转账类型: {}", transferType);  
274 - }  
275 - }  
276 - // 1.3 构建 AlipayFundTransUniTransferRequest 256 + payeeInfo.setIdentityType("ALIPAY_LOGON_ID"); // 暂时只考虑转账到支付宝,银行没有权限 https://opendocs.alipay.com/open/02byvc?scene=66dd06f5a923403393b85de68d3c0055
  257 + payeeInfo.setIdentity(reqDTO.getAlipayLogonId()); // 支付宝登录号
  258 + payeeInfo.setName(reqDTO.getUserName()); // 支付宝账号姓名
  259 + model.setPayeeInfo(payeeInfo);
  260 + // 1.2 构建 AlipayFundTransUniTransferRequest
277 AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); 261 AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
278 request.setBizModel(model); 262 request.setBizModel(model);
279 - // 执行请求 263 +
  264 + // 2.1 执行请求
280 AlipayFundTransUniTransferResponse response = client.certificateExecute(request); 265 AlipayFundTransUniTransferResponse response = client.certificateExecute(request);
281 - // 处理结果  
282 if (!response.isSuccess()) { 266 if (!response.isSuccess()) {
283 // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询,或相同 outBizNo 重新发起转账 267 // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询,或相同 outBizNo 重新发起转账
284 // 发现 outBizNo 相同 两次请求参数相同. 会返回 "PAYMENT_INFO_INCONSISTENCY", 不知道哪里的问题. 暂时返回 WAIT. 后续job 会轮询 268 // 发现 outBizNo 相同 两次请求参数相同. 会返回 "PAYMENT_INFO_INCONSISTENCY", 不知道哪里的问题. 暂时返回 WAIT. 后续job 会轮询
@@ -287,25 +271,24 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa @@ -287,25 +271,24 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa
287 } 271 }
288 return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), 272 return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(),
289 reqDTO.getOutTransferNo(), response); 273 reqDTO.getOutTransferNo(), response);
290 - } else {  
291 - if (ObjectUtils.equalsAny(response.getStatus(), "REFUND", "FAIL")) { // 转账到银行卡会出现 "REFUND" "FAIL"  
292 - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(),  
293 - reqDTO.getOutTransferNo(), response);  
294 - }  
295 - if (Objects.equals(response.getStatus(), "DEALING")) { // 转账到银行卡会出现 "DEALING" 处理中  
296 - return PayTransferRespDTO.dealingOf(response.getOrderId(), reqDTO.getOutTransferNo(), response);  
297 - }  
298 - return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()),  
299 - response.getOutBizNo(), response);  
300 } 274 }
301 - 275 + // 2.2 处理结果
  276 + if (ObjectUtils.equalsAny(response.getStatus(), "REFUND", "FAIL")) { // 转账到银行卡会出现 "REFUND" "FAIL"
  277 + return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(),
  278 + reqDTO.getOutTransferNo(), response);
  279 + }
  280 + if (Objects.equals(response.getStatus(), "DEALING")) { // 转账到银行卡会出现 "DEALING" 处理中
  281 + return PayTransferRespDTO.dealingOf(response.getOrderId(), reqDTO.getOutTransferNo(), response);
  282 + }
  283 + return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()),
  284 + response.getOutBizNo(), response);
302 } 285 }
303 286
304 @Override 287 @Override
305 - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) throws Throwable { 288 + protected PayTransferRespDTO doGetTransfer(String outTradeNo) throws Throwable {
306 // 1.1 构建 AlipayFundTransCommonQueryModel 289 // 1.1 构建 AlipayFundTransCommonQueryModel
307 AlipayFundTransCommonQueryModel model = new AlipayFundTransCommonQueryModel(); 290 AlipayFundTransCommonQueryModel model = new AlipayFundTransCommonQueryModel();
308 - model.setProductCode(type == PayTransferTypeEnum.BANK_CARD ? "TRANS_BANKCARD_NO_PWD" : "TRANS_ACCOUNT_NO_PWD"); 291 + model.setProductCode("TRANS_ACCOUNT_NO_PWD");
309 model.setBizScene("DIRECT_TRANSFER"); //业务场景 292 model.setBizScene("DIRECT_TRANSFER"); //业务场景
310 model.setOutBizNo(outTradeNo); 293 model.setOutBizNo(outTradeNo);
311 // 1.2 构建 AlipayFundTransCommonQueryRequest 294 // 1.2 构建 AlipayFundTransCommonQueryRequest
@@ -319,18 +302,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa @@ -319,18 +302,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa
319 } else { 302 } else {
320 response = client.execute(request); 303 response = client.execute(request);
321 } 304 }
322 - // 2.2 处理返回结果  
323 - if (response.isSuccess()) {  
324 - if (ObjectUtils.equalsAny(response.getStatus(), "REFUND", "FAIL")) { // 转账到银行卡会出现 "REFUND" "FAIL"  
325 - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(),  
326 - outTradeNo, response);  
327 - }  
328 - if (Objects.equals(response.getStatus(), "DEALING")) { // 转账到银行卡会出现 "DEALING" 处理中  
329 - return PayTransferRespDTO.dealingOf(response.getOrderId(), outTradeNo, response);  
330 - }  
331 - return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getPayDate()),  
332 - response.getOutBizNo(), response);  
333 - } else { 305 + if (!response.isSuccess()) {
334 // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账 306 // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账
335 // 当出现 ORDER_NOT_EXIST 可能是转账还在处理中,也可能是转账处理失败. 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账 307 // 当出现 ORDER_NOT_EXIST 可能是转账还在处理中,也可能是转账处理失败. 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账
336 if (ObjectUtils.equalsAny(response.getSubCode(), "ORDER_NOT_EXIST", "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) { 308 if (ObjectUtils.equalsAny(response.getSubCode(), "ORDER_NOT_EXIST", "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) {
@@ -339,6 +311,16 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa @@ -339,6 +311,16 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient&lt;AlipayPa
339 return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), 311 return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(),
340 outTradeNo, response); 312 outTradeNo, response);
341 } 313 }
  314 + // 2.2 处理返回结果
  315 + if (ObjectUtils.equalsAny(response.getStatus(), "REFUND", "FAIL")) { // 转账到银行卡会出现 "REFUND" "FAIL"
  316 + return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(),
  317 + outTradeNo, response);
  318 + }
  319 + if (Objects.equals(response.getStatus(), "DEALING")) { // 转账到银行卡会出现 "DEALING" 处理中
  320 + return PayTransferRespDTO.dealingOf(response.getOrderId(), outTradeNo, response);
  321 + }
  322 + return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getPayDate()),
  323 + response.getOutBizNo(), response);
342 } 324 }
343 325
344 // TODO @chihuo:这里是不是也要实现,支付宝的。 326 // TODO @chihuo:这里是不是也要实现,支付宝的。
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java
@@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifie @@ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifie
9 import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; 9 import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
10 import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; 10 import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig;
11 import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; 11 import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
12 -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;  
13 12
14 import java.time.LocalDateTime; 13 import java.time.LocalDateTime;
15 import java.util.Map; 14 import java.util.Map;
@@ -78,7 +77,7 @@ public class MockPayClient extends AbstractPayClient&lt;NonePayClientConfig&gt; { @@ -78,7 +77,7 @@ public class MockPayClient extends AbstractPayClient&lt;NonePayClientConfig&gt; {
78 } 77 }
79 78
80 @Override 79 @Override
81 - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { 80 + protected PayTransferRespDTO doGetTransfer(String outTradeNo) {
82 throw new UnsupportedOperationException("待实现"); 81 throw new UnsupportedOperationException("待实现");
83 } 82 }
84 83
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java
@@ -17,7 +17,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifie @@ -17,7 +17,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifie
17 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.WxPayTransferPartnerNotifyV3Result; 17 import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.WxPayTransferPartnerNotifyV3Result;
18 import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; 18 import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
19 import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; 19 import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
20 -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum;  
21 import com.github.binarywang.wxpay.bean.notify.*; 20 import com.github.binarywang.wxpay.bean.notify.*;
22 import com.github.binarywang.wxpay.bean.request.*; 21 import com.github.binarywang.wxpay.bean.request.*;
23 import com.github.binarywang.wxpay.bean.result.*; 22 import com.github.binarywang.wxpay.bean.result.*;
@@ -489,7 +488,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient&lt;WxPayClientC @@ -489,7 +488,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient&lt;WxPayClientC
489 } 488 }
490 489
491 @Override 490 @Override
492 - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) throws WxPayException { 491 + protected PayTransferRespDTO doGetTransfer(String outTradeNo) throws WxPayException {
493 QueryTransferBatchesRequest request = QueryTransferBatchesRequest.newBuilder() 492 QueryTransferBatchesRequest request = QueryTransferBatchesRequest.newBuilder()
494 .outBatchNo(outTradeNo).needQueryDetail(true).offset(0).limit(20).detailStatus("ALL") 493 .outBatchNo(outTradeNo).needQueryDetail(true).offset(0).limit(20).detailStatus("ALL")
495 .build(); 494 .build();
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java
@@ -7,6 +7,7 @@ import lombok.Getter; @@ -7,6 +7,7 @@ import lombok.Getter;
7 7
8 import java.util.Arrays; 8 import java.util.Arrays;
9 9
  10 +// TODO @芋艿:【转账】这里要不要改成支付平台?
10 /** 11 /**
11 * 转账类型枚举 12 * 转账类型枚举
12 * 13 *