Commit 3f51be6a2d26650f103f88d95a4cbe9ad942e2c3
1 parent
f99e2aec
钱包。删除不需要的类
Showing
5 changed files
with
5 additions
and
95 deletions
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/delegate/DelegatePayClient.java deleted
| 1 | -package cn.iocoder.yudao.framework.pay.core.client.impl.delegate; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; | |
| 4 | -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; | |
| 5 | -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; | |
| 6 | -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; | |
| 7 | -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; | |
| 8 | -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; | |
| 9 | - | |
| 10 | -import java.util.Map; | |
| 11 | - | |
| 12 | -// TODO @jason:其它模块,主要是无法 pay client 初始化存在问题,所以我感觉,是不是可以搞个 PayClientInitializer 接口。这样,PayClientFactory 去 get 这个支付模式对应的 PayClientInitializer,通过它来创建。具体注入的地方,可以在 PayChannel init 方法那; | |
| 13 | -/** | |
| 14 | - * 代理支付 Client 的抽象类。 | |
| 15 | - * | |
| 16 | - * 用于支付 Client 由其它模块实现,例如钱包支付 | |
| 17 | - * | |
| 18 | - * @author jason | |
| 19 | - */ | |
| 20 | -public abstract class DelegatePayClient<Config extends PayClientConfig> extends AbstractPayClient<PayClientConfig> { | |
| 21 | - | |
| 22 | - private final DelegatePayClient<Config> delegate; | |
| 23 | - | |
| 24 | - public DelegatePayClient(Long channelId, String channelCode, PayClientConfig config) { | |
| 25 | - super(channelId, channelCode, config); | |
| 26 | - delegate = this; | |
| 27 | - } | |
| 28 | - | |
| 29 | - @Override | |
| 30 | - protected void doInit() { | |
| 31 | - delegate.doInit(); | |
| 32 | - } | |
| 33 | - | |
| 34 | - @Override | |
| 35 | - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { | |
| 36 | - return delegate.doUnifiedOrder(reqDTO); | |
| 37 | - } | |
| 38 | - | |
| 39 | - @Override | |
| 40 | - protected PayOrderRespDTO doGetOrder(String outTradeNo) { | |
| 41 | - return delegate.doGetOrder(outTradeNo); | |
| 42 | - } | |
| 43 | - | |
| 44 | - @Override | |
| 45 | - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { | |
| 46 | - return delegate.doUnifiedRefund(reqDTO); | |
| 47 | - } | |
| 48 | - | |
| 49 | - @Override | |
| 50 | - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { | |
| 51 | - return delegate.doGetRefund(outTradeNo, outRefundNo); | |
| 52 | - } | |
| 53 | - | |
| 54 | - @Override | |
| 55 | - protected PayRefundRespDTO doParseRefundNotify(Map<String,String> params, String body) { | |
| 56 | - return delegate.doParseRefundNotify(params, body); | |
| 57 | - } | |
| 58 | - | |
| 59 | - @Override | |
| 60 | - protected PayOrderRespDTO doParseOrderNotify(Map<String,String> params, String body) { | |
| 61 | - return delegate.doParseOrderNotify(params, body); | |
| 62 | - } | |
| 63 | -} |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDT |
| 5 | 5 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; |
| 6 | 6 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; |
| 7 | 7 | import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; |
| 8 | +import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; | |
| 8 | 9 | import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; |
| 9 | 10 | |
| 10 | 11 | import java.time.LocalDateTime; |
| ... | ... | @@ -17,11 +18,11 @@ import java.util.Map; |
| 17 | 18 | * |
| 18 | 19 | * @author jason |
| 19 | 20 | */ |
| 20 | -public class MockPayClient extends AbstractPayClient<MockPayClientConfig> { | |
| 21 | +public class MockPayClient extends AbstractPayClient<NonePayClientConfig> { | |
| 21 | 22 | |
| 22 | 23 | private static final String MOCK_RESP_SUCCESS_DATA = "MOCK_SUCCESS"; |
| 23 | 24 | |
| 24 | - public MockPayClient(Long channelId, MockPayClientConfig config) { | |
| 25 | + public MockPayClient(Long channelId, NonePayClientConfig config) { | |
| 25 | 26 | super(channelId, PayChannelEnum.MOCK.getCode(), config); |
| 26 | 27 | } |
| 27 | 28 | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java deleted
| 1 | -package cn.iocoder.yudao.framework.pay.core.client.impl.mock; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -import javax.validation.Validator; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 模拟支付的 PayClientConfig 实现类 | |
| 10 | - * | |
| 11 | - * @author jason | |
| 12 | - */ | |
| 13 | -@Data | |
| 14 | -public class MockPayClientConfig implements PayClientConfig { | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * 配置名称 | |
| 18 | - * | |
| 19 | - * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 | |
| 20 | - */ | |
| 21 | - private String name; | |
| 22 | - | |
| 23 | - @Override | |
| 24 | - public void validate(Validator validator) { | |
| 25 | - // 模拟支付配置无需校验 | |
| 26 | - } | |
| 27 | - | |
| 28 | -} |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java
| ... | ... | @@ -4,7 +4,6 @@ import cn.hutool.core.util.ArrayUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; |
| 5 | 5 | import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; |
| 6 | 6 | import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; |
| 7 | -import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClientConfig; | |
| 8 | 7 | import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; |
| 9 | 8 | import lombok.AllArgsConstructor; |
| 10 | 9 | import lombok.Getter; |
| ... | ... | @@ -30,7 +29,7 @@ public enum PayChannelEnum { |
| 30 | 29 | ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class), |
| 31 | 30 | ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class), |
| 32 | 31 | |
| 33 | - MOCK("mock", "模拟支付", MockPayClientConfig.class), | |
| 32 | + MOCK("mock", "模拟支付", NonePayClientConfig.class), | |
| 34 | 33 | |
| 35 | 34 | WALLET("wallet", "钱包支付", NonePayClientConfig.class); |
| 36 | 35 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java
| ... | ... | @@ -70,6 +70,7 @@ public class PayOrderController { |
| 70 | 70 | @PostMapping("/submit") |
| 71 | 71 | @Operation(summary = "提交支付订单") |
| 72 | 72 | public CommonResult<PayOrderSubmitRespVO> submitPayOrder(@RequestBody PayOrderSubmitReqVO reqVO) { |
| 73 | + // 钱包支付需要 额外传 user_id 和 user_type | |
| 73 | 74 | if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { |
| 74 | 75 | Map<String, String> channelExtras = reqVO.getChannelExtras() == null ? new HashMap<>(8) : reqVO.getChannelExtras(); |
| 75 | 76 | channelExtras.put("user_id", String.valueOf(WebFrameworkUtils.getLoginUserId())); | ... | ... |