From 5b066ea69303e1045d9d598196d07f1e7c06f818 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 22 Jul 2023 20:46:38 +0800 Subject: [PATCH] =?UTF-8?q?mall=20+=20pay=EF=BC=9A=201.=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=94=AF=E4=BB=98=E5=AE=9D=E9=80=80=E6=AC=BE=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/pay/core/client/PayClient.java | 9 ++++ .../core/client/impl/AbstractPayClient.java | 22 +++++++-- .../impl/alipay/AbstractAlipayPayClient.java | 48 +++++++++++++++---- .../impl/weixin/AbstractWxPayClient.java | 5 ++ .../client/impl/weixin/WxPubPayClient.java | 1 + .../dal/dataobject/refund/PayRefundDO.java | 6 +++ 6 files changed, 79 insertions(+), 12 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java index 15ce53e95..4d163be55 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java @@ -67,4 +67,13 @@ public interface PayClient { */ PayRefundRespDTO parseRefundNotify(Map params, String body); + /** + * 获得退款订单信息 + * + * @param outTradeNo 外部订单号 + * @param outRefundNo 外部退款号 + * @return 退款订单信息 + */ + PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo); + } 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 bd4580e2d..c2c850b61 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 @@ -94,7 +94,7 @@ public abstract class AbstractPayClient implemen throws Throwable; @Override - public PayOrderRespDTO parseOrderNotify(Map params, String body) { + public final PayOrderRespDTO parseOrderNotify(Map params, String body) { try { return doParseOrderNotify(params, body); } catch (Throwable ex) { @@ -108,7 +108,7 @@ public abstract class AbstractPayClient implemen throws Throwable; @Override - public PayOrderRespDTO getOrder(String outTradeNo) { + public final PayOrderRespDTO getOrder(String outTradeNo) { try { return doGetOrder(outTradeNo); } catch (Throwable ex) { @@ -124,7 +124,7 @@ public abstract class AbstractPayClient implemen // ============ 退款相关 ========== @Override - public PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO) { + public final PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO) { ValidationUtils.validate(reqDTO); // 执行统一退款 PayRefundRespDTO resp; @@ -145,7 +145,7 @@ public abstract class AbstractPayClient implemen protected abstract PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable; @Override - public PayRefundRespDTO parseRefundNotify(Map params, String body) { + public final PayRefundRespDTO parseRefundNotify(Map params, String body) { try { return doParseRefundNotify(params, body); } catch (Throwable ex) { @@ -158,6 +158,20 @@ public abstract class AbstractPayClient implemen protected abstract PayRefundRespDTO doParseRefundNotify(Map params, String body) throws Throwable; + @Override + public final PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo) { + try { + return doGetRefund(outTradeNo, outRefundNo); + } catch (Throwable ex) { + log.error("[getRefund][客户端({}) outTradeNo({}) outRefundNo({}) 查询退款单异常]", + getId(), outTradeNo, outRefundNo, ex); + throw buildPayException(ex); + } + } + + protected abstract PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) + throws Throwable; + // ========== 各种工具方法 ========== private PayException buildPayException(Throwable ex) { diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java index f5c072a2d..e92544729 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java @@ -17,11 +17,14 @@ import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayConfig; import com.alipay.api.AlipayResponse; import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeFastpayRefundQueryModel; import com.alipay.api.domain.AlipayTradeQueryModel; import com.alipay.api.domain.AlipayTradeRefundModel; import com.alipay.api.internal.util.AlipaySignature; +import com.alipay.api.request.AlipayTradeFastpayRefundQueryRequest; import com.alipay.api.request.AlipayTradeQueryRequest; import com.alipay.api.request.AlipayTradeRefundRequest; +import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse; import com.alipay.api.response.AlipayTradeQueryResponse; import com.alipay.api.response.AlipayTradeRefundResponse; import lombok.SneakyThrows; @@ -29,6 +32,7 @@ import lombok.extern.slf4j.Slf4j; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; +import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.function.Supplier; @@ -102,7 +106,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient