Commit ffee1895898b724476d8f545a609c41acace645b
1 parent
5327d3a4
reactor:移除 PayClient 获取转账时的 type 字段,只有支付宝会区分,后续通过 channelExtras 区分
Showing
10 changed files
with
53 additions
and
105 deletions
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java
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 | 14 | import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; |
| 15 | 15 | import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; |
| 16 | 16 | import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; |
| 17 | -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; | |
| 18 | 17 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; |
| 19 | 18 | import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; |
| 20 | 19 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 21 | -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; | |
| 22 | 20 | import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; |
| 21 | +import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; | |
| 23 | 22 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 24 | 23 | import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; |
| 25 | 24 | import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; |
| ... | ... | @@ -188,7 +187,7 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> { |
| 188 | 187 | } |
| 189 | 188 | |
| 190 | 189 | @Override |
| 191 | - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { | |
| 190 | + protected PayTransferRespDTO doGetTransfer(String outTradeNo) { | |
| 192 | 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 | 9 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; |
| 10 | 10 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; |
| 11 | 11 | import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; |
| 12 | -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; | |
| 13 | 12 | import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; |
| 14 | 13 | import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; |
| 15 | 14 | import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferCreateReqVO; |
| ... | ... | @@ -283,8 +282,7 @@ public class PayTransferServiceImpl implements PayTransferService { |
| 283 | 282 | log.error("[syncTransfer][渠道编号({}) 找不到对应的支付客户端]", transfer.getChannelId()); |
| 284 | 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 | 287 | // 2. 回调转账结果 |
| 290 | 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 | 6 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; |
| 7 | 7 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; |
| 8 | 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 | 10 | import java.util.Map; |
| 12 | 11 | |
| ... | ... | @@ -95,10 +94,9 @@ public interface PayClient { |
| 95 | 94 | * 获得转账订单信息 |
| 96 | 95 | * |
| 97 | 96 | * @param outTradeNo 外部订单号 |
| 98 | - * @param type 转账类型 | |
| 99 | 97 | * @return 转账信息 |
| 100 | 98 | */ |
| 101 | - PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type); | |
| 99 | + PayTransferRespDTO getTransfer(String outTradeNo); | |
| 102 | 100 | |
| 103 | 101 | /** |
| 104 | 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 | 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 | 3 | import jakarta.validation.constraints.Min; |
| 9 | 4 | import jakarta.validation.constraints.NotBlank; |
| 10 | 5 | import jakarta.validation.constraints.NotEmpty; |
| 11 | 6 | import jakarta.validation.constraints.NotNull; |
| 7 | +import lombok.Data; | |
| 8 | +import org.hibernate.validator.constraints.Length; | |
| 12 | 9 | import org.hibernate.validator.constraints.URL; |
| 13 | 10 | |
| 14 | 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 | 17 | * 统一转账 Request DTO |
| ... | ... | @@ -24,15 +22,6 @@ import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferType |
| 24 | 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 | 25 | * 用户 IP |
| 37 | 26 | */ |
| 38 | 27 | @NotEmpty(message = "用户 IP 不能为空") |
| ... | ... | @@ -55,6 +44,7 @@ public class PayTransferUnifiedReqDTO { |
| 55 | 44 | @Length(max = 128, message = "转账标题不能超过 128") |
| 56 | 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 | 188 | |
| 189 | 189 | @Override |
| 190 | 190 | public final PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { |
| 191 | - validatePayTransferReqDTO(reqDTO); | |
| 192 | 191 | PayTransferRespDTO resp; |
| 193 | 192 | try { |
| 194 | 193 | resp = doUnifiedTransfer(reqDTO); |
| ... | ... | @@ -202,22 +201,6 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 202 | 201 | } |
| 203 | 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 | 205 | @Override |
| 223 | 206 | public final PayTransferRespDTO parseTransferNotify(Map<String, String> params, String body, Map<String, String> headers) { |
| ... | ... | @@ -236,14 +219,14 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 236 | 219 | throws Throwable; |
| 237 | 220 | |
| 238 | 221 | @Override |
| 239 | - public final PayTransferRespDTO getTransfer(String outTradeNo, PayTransferTypeEnum type) { | |
| 222 | + public final PayTransferRespDTO getTransfer(String outTradeNo) { | |
| 240 | 223 | try { |
| 241 | - return doGetTransfer(outTradeNo, type); | |
| 224 | + return doGetTransfer(outTradeNo); | |
| 242 | 225 | } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 |
| 243 | 226 | throw ex; |
| 244 | 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 | 230 | throw buildPayException(ex); |
| 248 | 231 | } |
| 249 | 232 | } |
| ... | ... | @@ -251,7 +234,7 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 251 | 234 | protected abstract PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) |
| 252 | 235 | throws Throwable; |
| 253 | 236 | |
| 254 | - protected abstract PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) | |
| 237 | + protected abstract PayTransferRespDTO doGetTransfer(String outTradeNo) | |
| 255 | 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 | 4 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 5 | 5 | import cn.hutool.core.lang.Assert; |
| 6 | 6 | import cn.hutool.core.map.MapUtil; |
| 7 | +import cn.hutool.core.util.ObjectUtil; | |
| 7 | 8 | import cn.hutool.core.util.StrUtil; |
| 8 | 9 | import cn.hutool.http.HttpUtil; |
| 9 | 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 | 17 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; |
| 17 | 18 | import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; |
| 18 | 19 | import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; |
| 19 | -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; | |
| 20 | 20 | import com.alipay.api.AlipayApiException; |
| 21 | 21 | import com.alipay.api.AlipayConfig; |
| 22 | 22 | import com.alipay.api.AlipayResponse; |
| ... | ... | @@ -40,8 +40,7 @@ import java.util.Objects; |
| 40 | 40 | import java.util.function.Supplier; |
| 41 | 41 | |
| 42 | 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 | 44 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; |
| 46 | 45 | import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; |
| 47 | 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<AlipayPa |
| 236 | 235 | |
| 237 | 236 | @Override |
| 238 | 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 | 240 | throw exception0(ERROR_CONFIGURATION.getCode(), "支付宝单笔转账必须使用公钥证书模式"); |
| 242 | 241 | } |
| 243 | - // 1.2 构建 AlipayFundTransUniTransferModel | |
| 242 | + | |
| 243 | + // 1.1 构建 AlipayFundTransUniTransferModel | |
| 244 | 244 | AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel(); |
| 245 | 245 | // ① 通用的参数 |
| 246 | 246 | model.setTransAmount(formatAmount(reqDTO.getPrice())); // 转账金额 |
| ... | ... | @@ -253,32 +253,16 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa |
| 253 | 253 | } |
| 254 | 254 | // ② 个性化的参数 |
| 255 | 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 | 261 | AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); |
| 278 | 262 | request.setBizModel(model); |
| 279 | - // 执行请求 | |
| 263 | + | |
| 264 | + // 2.1 执行请求 | |
| 280 | 265 | AlipayFundTransUniTransferResponse response = client.certificateExecute(request); |
| 281 | - // 处理结果 | |
| 282 | 266 | if (!response.isSuccess()) { |
| 283 | 267 | // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询,或相同 outBizNo 重新发起转账 |
| 284 | 268 | // 发现 outBizNo 相同 两次请求参数相同. 会返回 "PAYMENT_INFO_INCONSISTENCY", 不知道哪里的问题. 暂时返回 WAIT. 后续job 会轮询 |
| ... | ... | @@ -287,25 +271,24 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa |
| 287 | 271 | } |
| 288 | 272 | return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), |
| 289 | 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 | 287 | @Override |
| 305 | - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) throws Throwable { | |
| 288 | + protected PayTransferRespDTO doGetTransfer(String outTradeNo) throws Throwable { | |
| 306 | 289 | // 1.1 构建 AlipayFundTransCommonQueryModel |
| 307 | 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 | 292 | model.setBizScene("DIRECT_TRANSFER"); //业务场景 |
| 310 | 293 | model.setOutBizNo(outTradeNo); |
| 311 | 294 | // 1.2 构建 AlipayFundTransCommonQueryRequest |
| ... | ... | @@ -319,18 +302,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa |
| 319 | 302 | } else { |
| 320 | 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 | 306 | // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账 |
| 335 | 307 | // 当出现 ORDER_NOT_EXIST 可能是转账还在处理中,也可能是转账处理失败. 返回 WAIT 状态. 后续 job 会轮询, 或相同 outBizNo 重新发起转账 |
| 336 | 308 | if (ObjectUtils.equalsAny(response.getSubCode(), "ORDER_NOT_EXIST", "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) { |
| ... | ... | @@ -339,6 +311,16 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa |
| 339 | 311 | return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), |
| 340 | 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 | 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 | 9 | import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; |
| 10 | 10 | import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; |
| 11 | 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 | 13 | import java.time.LocalDateTime; |
| 15 | 14 | import java.util.Map; |
| ... | ... | @@ -78,7 +77,7 @@ public class MockPayClient extends AbstractPayClient<NonePayClientConfig> { |
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | @Override |
| 81 | - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) { | |
| 80 | + protected PayTransferRespDTO doGetTransfer(String outTradeNo) { | |
| 82 | 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 | 17 | import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.WxPayTransferPartnerNotifyV3Result; |
| 18 | 18 | import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; |
| 19 | 19 | import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; |
| 20 | -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; | |
| 21 | 20 | import com.github.binarywang.wxpay.bean.notify.*; |
| 22 | 21 | import com.github.binarywang.wxpay.bean.request.*; |
| 23 | 22 | import com.github.binarywang.wxpay.bean.result.*; |
| ... | ... | @@ -489,7 +488,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC |
| 489 | 488 | } |
| 490 | 489 | |
| 491 | 490 | @Override |
| 492 | - protected PayTransferRespDTO doGetTransfer(String outTradeNo, PayTransferTypeEnum type) throws WxPayException { | |
| 491 | + protected PayTransferRespDTO doGetTransfer(String outTradeNo) throws WxPayException { | |
| 493 | 492 | QueryTransferBatchesRequest request = QueryTransferBatchesRequest.newBuilder() |
| 494 | 493 | .outBatchNo(outTradeNo).needQueryDetail(true).offset(0).limit(20).detailStatus("ALL") |
| 495 | 494 | .build(); | ... | ... |
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java