mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
code review:钱包的逻辑
This commit is contained in:
parent
0db4581030
commit
9697aee898
@ -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);
|
||||||
|
@ -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>
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -65,6 +65,7 @@ public class PayWalletController {
|
|||||||
MemberUserRespDTO::getId);
|
MemberUserRespDTO::getId);
|
||||||
pageVO.setUserIds(userIds);
|
pageVO.setUserIds(userIds);
|
||||||
}
|
}
|
||||||
|
// TODO @jason:管理员也可以先查询下。。
|
||||||
// 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景
|
// 暂时支持查询 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())) {
|
||||||
|
@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ import org.mapstruct.factory.Mappers;
|
|||||||
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);
|
||||||
|
@ -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());
|
||||||
}));
|
}));
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user