code review:钱包的逻辑

This commit is contained in:
YunaiV 2023-10-21 21:17:49 +08:00
parent 0db4581030
commit 9697aee898
12 changed files with 24 additions and 15 deletions

View File

@ -160,8 +160,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
// 2.1 执行请求 // 2.1 执行请求
AlipayTradeRefundResponse response; AlipayTradeRefundResponse response;
if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式
// 证书模式
response = client.certificateExecute(request); response = client.certificateExecute(request);
} else { } else {
response = client.execute(request); response = client.execute(request);
@ -203,8 +202,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
// 2.1 执行请求 // 2.1 执行请求
AlipayTradeFastpayRefundQueryResponse response; AlipayTradeFastpayRefundQueryResponse response;
if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式
// 证书模式
response = client.certificateExecute(request); response = client.certificateExecute(request);
} else { } else {
response = client.execute(request); response = client.execute(request);

View File

@ -23,12 +23,12 @@
<artifactId>yudao-module-pay-api</artifactId> <artifactId>yudao-module-pay-api</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-member-api</artifactId> <artifactId>yudao-module-member-api</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<!-- 业务组件 --> <!-- 业务组件 -->
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>

View File

@ -15,6 +15,7 @@ import javax.annotation.Resource;
@Service @Service
@Validated @Validated
public class PayTransferApiImpl implements PayTransferApi { public class PayTransferApiImpl implements PayTransferApi {
@Resource @Resource
private PayTransferService payTransferService; private PayTransferService payTransferService;
@ -22,4 +23,5 @@ public class PayTransferApiImpl implements PayTransferApi {
public Long createTransfer(PayTransferCreateReqDTO reqDTO) { public Long createTransfer(PayTransferCreateReqDTO reqDTO) {
return payTransferService.createTransfer(reqDTO); return payTransferService.createTransfer(reqDTO);
} }
}
}

View File

@ -65,7 +65,8 @@ public class PayWalletController {
MemberUserRespDTO::getId); MemberUserRespDTO::getId);
pageVO.setUserIds(userIds); pageVO.setUserIds(userIds);
} }
// 暂时支持查询 userType 会员类型管理员类型还不知道使用场景 // TODO @jason管理员也可以先查询下
// 暂时支持查询 userType 会员类型管理员类型还不知道使用场景
PageResult<PayWalletDO> pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO); PageResult<PayWalletDO> pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO);
if (CollectionUtil.isEmpty(pageResult.getList())) { if (CollectionUtil.isEmpty(pageResult.getList())) {
return success(new PageResult<>(pageResult.getTotal())); return success(new PageResult<>(pageResult.getTotal()));

View File

@ -19,10 +19,9 @@ public class PayWalletRespVO extends PayWalletBaseVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "用户昵称") @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**")
private String nickname; private String nickname;
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg")
@Schema(description = "用户头像")
private String avatar; private String avatar;
} }

View File

@ -12,4 +12,5 @@ public class PayWalletUserReqVO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "用户编号不能为空") @NotNull(message = "用户编号不能为空")
private Long userId; private Long userId;
} }

View File

@ -10,8 +10,9 @@ import org.mapstruct.factory.Mappers;
@Mapper @Mapper
public interface PayTransferConvert { public interface PayTransferConvert {
PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class); PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class);
@Mapping(source = "title", target = "subject")
@Mapping(source = "title", target = "subject") // TODO @jason是不是都改成 subject 完事呀
PayTransferDO convert(PayTransferCreateReqDTO dto); PayTransferDO convert(PayTransferCreateReqDTO dto);
PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo); PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo);

View File

@ -26,6 +26,7 @@ public interface PayWalletConvert {
PageResult<PayWalletRespVO> pageResult = convertPage(page); PageResult<PayWalletRespVO> pageResult = convertPage(page);
pageResult.getList().forEach( wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(), pageResult.getList().forEach( wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(),
user -> { user -> {
// TODO @jason可以链式调用哈
wallet.setNickname(user.getNickname()); wallet.setNickname(user.getNickname());
wallet.setAvatar(user.getAvatar()); wallet.setAvatar(user.getAvatar());
})); }));

View File

@ -11,7 +11,8 @@ import lombok.Data;
import java.util.Map; import java.util.Map;
// TODO @jason转账是不是类似 refund不用拓展单呀支付做拓展单的原因是因为它存在不确定性可以切换多种转账和退款都是明确方式的 // TODO @jason转账是不是类似 refund不用拓展单呀支付做拓展单的原因是因为它存在不确定性可以切换多种转账和退款都是明确方式的
// @芋艿 转账是不是也存在多种方式 例如转账到银行卡 可以使用微信也可以使用支付宝 支付宝账号余额不够可以切换到微信 // @芋艿 转账是不是也存在多种方式 例如转账到银行卡 可以使用微信也可以使用支付宝 支付宝账号余额不够可以切换到微信
// TODO @jason发起了就不允许调整了类似退款哈
/** /**
* 转账拓展单 DO * 转账拓展单 DO
* *
@ -64,4 +65,4 @@ public class PayTransferExtensionDO extends BaseDO {
*/ */
private String channelNotifyData; private String channelNotifyData;
} }

View File

@ -19,7 +19,9 @@ public interface PayWalletRechargePackageMapper extends BaseMapperX<PayWalletRec
.orderByDesc(PayWalletRechargePackageDO::getPayPrice)); .orderByDesc(PayWalletRechargePackageDO::getPayPrice));
} }
// TODO @jason这里要有空格哈String name) {
default PayWalletRechargePackageDO selectByName(String name){ default PayWalletRechargePackageDO selectByName(String name){
return selectOne(PayWalletRechargePackageDO::getName, name); return selectOne(PayWalletRechargePackageDO::getName, name);
} }
}
}

View File

@ -218,6 +218,7 @@ public class PayTransferServiceImpl implements PayTransferService {
PayChannelEnum payChannel = PayChannelEnum.getByCode(channelCode); PayChannelEnum payChannel = PayChannelEnum.getByCode(channelCode);
switch (transferType) { switch (transferType) {
case ALIPAY_BALANCE: { case ALIPAY_BALANCE: {
// TODO @jason可以抽到 PayChannelEnum isAlipay 类似这种哈
if (!payChannel.getCode().startsWith("alipay")) { if (!payChannel.getCode().startsWith("alipay")) {
throw exception(PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH); throw exception(PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH);
} }

View File

@ -48,6 +48,7 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
public Long createWalletRechargePackage(WalletRechargePackageCreateReqVO createReqVO) { public Long createWalletRechargePackage(WalletRechargePackageCreateReqVO createReqVO) {
// 校验套餐名是否唯一 // 校验套餐名是否唯一
validateRechargePackageNameUnique(null, createReqVO.getName()); validateRechargePackageNameUnique(null, createReqVO.getName());
// 插入 // 插入
PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO); PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO);
walletRechargePackageMapper.insert(walletRechargePackage); walletRechargePackageMapper.insert(walletRechargePackage);
@ -61,6 +62,7 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
validateWalletRechargePackageExists(updateReqVO.getId()); validateWalletRechargePackageExists(updateReqVO.getId());
// 校验套餐名是否唯一 // 校验套餐名是否唯一
validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName()); validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName());
// 更新 // 更新
PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO); PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO);
walletRechargePackageMapper.updateById(updateObj); walletRechargePackageMapper.updateById(updateObj);