diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java index 5a0ec1214..e8f898b2e 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java @@ -81,6 +81,8 @@ public abstract class AbstractPayClient implemen PayOrderRespDTO resp; try { resp = doUnifiedOrder(reqDTO); + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; } catch (Throwable ex) { // 系统异常,则包装成 PayException 异常抛出 log.error("[unifiedOrder][客户端({}) request({}) 发起支付异常]", @@ -97,6 +99,8 @@ public abstract class AbstractPayClient implemen public final PayOrderRespDTO parseOrderNotify(Map params, String body) { try { return doParseOrderNotify(params, body); + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; } catch (Throwable ex) { log.error("[parseOrderNotify][客户端({}) params({}) body({}) 解析失败]", getId(), params, body, ex); @@ -111,6 +115,8 @@ public abstract class AbstractPayClient implemen public final PayOrderRespDTO getOrder(String outTradeNo) { try { return doGetOrder(outTradeNo); + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; } catch (Throwable ex) { log.error("[getOrder][客户端({}) outTradeNo({}) 查询支付单异常]", getId(), outTradeNo, ex); @@ -130,8 +136,7 @@ public abstract class AbstractPayClient implemen PayRefundRespDTO resp; try { resp = doUnifiedRefund(reqDTO); - } catch (ServiceException ex) { - // 业务异常,都是实现类已经翻译,所以直接抛出即可 + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 throw ex; } catch (Throwable ex) { // 系统异常,则包装成 PayException 异常抛出 @@ -148,6 +153,8 @@ public abstract class AbstractPayClient implemen public final PayRefundRespDTO parseRefundNotify(Map params, String body) { try { return doParseRefundNotify(params, body); + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; } catch (Throwable ex) { log.error("[parseRefundNotify][客户端({}) params({}) body({}) 解析失败]", getId(), params, body, ex); @@ -162,6 +169,8 @@ public abstract class AbstractPayClient implemen public final PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo) { try { return doGetRefund(outTradeNo, outRefundNo); + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; } catch (Throwable ex) { log.error("[getRefund][客户端({}) outTradeNo({}) outRefundNo({}) 查询退款单异常]", getId(), outTradeNo, outRefundNo, ex); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java index e4e644d26..5254bc8c9 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; +import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; @@ -55,13 +56,17 @@ public class AlipayBarPayClient extends AbstractAlipayPayClient { request.setNotifyUrl(reqDTO.getNotifyUrl()); request.setReturnUrl(reqDTO.getReturnUrl()); - // TODO 芋艿:各种边界的处理 // 2.1 执行请求 AlipayTradePayResponse response = client.execute(request); // 2.2 处理结果 if (!response.isSuccess()) { return buildClosedPayOrderRespDTO(reqDTO, response); } + if ("10000".equals(response.getCode())) { // 免密支付 + return PayOrderRespDTO.successOf(response.getTradeNo(), response.getBuyerUserId(), LocalDateTimeUtil.of(response.getGmtPayment()), + response.getOutTradeNo(), response); + } + // 大额支付,需要用户输入密码,所以返回 waiting。此时,前端一般会进行轮询 return PayOrderRespDTO.waitingOf(displayMode, "", reqDTO.getOutTradeNo(), response); }