Commit cd101ec7fc876e6b62b289b9603d260896ef9bd6
1 parent
d2c7ec24
【功能新增】支付:钱包余额,支持 userId 过滤
Showing
2 changed files
with
22 additions
and
3 deletions
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java
| 1 | package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; | 1 | package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 7 | import lombok.Data; |
| 6 | 8 | ||
| @@ -8,7 +10,14 @@ import lombok.Data; | @@ -8,7 +10,14 @@ import lombok.Data; | ||
| 8 | @Data | 10 | @Data |
| 9 | public class PayWalletTransactionPageReqVO extends PageParam { | 11 | public class PayWalletTransactionPageReqVO extends PageParam { |
| 10 | 12 | ||
| 11 | - @Schema(description = "钱包编号", example = "1") | 13 | + @Schema(description = "钱包编号", example = "888") |
| 12 | private Long walletId; | 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 | package cn.iocoder.yudao.module.pay.service.wallet; | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.ObjectUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; | 5 | import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; |
| 5 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; | 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 +12,11 @@ import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper; | ||
| 11 | import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; | 12 | import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; |
| 12 | import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; | 13 | import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; |
| 13 | import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; | 14 | import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; |
| 15 | +import jakarta.annotation.Resource; | ||
| 14 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 16 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 17 | 19 | ||
| 18 | -import jakarta.annotation.Resource; | ||
| 19 | - | ||
| 20 | import java.time.LocalDateTime; | 20 | import java.time.LocalDateTime; |
| 21 | 21 | ||
| 22 | import static cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO.TYPE_EXPENSE; | 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,6 +53,16 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ | ||
| 53 | 53 | ||
| 54 | @Override | 54 | @Override |
| 55 | public PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) { | 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 | return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO, null); | 66 | return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO, null); |
| 57 | } | 67 | } |
| 58 | 68 |