diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/merchant/PayMerchantMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/merchant/PayMerchantMapper.java index f20572509..0afb88f4b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/merchant/PayMerchantMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/merchant/PayMerchantMapper.java @@ -1,14 +1,15 @@ package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant; -import java.util.*; - +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantExportReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantPageReqVO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.*; + +import java.util.List; /** * 支付商户信息 Mapper @@ -47,6 +48,7 @@ public interface PayMerchantMapper extends BaseMapperX { * @return 商户集合 */ default List getMerchantListByName(String merchantName) { + // TODO @aquan:全模糊匹配,暂时不考虑索引的事;另外,可以直接 new Lambada 的 QueryWrapper 实现类呀 return this.selectList(new QueryWrapper() .lambda().likeRight(PayMerchantDO::getName, merchantName)); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java index 227292493..2249f0a73 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java @@ -1,31 +1,28 @@ package cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelExportReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelPageReqVO; +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelUpdateReqVO; import cn.iocoder.yudao.adminserver.modules.pay.convert.channel.PayChannelConvert; import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper; import cn.iocoder.yudao.adminserver.modules.pay.service.channel.PayChannelService; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.Assert; import org.springframework.validation.annotation.Validated; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Set; @@ -49,16 +46,16 @@ public class PayChannelServiceImpl implements PayChannelService { @Override public Long createChannel(PayChannelCreateReqVO reqVO) { - + // TODO @aquan:感觉获得那一条比较合适。因为是有唯一性的。注释有错别字哈。 // 判断是否有重复的有责无法新增 Integer channelCount = this.getChannelCountByConditions(reqVO.getMerchantId(), reqVO.getAppId(), reqVO.getCode()); if (channelCount > 0) { throw exception(CHANNEL_EXIST_SAME_CHANNEL_ERROR); } + // 新增渠道 PayChannelDO channel = PayChannelConvert.INSTANCE.convert(reqVO); settingConfigAndCheckParam(channel, reqVO.getConfig()); - channelMapper.insert(channel); return channel.getId(); } @@ -170,16 +167,17 @@ public class PayChannelServiceImpl implements PayChannelService { * @param configStr 配置 */ private void settingConfigAndCheckParam(PayChannelDO channel, String configStr) { - // 得到这个渠道是微信的还是支付宝的 String channelType = PayChannelEnum.verifyWechatOrAliPay(channel.getCode()); Assert.notNull(channelType, CHANNEL_NOT_EXISTS.getMsg()); // 进行验证 + // TODO @阿全:Spring 可以注入 Validator 哈 ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); Validator validator = validatorFactory.getValidator(); // 微信的验证 + // TODO @aquan:这么实现,可扩性不好。@AssertTrue 注解。 if (PayChannelEnum.WECHAT.equals(channelType)) { WXPayClientConfig config = JSON.parseObject(configStr, WXPayClientConfig.class); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java index e37f6f9d3..2f76dc526 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java @@ -124,7 +124,7 @@ public class PayMerchantServiceImpl implements PayMerchantService { */ @Override public List getMerchantListByNameLimit(String merchantName) { - + // TODO @aquan:mybatis plus 哈 LambdaQueryWrapper queryWrapper = new QueryWrapper().lambda() .select(PayMerchantDO::getId, PayMerchantDO::getName) .likeRight(PayMerchantDO::getName, merchantName) diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelServiceTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelServiceTest.java index a92860d7c..588c640ab 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelServiceTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelServiceTest.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import javax.validation.Validator; import java.util.List; import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.CHANNEL_NOT_EXISTS; @@ -70,7 +69,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { @Test public void testCreateWechatVersion3Channel_success() { - // 准备参数 + // 准备参数 TODO @aquan:多余的空行去掉哈。例如说 74 行。 WXPayClientConfig v3Config = getV3Config(); PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { diff --git a/yudao-admin-server/src/test/resources/sql/create_tables.sql b/yudao-admin-server/src/test/resources/sql/create_tables.sql index 60b6fa47a..5abf697ab 100644 --- a/yudao-admin-server/src/test/resources/sql/create_tables.sql +++ b/yudao-admin-server/src/test/resources/sql/create_tables.sql @@ -479,7 +479,7 @@ CREATE TABLE IF NOT EXISTS "pay_app" ( "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit(1) NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") -) COMMENT = '支付应用信息'; +) COMMENT = '支付应用信息'; CREATE TABLE "pay_channel" ( "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, @@ -496,5 +496,5 @@ CREATE TABLE "pay_channel" ( "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit(1) NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") -)COMMENT = '支付渠道'; +) COMMENT = '支付渠道'; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java index 9369a1512..d2796e36a 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java @@ -27,6 +27,7 @@ public interface PayErrorCodeCoreConstants { ErrorCode CHANNEL_WECHAT_VERSION_2_MCH_KEY_IS_NULL = new ErrorCode(1007001006,"微信渠道v2版本中商户密钥不可为空"); ErrorCode CHANNEL_WECHAT_VERSION_3_PRIVATE_KEY_IS_NULL = new ErrorCode(1007001006,"微信渠道v3版本apiclient_key.pem不可为空"); ErrorCode CHANNEL_WECHAT_VERSION_3_CERT_KEY_IS_NULL = new ErrorCode(1007001006,"微信渠道v3版本中apiclient_cert.pem不可为空"); + /** * ========== ORDER 模块 1-007-002-000 ========== */ @@ -48,6 +49,8 @@ public interface PayErrorCodeCoreConstants { ErrorCode PAY_REFUND_CHN_ORDER_NO_IS_NULL = new ErrorCode(1007006002, "该订单的渠道订单为空"); ErrorCode PAY_REFUND_POST_HANDLER_NOT_FOUND = new ErrorCode(1007006002, "未找到对应的退款后置处理类"); + // TODO @aquan:下面还两个要合并上去哈。另外一般中英文之间要有空格。例如说, 新建一个 order 数据;这样可读性更好。 + /** * ========== 支付商户信息 1-007-004-000 ========== */ diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java index 349776326..a2e2965b5 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java @@ -10,6 +10,8 @@ import java.io.FileNotFoundException; // TODO 芋艿:参数校验 +// TODO @aquan: 不要全文件格式化哈,去掉下

看着不太友好哈 + /** * 微信支付的 PayClientConfig 实现类 * 属性主要来自 {@link com.github.binarywang.wxpay.config.WxPayConfig} 的必要属性 @@ -71,6 +73,7 @@ public class WXPayClientConfig implements PayClientConfig { *

* 注意,可通过 {@link #main(String[])} 读取 */ + // TODO @aquan:对于只有一个值的时候,直接 groups = V3.class 即可,简洁。例如说,我们在 Spring MVC 注解,url 可以多个,也只写单个,一个道理哈 @NotBlank(message = "apiclient_key 不能为空", groups = {V3.class}) private String privateKeyContent; /**