Commit 3368a995cabe56d19ffa4bbd6f110c67b4b35226
1 parent
e46a27b9
支付模块的 code review
Showing
14 changed files
with
99 additions
and
86 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayChannelCreateReqVO.java
| @@ -11,6 +11,8 @@ import lombok.ToString; | @@ -11,6 +11,8 @@ import lombok.ToString; | ||
| 11 | @ToString(callSuper = true) | 11 | @ToString(callSuper = true) |
| 12 | public class PayChannelCreateReqVO extends PayChannelBaseVO { | 12 | public class PayChannelCreateReqVO extends PayChannelBaseVO { |
| 13 | 13 | ||
| 14 | - | 14 | + // TODO @aquan:我在想,要不这个创建和修改特殊一点。前端传递 string 过来,后端解析成对应的。因为有 code,所以我们都知道是哪个配置类。 |
| 15 | + // 然后,在 PayChannelEnum 里,枚举每个渠道对应的配置类。另外,我们就不单独给配置类搞 vo 了。参数校验,通过手动调用 Validator 去校验。 | ||
| 16 | + // 通过这样的方式,VO 和 api 都收成,一个 update,一个 create | ||
| 15 | 17 | ||
| 16 | } | 18 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/controller/channel/vo/PayWechatChannelUpdateReqVO.java
| @@ -62,5 +62,7 @@ public class PayWechatChannelUpdateReqVO extends PayChannelBaseVO { | @@ -62,5 +62,7 @@ public class PayWechatChannelUpdateReqVO extends PayChannelBaseVO { | ||
| 62 | 62 | ||
| 63 | @ApiModelProperty(value = "apiclient_cert.pem 证书对应的字符串", required = true, example = "-----BEGIN CERTIFICATE-----") | 63 | @ApiModelProperty(value = "apiclient_cert.pem 证书对应的字符串", required = true, example = "-----BEGIN CERTIFICATE-----") |
| 64 | private String privateCertContent; | 64 | private String privateCertContent; |
| 65 | + | ||
| 66 | + // TODO @aquan:参数校验。可以使用 @AssertTrue,v2 和 v3 的 | ||
| 65 | } | 67 | } |
| 66 | } | 68 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/mysql/app/PayAppMapper.java
| 1 | package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app; | 1 | package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app; |
| 2 | 2 | ||
| 3 | -import java.util.*; | ||
| 4 | - | 3 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO; |
| 4 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO; | ||
| 5 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; | 5 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | ||
| 8 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | ||
| 9 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*; | 10 | + |
| 11 | +import java.util.Collection; | ||
| 12 | +import java.util.List; | ||
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| 13 | * 支付应用信息 Mapper | 15 | * 支付应用信息 Mapper |
| @@ -17,7 +19,7 @@ import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*; | @@ -17,7 +19,7 @@ import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*; | ||
| 17 | @Mapper | 19 | @Mapper |
| 18 | public interface PayAppMapper extends BaseMapperX<PayAppDO> { | 20 | public interface PayAppMapper extends BaseMapperX<PayAppDO> { |
| 19 | 21 | ||
| 20 | - default PageResult<PayAppDO> selectPage(PayAppPageReqVO reqVO,Collection<Long> merchantIds) { | 22 | + default PageResult<PayAppDO> selectPage(PayAppPageReqVO reqVO, Collection<Long> merchantIds) { |
| 21 | return selectPage(reqVO, new QueryWrapperX<PayAppDO>() | 23 | return selectPage(reqVO, new QueryWrapperX<PayAppDO>() |
| 22 | .likeIfPresent("name", reqVO.getName()) | 24 | .likeIfPresent("name", reqVO.getName()) |
| 23 | .eqIfPresent("status", reqVO.getStatus()) | 25 | .eqIfPresent("status", reqVO.getStatus()) |
| @@ -38,7 +40,7 @@ public interface PayAppMapper extends BaseMapperX<PayAppDO> { | @@ -38,7 +40,7 @@ public interface PayAppMapper extends BaseMapperX<PayAppDO> { | ||
| 38 | .eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl()) | 40 | .eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl()) |
| 39 | .eqIfPresent("merchant_id", reqVO.getMerchantId()) | 41 | .eqIfPresent("merchant_id", reqVO.getMerchantId()) |
| 40 | .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | 42 | .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) |
| 41 | - .orderByDesc("id") ); | 43 | + .orderByDesc("id")); |
| 42 | } | 44 | } |
| 43 | 45 | ||
| 44 | } | 46 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/app/impl/PayAppServiceImpl.java
| 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.app.impl; | 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.app.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateReqVO; | ||
| 8 | +import cn.iocoder.yudao.adminserver.modules.pay.convert.app.PayAppConvert; | ||
| 9 | +import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper; | ||
| 10 | +import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService; | ||
| 4 | import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService; | 11 | import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService; |
| 5 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; | 12 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; |
| 6 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; | 13 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; |
| 7 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 14 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 8 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 15 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | import com.google.common.annotations.VisibleForTesting; | 16 | import com.google.common.annotations.VisibleForTesting; |
| 10 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 11 | -import javax.annotation.Resource; | ||
| 12 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 13 | 19 | ||
| 14 | -import java.util.*; | ||
| 15 | -import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*; | ||
| 16 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 17 | - | ||
| 18 | -import cn.iocoder.yudao.adminserver.modules.pay.convert.app.PayAppConvert; | ||
| 19 | -import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper; | ||
| 20 | -import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService; | 20 | +import javax.annotation.Resource; |
| 21 | +import java.util.Collection; | ||
| 22 | +import java.util.Collections; | ||
| 23 | +import java.util.List; | ||
| 24 | +import java.util.Set; | ||
| 21 | 25 | ||
| 26 | +import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.APP_NOT_EXISTS; | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 27 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 23 | -import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; | 28 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 24 | 29 | ||
| 25 | /** | 30 | /** |
| 26 | * 支付应用信息 Service 实现类 | 31 | * 支付应用信息 Service 实现类 |
| @@ -84,7 +89,8 @@ public class PayAppServiceImpl implements PayAppService { | @@ -84,7 +89,8 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 84 | 89 | ||
| 85 | @Override | 90 | @Override |
| 86 | public PageResult<PayAppDO> getAppPage(PayAppPageReqVO pageReqVO) { | 91 | public PageResult<PayAppDO> getAppPage(PayAppPageReqVO pageReqVO) { |
| 87 | - return appMapper.selectPage(pageReqVO,this.getMerchantCondition(pageReqVO.getMerchantName())); | 92 | + // TODO @aquan:会有一个场景,merchantName 匹配不到商户编号的时候,应该返回没数据的 |
| 93 | + return appMapper.selectPage(pageReqVO, this.getMerchantCondition(pageReqVO.getMerchantName())); | ||
| 88 | } | 94 | } |
| 89 | 95 | ||
| 90 | @Override | 96 | @Override |
| @@ -94,6 +100,7 @@ public class PayAppServiceImpl implements PayAppService { | @@ -94,6 +100,7 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 94 | 100 | ||
| 95 | /** | 101 | /** |
| 96 | * 获取商户编号集合,根据商户名称模糊查询得到所有的商户编号集合 | 102 | * 获取商户编号集合,根据商户名称模糊查询得到所有的商户编号集合 |
| 103 | + * | ||
| 97 | * @param merchantName 商户名称 | 104 | * @param merchantName 商户名称 |
| 98 | * @return 商户编号集合 | 105 | * @return 商户编号集合 |
| 99 | */ | 106 | */ |
| @@ -101,7 +108,7 @@ public class PayAppServiceImpl implements PayAppService { | @@ -101,7 +108,7 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 101 | if (StrUtil.isBlank(merchantName)) { | 108 | if (StrUtil.isBlank(merchantName)) { |
| 102 | return Collections.emptySet(); | 109 | return Collections.emptySet(); |
| 103 | } | 110 | } |
| 104 | - return CollectionUtils.convertSet(merchantService.getMerchantListByName(merchantName), PayMerchantDO::getId); | 111 | + return convertSet(merchantService.getMerchantListByName(merchantName), PayMerchantDO::getId); |
| 105 | } | 112 | } |
| 106 | 113 | ||
| 107 | /** | 114 | /** |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/PayChannelService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.channel; | 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.channel; |
| 2 | 2 | ||
| 3 | -import java.util.*; | ||
| 4 | -import javax.validation.*; | ||
| 5 | - | ||
| 6 | import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; | 3 | import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; |
| 7 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; | 4 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; |
| 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | import org.springframework.web.multipart.MultipartFile; | 6 | import org.springframework.web.multipart.MultipartFile; |
| 10 | 7 | ||
| 8 | +import javax.validation.Valid; | ||
| 9 | +import java.util.Collection; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 11 | /** | 12 | /** |
| 12 | - * 支付渠道 | ||
| 13 | - * Service 接口 | 13 | + * 支付渠道 Service 接口 |
| 14 | * | 14 | * |
| 15 | - * @author 芋艿 | 15 | + * @author 芋艿 // TODO @aquan:作者不要我 |
| 16 | */ | 16 | */ |
| 17 | public interface PayChannelService { | 17 | public interface PayChannelService { |
| 18 | 18 | ||
| 19 | - | ||
| 20 | /** | 19 | /** |
| 21 | * 创建支付渠道 | 20 | * 创建支付渠道 |
| 22 | * | 21 | * |
| @@ -72,8 +71,7 @@ public interface PayChannelService { | @@ -72,8 +71,7 @@ public interface PayChannelService { | ||
| 72 | * 列表, 用于 Excel 导出 | 71 | * 列表, 用于 Excel 导出 |
| 73 | * | 72 | * |
| 74 | * @param exportReqVO 查询条件 | 73 | * @param exportReqVO 查询条件 |
| 75 | - * @return 支付渠道 | ||
| 76 | - * 列表 | 74 | + * @return 支付渠道列表 |
| 77 | */ | 75 | */ |
| 78 | List<PayChannelDO> getChannelList(PayChannelExportReqVO exportReqVO); | 76 | List<PayChannelDO> getChannelList(PayChannelExportReqVO exportReqVO); |
| 79 | 77 | ||
| @@ -83,6 +81,7 @@ public interface PayChannelService { | @@ -83,6 +81,7 @@ public interface PayChannelService { | ||
| 83 | * @param payIds 支付应用编号集合 | 81 | * @param payIds 支付应用编号集合 |
| 84 | * @return 支付渠道 | 82 | * @return 支付渠道 |
| 85 | */ | 83 | */ |
| 84 | + // TODO @aquan:暂时不用提供这种哈。之前提供的原因,是数据字典比较特殊。 | ||
| 86 | List<PayChannelDO> getSimpleChannels(Collection<Long> payIds); | 85 | List<PayChannelDO> getSimpleChannels(Collection<Long> payIds); |
| 87 | 86 | ||
| 88 | /** | 87 | /** |
| @@ -91,6 +90,7 @@ public interface PayChannelService { | @@ -91,6 +90,7 @@ public interface PayChannelService { | ||
| 91 | * @param file pem公私钥文件 | 90 | * @param file pem公私钥文件 |
| 92 | * @return 解析后的字符串 | 91 | * @return 解析后的字符串 |
| 93 | */ | 92 | */ |
| 93 | + // TODO @aquan:可以前端读取么? | ||
| 94 | String parsingPemFile(MultipartFile file); | 94 | String parsingPemFile(MultipartFile file); |
| 95 | 95 | ||
| 96 | /** | 96 | /** |
| @@ -99,6 +99,7 @@ public interface PayChannelService { | @@ -99,6 +99,7 @@ public interface PayChannelService { | ||
| 99 | * @param reqVO 创建信息 | 99 | * @param reqVO 创建信息 |
| 100 | * @return 创建结果 | 100 | * @return 创建结果 |
| 101 | */ | 101 | */ |
| 102 | + // TODO @aquan:pojo 如果要做参数校验,需要添加 @Valid | ||
| 102 | Long createWechatChannel(PayWechatChannelCreateReqVO reqVO); | 103 | Long createWechatChannel(PayWechatChannelCreateReqVO reqVO); |
| 103 | 104 | ||
| 104 | /** | 105 | /** |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/channel/impl/PayChannelServiceImpl.java
| 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl; | 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.io.IoUtil; | 3 | import cn.hutool.core.io.IoUtil; |
| 4 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.pay.convert.channel.PayChannelConvert; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.pay.service.channel.PayChannelService; | ||
| 4 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; | 8 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; |
| 5 | -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 9 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; | 10 | import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; |
| 7 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 11 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 8 | -import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 9 | -import com.fasterxml.jackson.databind.json.JsonMapper; | ||
| 10 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 11 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| 12 | - | ||
| 13 | -import javax.annotation.Resource; | ||
| 14 | - | ||
| 15 | -import org.springframework.util.Assert; | ||
| 16 | import org.springframework.validation.annotation.Validated; | 14 | import org.springframework.validation.annotation.Validated; |
| 17 | - | ||
| 18 | -import java.io.IOException; | ||
| 19 | -import java.util.*; | ||
| 20 | - | ||
| 21 | -import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; | ||
| 22 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 23 | - | ||
| 24 | -import cn.iocoder.yudao.adminserver.modules.pay.convert.channel.PayChannelConvert; | ||
| 25 | -import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper; | ||
| 26 | -import cn.iocoder.yudao.adminserver.modules.pay.service.channel.PayChannelService; | ||
| 27 | import org.springframework.web.multipart.MultipartFile; | 15 | import org.springframework.web.multipart.MultipartFile; |
| 28 | 16 | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | +import java.io.IOException; | ||
| 19 | +import java.util.Collection; | ||
| 20 | +import java.util.List; | ||
| 29 | 21 | ||
| 30 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 31 | import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; | 22 | import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; |
| 23 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 32 | 24 | ||
| 33 | /** | 25 | /** |
| 34 | - * 支付渠道 | ||
| 35 | - * Service 实现类 | 26 | + * 支付渠道 Service 实现类 |
| 36 | * | 27 | * |
| 37 | - * @author 芋艿 | 28 | + * @author 芋艿 // TODO aquan:作者写自己哈 |
| 38 | */ | 29 | */ |
| 39 | -@Slf4j | ||
| 40 | @Service | 30 | @Service |
| 31 | +@Slf4j | ||
| 41 | @Validated | 32 | @Validated |
| 42 | public class PayChannelServiceImpl implements PayChannelService { | 33 | public class PayChannelServiceImpl implements PayChannelService { |
| 43 | 34 | ||
| @@ -162,6 +153,7 @@ public class PayChannelServiceImpl implements PayChannelService { | @@ -162,6 +153,7 @@ public class PayChannelServiceImpl implements PayChannelService { | ||
| 162 | ); | 153 | ); |
| 163 | } | 154 | } |
| 164 | 155 | ||
| 156 | + // TODO @aquan:service 不出现 mybatis plus 哈 | ||
| 165 | /** | 157 | /** |
| 166 | * 根据条件获取通道 | 158 | * 根据条件获取通道 |
| 167 | * | 159 | * |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/PayMerchantService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.merchant; | 1 | package cn.iocoder.yudao.adminserver.modules.pay.service.merchant; |
| 2 | 2 | ||
| 3 | -import java.util.*; | ||
| 4 | -import javax.validation.*; | ||
| 5 | - | ||
| 6 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.*; | ||
| 8 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; | 4 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantCreateReqVO; |
| 5 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantExportReqVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantUpdateReqVO; | ||
| 9 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; | 8 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; |
| 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 11 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 12 | 11 | ||
| 12 | +import javax.validation.Valid; | ||
| 13 | +import java.util.Collection; | ||
| 14 | +import java.util.Collections; | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.Map; | ||
| 17 | + | ||
| 13 | /** | 18 | /** |
| 14 | * 支付商户信息 Service 接口 | 19 | * 支付商户信息 Service 接口 |
| 15 | * | 20 | * |
| @@ -87,6 +92,7 @@ public interface PayMerchantService { | @@ -87,6 +92,7 @@ public interface PayMerchantService { | ||
| 87 | */ | 92 | */ |
| 88 | List<PayMerchantDO> getMerchantListByName(String merchantName); | 93 | List<PayMerchantDO> getMerchantListByName(String merchantName); |
| 89 | 94 | ||
| 95 | + // TODO aquan:暂时不用提供这样的检索。商户不多的。 | ||
| 90 | /** | 96 | /** |
| 91 | * 根据商户名称模糊查询一定数量的商户集合 | 97 | * 根据商户名称模糊查询一定数量的商户集合 |
| 92 | * @param merchantName 商户名称 | 98 | * @param merchantName 商户名称 |
| @@ -100,6 +106,7 @@ public interface PayMerchantService { | @@ -100,6 +106,7 @@ public interface PayMerchantService { | ||
| 100 | * @param merchantIds 商户编号数组 | 106 | * @param merchantIds 商户编号数组 |
| 101 | * @return 商户列表 | 107 | * @return 商户列表 |
| 102 | */ | 108 | */ |
| 109 | + // TODO @aquan:和 getMerchantList 重复了 | ||
| 103 | List<PayMerchantDO> getSimpleMerchants(Collection<Long> merchantIds); | 110 | List<PayMerchantDO> getSimpleMerchants(Collection<Long> merchantIds); |
| 104 | 111 | ||
| 105 | /** | 112 | /** |
| @@ -108,11 +115,13 @@ public interface PayMerchantService { | @@ -108,11 +115,13 @@ public interface PayMerchantService { | ||
| 108 | * @param merchantIds 商户编号数组 | 115 | * @param merchantIds 商户编号数组 |
| 109 | * @return 商户 Map | 116 | * @return 商户 Map |
| 110 | */ | 117 | */ |
| 111 | - default Map<Long, PayMerchantDO> getMerchantMap(Collection<Long> merchantIds){ | 118 | + default Map<Long, PayMerchantDO> getMerchantMap(Collection<Long> merchantIds) { |
| 119 | + // TODO @aquan:可以不用判空,交给 getMerchantList 解决 | ||
| 112 | if (CollUtil.isEmpty(merchantIds)) { | 120 | if (CollUtil.isEmpty(merchantIds)) { |
| 113 | return Collections.emptyMap(); | 121 | return Collections.emptyMap(); |
| 114 | } | 122 | } |
| 115 | List<PayMerchantDO> list = getSimpleMerchants(merchantIds); | 123 | List<PayMerchantDO> list = getSimpleMerchants(merchantIds); |
| 116 | return CollectionUtils.convertMap(list, PayMerchantDO::getId); | 124 | return CollectionUtils.convertMap(list, PayMerchantDO::getId); |
| 117 | } | 125 | } |
| 126 | + | ||
| 118 | } | 127 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/service/merchant/impl/PayMerchantServiceImpl.java
| @@ -113,6 +113,7 @@ public class PayMerchantServiceImpl implements PayMerchantService { | @@ -113,6 +113,7 @@ public class PayMerchantServiceImpl implements PayMerchantService { | ||
| 113 | */ | 113 | */ |
| 114 | @Override | 114 | @Override |
| 115 | public List<PayMerchantDO> getMerchantListByName(String merchantName) { | 115 | public List<PayMerchantDO> getMerchantListByName(String merchantName) { |
| 116 | + // TODO @aquan:Service 层,不要出现 mybatis plus 的代码,要放到 mapper 里提供。技术与业务分离,原则上 | ||
| 116 | return this.merchantMapper.selectList(new QueryWrapper<PayMerchantDO>() | 117 | return this.merchantMapper.selectList(new QueryWrapper<PayMerchantDO>() |
| 117 | .lambda().likeRight(PayMerchantDO::getName, merchantName)); | 118 | .lambda().likeRight(PayMerchantDO::getName, merchantName)); |
| 118 | } | 119 | } |
| @@ -160,6 +161,7 @@ public class PayMerchantServiceImpl implements PayMerchantService { | @@ -160,6 +161,7 @@ public class PayMerchantServiceImpl implements PayMerchantService { | ||
| 160 | return merchantMapper.selectBatchIds(merchantIds); | 161 | return merchantMapper.selectBatchIds(merchantIds); |
| 161 | } | 162 | } |
| 162 | 163 | ||
| 164 | + // TODO @芋艿:后续增加下合适的算法 | ||
| 163 | /** | 165 | /** |
| 164 | * 根据年月日时分秒毫秒生成商户号 | 166 | * 根据年月日时分秒毫秒生成商户号 |
| 165 | * @return 商户号 | 167 | * @return 商户号 |
| @@ -168,5 +170,4 @@ public class PayMerchantServiceImpl implements PayMerchantService { | @@ -168,5 +170,4 @@ public class PayMerchantServiceImpl implements PayMerchantService { | ||
| 168 | return "M" + DateUtil.format(LocalDateTime.now(),"yyyyMMddHHmmssSSS"); | 170 | return "M" + DateUtil.format(LocalDateTime.now(),"yyyyMMddHHmmssSSS"); |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 171 | - | ||
| 172 | } | 173 | } |
yudao-admin-server/src/main/resources/application.yaml
| @@ -61,5 +61,5 @@ yudao: | @@ -61,5 +61,5 @@ yudao: | ||
| 61 | - cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants | 61 | - cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants |
| 62 | - cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants | 62 | - cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants |
| 63 | pay: | 63 | pay: |
| 64 | - payReturnUrl: http://127.0.0.1 | 64 | + payReturnUrl: http://127.0.0.1 # TODO @aquan:这个变量,配置到 dev 或者 local 里,不同环境有差别哈 |
| 65 | debug: false | 65 | debug: false |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/app/service/PayAppServiceTest.java
| 1 | package cn.iocoder.yudao.adminserver.modules.pay.app.service; | 1 | package cn.iocoder.yudao.adminserver.modules.pay.app.service; |
| 2 | 2 | ||
| 3 | -import javax.annotation.Resource; | ||
| 4 | - | ||
| 5 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 6 | import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO; |
| @@ -10,22 +8,21 @@ import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateRe | @@ -10,22 +8,21 @@ import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateRe | ||
| 10 | import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper; | 8 | import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper; |
| 11 | import cn.iocoder.yudao.adminserver.modules.pay.service.app.impl.PayAppServiceImpl; | 9 | import cn.iocoder.yudao.adminserver.modules.pay.service.app.impl.PayAppServiceImpl; |
| 12 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; | 10 | import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; |
| 13 | -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | ||
| 14 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 11 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 15 | - | 12 | +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 16 | import org.junit.jupiter.api.Test; | 13 | import org.junit.jupiter.api.Test; |
| 17 | import org.springframework.context.annotation.Import; | 14 | import org.springframework.context.annotation.Import; |
| 18 | -import java.util.*; | ||
| 19 | 15 | ||
| 20 | -import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; | 16 | +import javax.annotation.Resource; |
| 17 | +import java.util.List; | ||
| 18 | + | ||
| 19 | +import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.APP_NOT_EXISTS; | ||
| 21 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 20 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 22 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 21 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 23 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 24 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | 22 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; |
| 23 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 25 | import static org.junit.jupiter.api.Assertions.*; | 24 | import static org.junit.jupiter.api.Assertions.*; |
| 26 | 25 | ||
| 27 | -import static org.mockito.Mockito.*; | ||
| 28 | - | ||
| 29 | /** | 26 | /** |
| 30 | * {@link PayAppServiceImpl} 的单元测试类 | 27 | * {@link PayAppServiceImpl} 的单元测试类 |
| 31 | * | 28 | * |
| @@ -148,7 +145,7 @@ public class PayAppServiceTest extends BaseDbUnitTest { | @@ -148,7 +145,7 @@ public class PayAppServiceTest extends BaseDbUnitTest { | ||
| 148 | assertPojoEquals(dbApp, pageResult.getList().get(0)); | 145 | assertPojoEquals(dbApp, pageResult.getList().get(0)); |
| 149 | } | 146 | } |
| 150 | 147 | ||
| 151 | - @Test // TODO 请修改 null 为需要的值 | 148 | + @Test // TODO aquan:请修改 null 为需要的值 |
| 152 | public void testGetAppList() { | 149 | public void testGetAppList() { |
| 153 | // mock 数据 | 150 | // mock 数据 |
| 154 | PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 | 151 | PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/channel/PayChannelServiceTest.java
| 1 | package cn.iocoder.yudao.adminserver.modules.pay.channel; | 1 | package cn.iocoder.yudao.adminserver.modules.pay.channel; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; | ||
| 4 | -import org.junit.jupiter.api.Test; | ||
| 5 | - | ||
| 6 | -import javax.annotation.Resource; | ||
| 7 | - | ||
| 8 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 9 | -import cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl.PayChannelServiceImpl; | ||
| 10 | -import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*; | 4 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelCreateReqVO; |
| 5 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelExportReqVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelUpdateReqVO; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper; | 8 | import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper; |
| 12 | -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 9 | +import cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl.PayChannelServiceImpl; |
| 10 | +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; | ||
| 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 11 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 14 | - | 12 | +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 15 | import org.junit.jupiter.api.Test; | 13 | import org.junit.jupiter.api.Test; |
| 16 | import org.springframework.context.annotation.Import; | 14 | import org.springframework.context.annotation.Import; |
| 17 | -import java.util.*; | ||
| 18 | 15 | ||
| 19 | -import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; | 16 | +import javax.annotation.Resource; |
| 17 | +import java.util.List; | ||
| 18 | + | ||
| 19 | +import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.CHANNEL_NOT_EXISTS; | ||
| 20 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 20 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 21 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 21 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 22 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 23 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | 22 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; |
| 23 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 24 | import static org.junit.jupiter.api.Assertions.*; | 24 | import static org.junit.jupiter.api.Assertions.*; |
| 25 | 25 | ||
| 26 | -import static org.mockito.Mockito.*; | ||
| 27 | - | ||
| 28 | /** | 26 | /** |
| 29 | * {@link PayChannelServiceImpl} 的单元测试类 | 27 | * {@link PayChannelServiceImpl} 的单元测试类 |
| 30 | * | 28 | * |
| @@ -152,7 +150,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { | @@ -152,7 +150,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { | ||
| 152 | assertPojoEquals(dbChannel, pageResult.getList().get(0)); | 150 | assertPojoEquals(dbChannel, pageResult.getList().get(0)); |
| 153 | } | 151 | } |
| 154 | 152 | ||
| 155 | - @Test // TODO 请修改 null 为需要的值 | 153 | + @Test // TODO aquan:请修改 null 为需要的值 |
| 156 | public void testGetChannelList() { | 154 | public void testGetChannelList() { |
| 157 | // mock 数据 | 155 | // mock 数据 |
| 158 | PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { // 等会查询到 | 156 | PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { // 等会查询到 |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeCoreConstants.java
| @@ -45,5 +45,7 @@ public interface PayErrorCodeCoreConstants { | @@ -45,5 +45,7 @@ public interface PayErrorCodeCoreConstants { | ||
| 45 | */ | 45 | */ |
| 46 | ErrorCode CHANNEL_NOT_EXISTS = new ErrorCode(1007006000, "支付渠道不存在"); | 46 | ErrorCode CHANNEL_NOT_EXISTS = new ErrorCode(1007006000, "支付渠道不存在"); |
| 47 | ErrorCode CHANNEL_KEY_READ_ERROR = new ErrorCode(1007006002, "支付渠道秘钥文件读取失败"); | 47 | ErrorCode CHANNEL_KEY_READ_ERROR = new ErrorCode(1007006002, "支付渠道秘钥文件读取失败"); |
| 48 | + // TODO @aquan:下面这个错误码,缺了 CHANNEL 前缀。另外,错误码的分段,上面有啦,合并下进去哈 | ||
| 48 | ErrorCode EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1007006003, "已存在相同的渠道"); | 49 | ErrorCode EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1007006003, "已存在相同的渠道"); |
| 50 | + | ||
| 49 | } | 51 | } |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java
| @@ -16,6 +16,7 @@ public enum PayChannelEnum { | @@ -16,6 +16,7 @@ public enum PayChannelEnum { | ||
| 16 | 16 | ||
| 17 | WX_PUB("wx_pub", "微信 JSAPI 支付"), // 公众号的网页 | 17 | WX_PUB("wx_pub", "微信 JSAPI 支付"), // 公众号的网页 |
| 18 | // TODO @芋艿 这个地方你写的是 wx_lit 是不是少写了一个e? 还是我这里多加了一个e | 18 | // TODO @芋艿 这个地方你写的是 wx_lit 是不是少写了一个e? 还是我这里多加了一个e |
| 19 | + // TODO @aquan:这里就是 lite 哈,轻量 | ||
| 19 | WX_LITE("wx_lite","微信小程序支付"), | 20 | WX_LITE("wx_lite","微信小程序支付"), |
| 20 | WX_APP("wx_app", "微信 App 支付"), | 21 | WX_APP("wx_app", "微信 App 支付"), |
| 21 | 22 |