Commit 0fcc0072c23ae1e38b6cca752a53026b96c243cf
1 parent
5ae43a23
1. AlipayBarPayClient 增加小额支付的成功返回
Showing
2 changed files
with
17 additions
and
3 deletions
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<Config extends PayClientConfig> implemen |
| 81 | 81 | PayOrderRespDTO resp; |
| 82 | 82 | try { |
| 83 | 83 | resp = doUnifiedOrder(reqDTO); |
| 84 | + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 | |
| 85 | + throw ex; | |
| 84 | 86 | } catch (Throwable ex) { |
| 85 | 87 | // 系统异常,则包装成 PayException 异常抛出 |
| 86 | 88 | log.error("[unifiedOrder][客户端({}) request({}) 发起支付异常]", |
| ... | ... | @@ -97,6 +99,8 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 97 | 99 | public final PayOrderRespDTO parseOrderNotify(Map<String, String> params, String body) { |
| 98 | 100 | try { |
| 99 | 101 | return doParseOrderNotify(params, body); |
| 102 | + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 | |
| 103 | + throw ex; | |
| 100 | 104 | } catch (Throwable ex) { |
| 101 | 105 | log.error("[parseOrderNotify][客户端({}) params({}) body({}) 解析失败]", |
| 102 | 106 | getId(), params, body, ex); |
| ... | ... | @@ -111,6 +115,8 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 111 | 115 | public final PayOrderRespDTO getOrder(String outTradeNo) { |
| 112 | 116 | try { |
| 113 | 117 | return doGetOrder(outTradeNo); |
| 118 | + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 | |
| 119 | + throw ex; | |
| 114 | 120 | } catch (Throwable ex) { |
| 115 | 121 | log.error("[getOrder][客户端({}) outTradeNo({}) 查询支付单异常]", |
| 116 | 122 | getId(), outTradeNo, ex); |
| ... | ... | @@ -130,8 +136,7 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 130 | 136 | PayRefundRespDTO resp; |
| 131 | 137 | try { |
| 132 | 138 | resp = doUnifiedRefund(reqDTO); |
| 133 | - } catch (ServiceException ex) { | |
| 134 | - // 业务异常,都是实现类已经翻译,所以直接抛出即可 | |
| 139 | + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 | |
| 135 | 140 | throw ex; |
| 136 | 141 | } catch (Throwable ex) { |
| 137 | 142 | // 系统异常,则包装成 PayException 异常抛出 |
| ... | ... | @@ -148,6 +153,8 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 148 | 153 | public final PayRefundRespDTO parseRefundNotify(Map<String, String> params, String body) { |
| 149 | 154 | try { |
| 150 | 155 | return doParseRefundNotify(params, body); |
| 156 | + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 | |
| 157 | + throw ex; | |
| 151 | 158 | } catch (Throwable ex) { |
| 152 | 159 | log.error("[parseRefundNotify][客户端({}) params({}) body({}) 解析失败]", |
| 153 | 160 | getId(), params, body, ex); |
| ... | ... | @@ -162,6 +169,8 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen |
| 162 | 169 | public final PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo) { |
| 163 | 170 | try { |
| 164 | 171 | return doGetRefund(outTradeNo, outRefundNo); |
| 172 | + } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 | |
| 173 | + throw ex; | |
| 165 | 174 | } catch (Throwable ex) { |
| 166 | 175 | log.error("[getRefund][客户端({}) outTradeNo({}) outRefundNo({}) 查询退款单异常]", |
| 167 | 176 | getId(), outTradeNo, outRefundNo, ex); | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java
| 1 | 1 | package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 3 | 4 | import cn.hutool.core.map.MapUtil; |
| 4 | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | 6 | import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; |
| ... | ... | @@ -55,13 +56,17 @@ public class AlipayBarPayClient extends AbstractAlipayPayClient { |
| 55 | 56 | request.setNotifyUrl(reqDTO.getNotifyUrl()); |
| 56 | 57 | request.setReturnUrl(reqDTO.getReturnUrl()); |
| 57 | 58 | |
| 58 | - // TODO 芋艿:各种边界的处理 | |
| 59 | 59 | // 2.1 执行请求 |
| 60 | 60 | AlipayTradePayResponse response = client.execute(request); |
| 61 | 61 | // 2.2 处理结果 |
| 62 | 62 | if (!response.isSuccess()) { |
| 63 | 63 | return buildClosedPayOrderRespDTO(reqDTO, response); |
| 64 | 64 | } |
| 65 | + if ("10000".equals(response.getCode())) { // 免密支付 | |
| 66 | + return PayOrderRespDTO.successOf(response.getTradeNo(), response.getBuyerUserId(), LocalDateTimeUtil.of(response.getGmtPayment()), | |
| 67 | + response.getOutTradeNo(), response); | |
| 68 | + } | |
| 69 | + // 大额支付,需要用户输入密码,所以返回 waiting。此时,前端一般会进行轮询 | |
| 65 | 70 | return PayOrderRespDTO.waitingOf(displayMode, "", |
| 66 | 71 | reqDTO.getOutTradeNo(), response); |
| 67 | 72 | } | ... | ... |