diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java index 0fa866696..68eac48cb 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant; -import cn.iocoder.yudao.coreservice.modules.pay.enums.merchant.PayChannelCodeEnum; +import cn.iocoder.yudao.framework.sms.core.enums.PayChannelCodeEnum; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import lombok.Data; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java index d4a887cf4..ebdc26030 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.coreservice.modules.pay.enums.merchant.PayChannelCodeEnum; +import cn.iocoder.yudao.framework.sms.core.enums.PayChannelCodeEnum; import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.TableName; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java index 6f9ce7060..732b68b13 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.coreservice.modules.pay.enums.merchant.PayChannelCodeEnum; +import cn.iocoder.yudao.framework.sms.core.enums.PayChannelCodeEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import lombok.Data; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/merchant/PayChannelCodeEnum.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/PayChannelCodeEnum.java similarity index 86% rename from yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/merchant/PayChannelCodeEnum.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/PayChannelCodeEnum.java index 9e8f7eba1..095692a2b 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/merchant/PayChannelCodeEnum.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/PayChannelCodeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.coreservice.modules.pay.enums.merchant; +package cn.iocoder.yudao.framework.sms.core.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml index 68b29bea0..862a41e45 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml @@ -29,6 +29,11 @@ hibernate-validator + + org.slf4j + slf4j-api + + com.github.javen205 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 37367a387..1fe3690e1 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 @@ -10,6 +10,13 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO; */ public interface PayClient { + /** + * 获得渠道编号 + * + * @return 渠道编号 + */ + Long getId(); + // TODO 缺少注释 CommonResult unifiedOrder(PayOrderUnifiedReqDTO reqDTO); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java new file mode 100644 index 000000000..b3f978fc9 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.framework.pay.core.client; + +/** + * 支付客户端的工厂接口 + * + * @author 芋道源码 + */ +public interface PayClientFactory { + + /** + * 获得支付客户端 + * + * @param channelId 渠道编号 + * @return 支付客户端 + */ + PayClient getPayClient(Long channelId); + + /** + * 创建支付客户端 + * + * @param channelId 渠道编号 + * @param channelCode 渠道编码 + * @param config 支付配置 + */ + void createOrUpdatePayClient(Long channelId, String channelCode, PayClientConfig config); + +} 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 4034a4a6f..77defbc4e 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 @@ -1,22 +1,73 @@ package cn.iocoder.yudao.framework.pay.core.client.impl; import cn.iocoder.yudao.framework.pay.core.client.PayClient; +import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.PayCodeMapping; +import lombok.extern.slf4j.Slf4j; /** * 支付客户端的抽象类,提供模板方法,减少子类的冗余代码 * * @author 芋道源码 */ -public abstract class AbstractPayClient implements PayClient { +@Slf4j +public abstract class AbstractPayClient implements PayClient { + /** + * 渠道编号 + */ + private final Long channelId; + /** + * 渠道编码 + */ + private final String channelCode; /** * 错误码枚举类 */ protected PayCodeMapping codeMapping; + /** + * 支付配置 + */ + protected Config config; protected Double calculateAmount(Integer amount) { return amount / 100.0; } + public AbstractPayClient(Long channelId, String channelCode, Config config, PayCodeMapping codeMapping) { + this.channelId = channelId; + this.channelCode = channelCode; + this.codeMapping = codeMapping; + this.config = config; + } + + /** + * 初始化 + */ + public final void init() { + doInit(); + log.info("[init][配置({}) 初始化完成]", config); + } + + /** + * 自定义初始化 + */ + protected abstract void doInit(); + + public final void refresh(Config config) { + // 判断是否更新 + if (config.equals(this.config)) { + return; + } + log.info("[refresh][配置({})发生变化,重新初始化]", config); + this.config = config; + // 初始化 + this.init(); + } + + @Override + public Long getId() { + return channelId; + } + } 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 new file mode 100644 index 000000000..d8f9d97c5 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl; + +import cn.iocoder.yudao.framework.pay.core.client.PayClient; +import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; +import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * 支付客户端的工厂实现类 + * + * @author 芋道源码 + */ +public class PayClientFactoryImpl implements PayClientFactory { + + /** + * 支付客户端 Map + * key:渠道编号 + */ + private final ConcurrentMap channelIdClients = new ConcurrentHashMap<>(); + + @Override + public PayClient getPayClient(Long channelId) { + return null; + } + + @Override + public void createOrUpdatePayClient(Long channelId, String channelCode, PayClientConfig config) { + + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayConfig.java index 8b36e8aac..26b1fc8d3 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayConfig.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayConfig.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; +import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import lombok.Data; // TODO 芋艿:参数校验 @@ -10,7 +11,7 @@ import lombok.Data; * @author 芋道源码 */ @Data -public class AlipayPayConfig { +public class AlipayPayConfig implements PayClientConfig { /** * 网关地址 - 线上 diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java similarity index 88% rename from yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClient.java rename to yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java index 7513d2039..1be679ca4 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java @@ -3,8 +3,8 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; import cn.hutool.core.bean.BeanUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.pay.core.client.PayCommonResult; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayConfig; import com.alipay.api.DefaultAlipayClient; @@ -14,24 +14,27 @@ import com.alipay.api.response.AlipayTradePrecreateResponse; import lombok.SneakyThrows; /** - * 支付宝的 PayClient 实现类 + * 支付宝【扫码支付】的 PayClient 实现类 + * 文档:https://opendocs.alipay.com/apis/02890k + * + * @author 芋道源码 */ -public class AlipayPayClient extends AbstractPayClient { +public class AlipayQrPayClient extends AbstractPayClient { - private final DefaultAlipayClient client; + private DefaultAlipayClient client; + public AlipayQrPayClient(Long channelId, String channelCode, AlipayPayConfig config) { + super(channelId, channelCode, config, new AlipayPayCodeMapping()); + } + + @Override @SneakyThrows - public AlipayPayClient(AlipayPayConfig config) { - // 创建 DefaultAlipayClient 对象 + protected void doInit() { AlipayConfig alipayConfig = new AlipayConfig(); BeanUtil.copyProperties(config, alipayConfig, false); this.client = new DefaultAlipayClient(alipayConfig); - - // 创建 AlipayPayCodeMapping 对象 - super.codeMapping = new AlipayPayCodeMapping(); } - // TODO 芋艿:暂时是扫码支付,需要调整成 wap https://opendocs.alipay.com/apis/api_1/alipay.trade.wap.pay @Override public CommonResult unifiedOrder(PayOrderUnifiedReqDTO reqDTO) { // 构建 AlipayTradePrecreateModel 请求 @@ -46,7 +49,7 @@ public class AlipayPayClient extends AbstractPayClient { request.setBizModel(model); // 执行请求 - AlipayTradePrecreateResponse response = null; + AlipayTradePrecreateResponse response; try { response = client.execute(request); } catch (AlipayApiException e) { @@ -67,7 +70,8 @@ public class AlipayPayClient extends AbstractPayClient { config.setSignType(AlipayPayConfig.SIGN_TYPE_DEFAULT); config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCV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J4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - AlipayPayClient client = new AlipayPayClient(config); + AlipayQrPayClient client = new AlipayQrPayClient(1L, "biu", config); + client.init(); PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO(); reqDTO.setAmount(123); @@ -75,5 +79,4 @@ public class AlipayPayClient extends AbstractPayClient { reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); client.unifiedOrder(reqDTO); } - } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java new file mode 100644 index 000000000..d2102ab6c --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java @@ -0,0 +1,85 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; + +import cn.hutool.core.bean.BeanUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.pay.core.client.PayCommonResult; +import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayConfig; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeWapPayModel; +import com.alipay.api.request.AlipayTradeWapPayRequest; +import com.alipay.api.response.AlipayTradeWapPayResponse; +import lombok.SneakyThrows; + +/** + * 支付宝【手机网站】的 PayClient 实现类 + * 文档:https://opendocs.alipay.com/apis/api_1/alipay.trade.wap.pay + * + * @author 芋道源码 + */ +public class AlipayWapPayClient extends AbstractPayClient { + + private DefaultAlipayClient client; + + public AlipayWapPayClient(Long channelId, String channelCode, AlipayPayConfig config) { + super(channelId, channelCode, config, new AlipayPayCodeMapping()); + } + + @Override + @SneakyThrows + protected void doInit() { + AlipayConfig alipayConfig = new AlipayConfig(); + BeanUtil.copyProperties(config, alipayConfig, false); + this.client = new DefaultAlipayClient(alipayConfig); + } + + @Override + public CommonResult unifiedOrder(PayOrderUnifiedReqDTO reqDTO) { + // 构建 AlipayTradeWapPayModel 请求 + AlipayTradeWapPayModel model = new AlipayTradeWapPayModel(); + model.setOutTradeNo(reqDTO.getMerchantOrderId()); + model.setSubject(reqDTO.getSubject()); + model.setBody(reqDTO.getBody()); + model.setTotalAmount(calculateAmount(reqDTO.getAmount()).toString()); + model.setProductCode("QUICK_WAP_PAY"); // TODO 芋艿:这里咋整 + model.setSellerId("2088102147948060"); // TODO 芋艿:这里咋整 + // TODO 芋艿:clientIp + expireTime + // 构建 AlipayTradeWapPayRequest + AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); + request.setBizModel(model); + + // 执行请求 + AlipayTradeWapPayResponse response; + try { + response = client.pageExecute(request); + } catch (AlipayApiException e) { + return PayCommonResult.build(e.getErrCode(), e.getErrMsg(), null, codeMapping); + } + + System.out.println(response.getBody()); + +// TODO 芋艿:sub Code + return PayCommonResult.build(response.getCode(), response.getMsg(), response, codeMapping); + } + + public static void main(String[] args) { + AlipayPayConfig config = new AlipayPayConfig(); + config.setAppId("2021000118634035"); + config.setServerUrl(AlipayPayConfig.SERVER_URL_SANDBOX); + config.setSignType(AlipayPayConfig.SIGN_TYPE_DEFAULT); + config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509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+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); + AlipayWapPayClient client = new AlipayWapPayClient(1L, "biubiubiu", config); + client.init(); + + PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO(); + reqDTO.setAmount(123); + reqDTO.setSubject("IPhone 13"); + reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); + client.unifiedOrder(reqDTO); + } + + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/index.html b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/index.html new file mode 100644 index 000000000..601a6b2cc --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/index.html @@ -0,0 +1 @@ +
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/SmsClientFactory.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/SmsClientFactory.java index d880b4ebd..338e83f52 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/SmsClientFactory.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/SmsClientFactory.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.framework.sms.core.client; import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties; /** - * 短信客户端工厂接口 + * 短信客户端的工厂接口 * * @author zzf * @date 2021/1/28 14:01 diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/AbstractSmsClient.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/AbstractSmsClient.java index 72a1e5271..0ef4869b4 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/AbstractSmsClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/AbstractSmsClient.java @@ -30,11 +30,6 @@ public abstract class AbstractSmsClient implements SmsClient { */ protected final SmsCodeMapping codeMapping; - /** - * 短信客户端有参构造函数 - * - * @param properties 短信配置 - */ public AbstractSmsClient(SmsChannelProperties properties, SmsCodeMapping codeMapping) { this.properties = properties; this.codeMapping = codeMapping; @@ -48,6 +43,11 @@ public abstract class AbstractSmsClient implements SmsClient { log.info("[init][配置({}) 初始化完成]", properties); } + /** + * 自定义初始化 + */ + protected abstract void doInit(); + public final void refresh(SmsChannelProperties properties) { // 判断是否更新 if (properties.equals(this.properties)) { @@ -59,11 +59,6 @@ public abstract class AbstractSmsClient implements SmsClient { this.init(); } - /** - * 自定义初始化 - */ - protected abstract void doInit(); - @Override public Long getId() { return properties.getId();