Commit ae98315616b5d88d4e41d1e2b97b1a954f9d7b14
1 parent
bf3e848c
增加模拟支付的订单号、退款号返回
Showing
4 changed files
with
19 additions
and
14 deletions
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 { | @@ -70,6 +70,7 @@ public class PayClientFactoryImpl implements PayClientFactory { | ||
| 70 | case ALIPAY_APP: return (AbstractPayClient<Config>) new AlipayAppPayClient(channelId, (AlipayPayClientConfig) config); | 70 | case ALIPAY_APP: return (AbstractPayClient<Config>) new AlipayAppPayClient(channelId, (AlipayPayClientConfig) config); |
| 71 | case ALIPAY_PC: return (AbstractPayClient<Config>) new AlipayPcPayClient(channelId, (AlipayPayClientConfig) config); | 71 | case ALIPAY_PC: return (AbstractPayClient<Config>) new AlipayPcPayClient(channelId, (AlipayPayClientConfig) config); |
| 72 | case ALIPAY_BAR: return (AbstractPayClient<Config>) new AlipayBarPayClient(channelId, (AlipayPayClientConfig) config); | 72 | case ALIPAY_BAR: return (AbstractPayClient<Config>) new AlipayBarPayClient(channelId, (AlipayPayClientConfig) config); |
| 73 | + // 其它支付 | ||
| 73 | case MOCK: return (AbstractPayClient<Config>) new MockPayClient(channelId, (MockPayClientConfig) config); | 74 | case MOCK: return (AbstractPayClient<Config>) new MockPayClient(channelId, (MockPayClientConfig) config); |
| 74 | } | 75 | } |
| 75 | // 创建失败,错误日志 + 抛出异常 | 76 | // 创建失败,错误日志 + 抛出异常 |
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; | @@ -11,7 +11,9 @@ import java.time.LocalDateTime; | ||
| 11 | import java.util.Map; | 11 | import java.util.Map; |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | - * 模拟支付的 PayClient 实现类, 模拟支付返回结果都是成功 | 14 | + * 模拟支付的 PayClient 实现类 |
| 15 | + * | ||
| 16 | + * 模拟支付返回结果都是成功,方便大家日常流畅 | ||
| 15 | * | 17 | * |
| 16 | * @author jason | 18 | * @author jason |
| 17 | */ | 19 | */ |
| @@ -25,31 +27,30 @@ public class MockPayClient extends AbstractPayClient<MockPayClientConfig> { | @@ -25,31 +27,30 @@ public class MockPayClient extends AbstractPayClient<MockPayClientConfig> { | ||
| 25 | 27 | ||
| 26 | @Override | 28 | @Override |
| 27 | protected void doInit() { | 29 | protected void doInit() { |
| 28 | - | ||
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | @Override | 32 | @Override |
| 32 | protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { | 33 | protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { |
| 33 | - // 模拟支付渠道订单号为空 | ||
| 34 | - return PayOrderRespDTO.successOf("", "", LocalDateTime.now(), reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA); | 34 | + return PayOrderRespDTO.successOf("MOCK-P-" + reqDTO.getOutTradeNo(), "", LocalDateTime.now(), |
| 35 | + reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA); | ||
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | @Override | 38 | @Override |
| 38 | protected PayOrderRespDTO doGetOrder(String outTradeNo) { | 39 | protected PayOrderRespDTO doGetOrder(String outTradeNo) { |
| 39 | - // 模拟支付渠道订单号为空 | ||
| 40 | - return PayOrderRespDTO.successOf("", "", LocalDateTime.now(), outTradeNo, MOCK_RESP_SUCCESS_DATA); | 40 | + return PayOrderRespDTO.successOf("MOCK-P-" + outTradeNo, "", LocalDateTime.now(), |
| 41 | + outTradeNo, MOCK_RESP_SUCCESS_DATA); | ||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | @Override | 44 | @Override |
| 44 | protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { | 45 | protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { |
| 45 | - // 模拟支付渠道退款单号为空 | ||
| 46 | - return PayRefundRespDTO.successOf("", LocalDateTime.now(), reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA); | 46 | + return PayRefundRespDTO.successOf("MOCK-R-" + reqDTO.getOutRefundNo(), LocalDateTime.now(), |
| 47 | + reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA); | ||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | @Override | 50 | @Override |
| 50 | protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { | 51 | protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { |
| 51 | - // 模拟支付渠道退款单号为空 | ||
| 52 | - return PayRefundRespDTO.successOf("", LocalDateTime.now(), outRefundNo, MOCK_RESP_SUCCESS_DATA); | 52 | + return PayRefundRespDTO.successOf("MOCK-R-" + outRefundNo, LocalDateTime.now(), |
| 53 | + outRefundNo, MOCK_RESP_SUCCESS_DATA); | ||
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | @Override | 56 | @Override |
| @@ -61,4 +62,5 @@ public class MockPayClient extends AbstractPayClient<MockPayClientConfig> { | @@ -61,4 +62,5 @@ public class MockPayClient extends AbstractPayClient<MockPayClientConfig> { | ||
| 61 | protected PayOrderRespDTO doParseOrderNotify(Map<String, String> params, String body) { | 62 | protected PayOrderRespDTO doParseOrderNotify(Map<String, String> params, String body) { |
| 62 | throw new UnsupportedOperationException("模拟支付无支付回调"); | 63 | throw new UnsupportedOperationException("模拟支付无支付回调"); |
| 63 | } | 64 | } |
| 64 | -} | ||
| 65 | \ No newline at end of file | 65 | \ No newline at end of file |
| 66 | + | ||
| 67 | +} |
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; | @@ -14,7 +14,9 @@ import javax.validation.Validator; | ||
| 14 | public class MockPayClientConfig implements PayClientConfig { | 14 | public class MockPayClientConfig implements PayClientConfig { |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | - * 配置名称,如果不加任何属性, JsonUtils.parseObject2 解析会报错. 暂时加个名称 | 17 | + * 配置名称 |
| 18 | + * | ||
| 19 | + * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 | ||
| 18 | */ | 20 | */ |
| 19 | private String name; | 21 | private String name; |
| 20 | 22 | ||
| @@ -22,4 +24,5 @@ public class MockPayClientConfig implements PayClientConfig { | @@ -22,4 +24,5 @@ public class MockPayClientConfig implements PayClientConfig { | ||
| 22 | public void validate(Validator validator) { | 24 | public void validate(Validator validator) { |
| 23 | // 模拟支付配置无需校验 | 25 | // 模拟支付配置无需校验 |
| 24 | } | 26 | } |
| 25 | -} | ||
| 26 | \ No newline at end of file | 27 | \ No newline at end of file |
| 28 | + | ||
| 29 | +} |
yudao-ui-admin/src/views/pay/app/components/mockChannelForm.vue
| @@ -10,7 +10,6 @@ | @@ -10,7 +10,6 @@ | ||
| 10 | </el-radio> | 10 | </el-radio> |
| 11 | </el-radio-group> | 11 | </el-radio-group> |
| 12 | </el-form-item> | 12 | </el-form-item> |
| 13 | - | ||
| 14 | <el-form-item label-width="180px" label="备注" prop="remark"> | 13 | <el-form-item label-width="180px" label="备注" prop="remark"> |
| 15 | <el-input v-model="formData.remark" :style="{width: '100%'}"></el-input> | 14 | <el-input v-model="formData.remark" :style="{width: '100%'}"></el-input> |
| 16 | </el-form-item> | 15 | </el-form-item> |