Commit cd101ec7fc876e6b62b289b9603d260896ef9bd6

Authored by YunaiV
1 parent d2c7ec24

【功能新增】支付:钱包余额,支持 userId 过滤

yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java
1 1 package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction;
2 2  
  3 +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
3 4 import cn.iocoder.yudao.framework.common.pojo.PageParam;
  5 +import cn.iocoder.yudao.framework.common.validation.InEnum;
4 6 import io.swagger.v3.oas.annotations.media.Schema;
5 7 import lombok.Data;
6 8  
... ... @@ -8,7 +10,14 @@ import lombok.Data;
8 10 @Data
9 11 public class PayWalletTransactionPageReqVO extends PageParam {
10 12  
11   - @Schema(description = "钱包编号", example = "1")
  13 + @Schema(description = "钱包编号", example = "888")
12 14 private Long walletId;
13 15  
  16 + @Schema(description = "用户编号", example = "1024")
  17 + private Long userId;
  18 +
  19 + @Schema(description = "用户类型", example = "1")
  20 + @InEnum(UserTypeEnum.class)
  21 + private Integer userType;
  22 +
14 23 }
... ...
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java
1 1 package cn.iocoder.yudao.module.pay.service.wallet;
2 2  
  3 +import cn.hutool.core.util.ObjectUtil;
3 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 5 import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO;
5 6 import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
... ... @@ -11,12 +12,11 @@ import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper;
11 12 import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO;
12 13 import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
13 14 import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
  15 +import jakarta.annotation.Resource;
14 16 import lombok.extern.slf4j.Slf4j;
15 17 import org.springframework.stereotype.Service;
16 18 import org.springframework.validation.annotation.Validated;
17 19  
18   -import jakarta.annotation.Resource;
19   -
20 20 import java.time.LocalDateTime;
21 21  
22 22 import static cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO.TYPE_EXPENSE;
... ... @@ -53,6 +53,16 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
53 53  
54 54 @Override
55 55 public PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) {
  56 + // 基于 userId + userType 查询钱包
  57 + if (pageVO.getWalletId() == null
  58 + && ObjectUtil.isAllNotEmpty(pageVO.getUserId(), pageVO.getUserType())) {
  59 + PayWalletDO wallet = payWalletService.getOrCreateWallet(pageVO.getUserId(), pageVO.getUserType());
  60 + if (wallet != null) {
  61 + pageVO.setWalletId(wallet.getId());
  62 + }
  63 + }
  64 +
  65 + // 查询分页
56 66 return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO, null);
57 67 }
58 68  
... ...