mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +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 执行请求
|
||||
AlipayTradeRefundResponse response;
|
||||
if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) {
|
||||
// 证书模式
|
||||
if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式
|
||||
response = client.certificateExecute(request);
|
||||
} else {
|
||||
response = client.execute(request);
|
||||
@ -203,8 +202,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
|
||||
|
||||
// 2.1 执行请求
|
||||
AlipayTradeFastpayRefundQueryResponse response;
|
||||
if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) {
|
||||
// 证书模式
|
||||
if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式
|
||||
response = client.certificateExecute(request);
|
||||
} else {
|
||||
response = client.execute(request);
|
||||
|
@ -23,12 +23,12 @@
|
||||
<artifactId>yudao-module-pay-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-member-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
|
@ -15,6 +15,7 @@ import javax.annotation.Resource;
|
||||
@Service
|
||||
@Validated
|
||||
public class PayTransferApiImpl implements PayTransferApi {
|
||||
|
||||
@Resource
|
||||
private PayTransferService payTransferService;
|
||||
|
||||
@ -22,4 +23,5 @@ public class PayTransferApiImpl implements PayTransferApi {
|
||||
public Long createTransfer(PayTransferCreateReqDTO reqDTO) {
|
||||
return payTransferService.createTransfer(reqDTO);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,7 +65,8 @@ public class PayWalletController {
|
||||
MemberUserRespDTO::getId);
|
||||
pageVO.setUserIds(userIds);
|
||||
}
|
||||
// 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景
|
||||
// TODO @jason:管理员也可以先查询下。。
|
||||
// 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景
|
||||
PageResult<PayWalletDO> pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO);
|
||||
if (CollectionUtil.isEmpty(pageResult.getList())) {
|
||||
return success(new PageResult<>(pageResult.getTotal()));
|
||||
|
@ -19,10 +19,9 @@ public class PayWalletRespVO extends PayWalletBaseVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "用户昵称")
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户头像")
|
||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg")
|
||||
private String avatar;
|
||||
|
||||
}
|
||||
|
@ -12,4 +12,5 @@ public class PayWalletUserReqVO {
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,9 @@ import org.mapstruct.factory.Mappers;
|
||||
@Mapper
|
||||
public interface PayTransferConvert {
|
||||
|
||||
PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class);
|
||||
@Mapping(source = "title", target = "subject")
|
||||
PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class);
|
||||
|
||||
@Mapping(source = "title", target = "subject") // TODO @jason:是不是都改成 subject 完事呀?
|
||||
PayTransferDO convert(PayTransferCreateReqDTO dto);
|
||||
|
||||
PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo);
|
||||
|
@ -26,6 +26,7 @@ public interface PayWalletConvert {
|
||||
PageResult<PayWalletRespVO> pageResult = convertPage(page);
|
||||
pageResult.getList().forEach( wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(),
|
||||
user -> {
|
||||
// TODO @jason:可以链式调用哈;
|
||||
wallet.setNickname(user.getNickname());
|
||||
wallet.setAvatar(user.getAvatar());
|
||||
}));
|
||||
|
@ -11,7 +11,8 @@ import lombok.Data;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO @jason:转账是不是类似 refund,不用拓展单呀?支付做拓展单的原因,是因为它存在不确定性,可以切换多种;转账和退款,都是明确方式的;
|
||||
// @芋艿 转账是不是也存在多种方式。 例如转账到银行卡。 可以使用微信,也可以使用支付宝。 支付宝账号余额不够,可以切换到微信
|
||||
// @芋艿 转账是不是也存在多种方式。 例如转账到银行卡。 可以使用微信,也可以使用支付宝。 支付宝账号余额不够,可以切换到微信;
|
||||
// TODO @jason:发起了,就不允许调整了,类似退款哈;
|
||||
/**
|
||||
* 转账拓展单 DO
|
||||
*
|
||||
@ -64,4 +65,4 @@ public class PayTransferExtensionDO extends BaseDO {
|
||||
*/
|
||||
private String channelNotifyData;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ public interface PayWalletRechargePackageMapper extends BaseMapperX<PayWalletRec
|
||||
.orderByDesc(PayWalletRechargePackageDO::getPayPrice));
|
||||
}
|
||||
|
||||
// TODO @jason:这里要有空格哈;String name) {
|
||||
default PayWalletRechargePackageDO selectByName(String name){
|
||||
return selectOne(PayWalletRechargePackageDO::getName, name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -218,6 +218,7 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||
PayChannelEnum payChannel = PayChannelEnum.getByCode(channelCode);
|
||||
switch (transferType) {
|
||||
case ALIPAY_BALANCE: {
|
||||
// TODO @jason:可以抽到 PayChannelEnum 里,isAlipay? 类似这种哈
|
||||
if (!payChannel.getCode().startsWith("alipay")) {
|
||||
throw exception(PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
|
||||
public Long createWalletRechargePackage(WalletRechargePackageCreateReqVO createReqVO) {
|
||||
// 校验套餐名是否唯一
|
||||
validateRechargePackageNameUnique(null, createReqVO.getName());
|
||||
|
||||
// 插入
|
||||
PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO);
|
||||
walletRechargePackageMapper.insert(walletRechargePackage);
|
||||
@ -61,6 +62,7 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
|
||||
validateWalletRechargePackageExists(updateReqVO.getId());
|
||||
// 校验套餐名是否唯一
|
||||
validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName());
|
||||
|
||||
// 更新
|
||||
PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO);
|
||||
walletRechargePackageMapper.updateById(updateObj);
|
||||
|
Loading…
Reference in New Issue
Block a user