From ae98315616b5d88d4e41d1e2b97b1a954f9d7b14 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 29 Jul 2023 11:32:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=8B=9F=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=9A=84=E8=AE=A2=E5=8D=95=E5=8F=B7=E3=80=81=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E5=8F=B7=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/impl/PayClientFactoryImpl.java | 1 + .../core/client/impl/mock/MockPayClient.java | 24 ++++++++++--------- .../client/impl/mock/MockPayClientConfig.java | 7 ++++-- .../pay/app/components/mockChannelForm.vue | 1 - 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java index adad219ed..121aeb087 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java @@ -70,6 +70,7 @@ public class PayClientFactoryImpl implements PayClientFactory { case ALIPAY_APP: return (AbstractPayClient) new AlipayAppPayClient(channelId, (AlipayPayClientConfig) config); case ALIPAY_PC: return (AbstractPayClient) new AlipayPcPayClient(channelId, (AlipayPayClientConfig) config); case ALIPAY_BAR: return (AbstractPayClient) new AlipayBarPayClient(channelId, (AlipayPayClientConfig) config); + // 其它支付 case MOCK: return (AbstractPayClient) new MockPayClient(channelId, (MockPayClientConfig) config); } // 创建失败,错误日志 + 抛出异常 diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java index 071737b76..1d3f4d48b 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java @@ -11,7 +11,9 @@ import java.time.LocalDateTime; import java.util.Map; /** - * 模拟支付的 PayClient 实现类, 模拟支付返回结果都是成功 + * 模拟支付的 PayClient 实现类 + * + * 模拟支付返回结果都是成功,方便大家日常流畅 * * @author jason */ @@ -25,31 +27,30 @@ public class MockPayClient extends AbstractPayClient { @Override protected void doInit() { - } @Override protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - // 模拟支付渠道订单号为空 - return PayOrderRespDTO.successOf("", "", LocalDateTime.now(), reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA); + return PayOrderRespDTO.successOf("MOCK-P-" + reqDTO.getOutTradeNo(), "", LocalDateTime.now(), + reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA); } @Override protected PayOrderRespDTO doGetOrder(String outTradeNo) { - // 模拟支付渠道订单号为空 - return PayOrderRespDTO.successOf("", "", LocalDateTime.now(), outTradeNo, MOCK_RESP_SUCCESS_DATA); + return PayOrderRespDTO.successOf("MOCK-P-" + outTradeNo, "", LocalDateTime.now(), + outTradeNo, MOCK_RESP_SUCCESS_DATA); } @Override protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - // 模拟支付渠道退款单号为空 - return PayRefundRespDTO.successOf("", LocalDateTime.now(), reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA); + return PayRefundRespDTO.successOf("MOCK-R-" + reqDTO.getOutRefundNo(), LocalDateTime.now(), + reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA); } @Override protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - // 模拟支付渠道退款单号为空 - return PayRefundRespDTO.successOf("", LocalDateTime.now(), outRefundNo, MOCK_RESP_SUCCESS_DATA); + return PayRefundRespDTO.successOf("MOCK-R-" + outRefundNo, LocalDateTime.now(), + outRefundNo, MOCK_RESP_SUCCESS_DATA); } @Override @@ -61,4 +62,5 @@ public class MockPayClient extends AbstractPayClient { protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { throw new UnsupportedOperationException("模拟支付无支付回调"); } -} \ No newline at end of file + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java index 61f68a2c1..3e35c52dc 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java @@ -14,7 +14,9 @@ import javax.validation.Validator; public class MockPayClientConfig implements PayClientConfig { /** - * 配置名称,如果不加任何属性, JsonUtils.parseObject2 解析会报错. 暂时加个名称 + * 配置名称 + * + * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 */ private String name; @@ -22,4 +24,5 @@ public class MockPayClientConfig implements PayClientConfig { public void validate(Validator validator) { // 模拟支付配置无需校验 } -} \ No newline at end of file + +} diff --git a/yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue b/yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue index d3b053c70..e2d6162f1 100644 --- a/yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue +++ b/yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue @@ -10,7 +10,6 @@ -