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

This commit is contained in:
YunaiV 2024-08-18 13:07:30 +08:00
parent d2c7ec2445
commit cd101ec7fc
2 changed files with 22 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -8,7 +10,14 @@ import lombok.Data;
@Data
public class PayWalletTransactionPageReqVO extends PageParam {
@Schema(description = "钱包编号", example = "1")
@Schema(description = "钱包编号", example = "888")
private Long walletId;
@Schema(description = "用户编号", example = "1024")
private Long userId;
@Schema(description = "用户类型", example = "1")
@InEnum(UserTypeEnum.class)
private Integer userType;
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO;
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;
import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO;
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO.TYPE_EXPENSE;
@ -53,6 +53,16 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
@Override
public PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) {
// 基于 userId + userType 查询钱包
if (pageVO.getWalletId() == null
&& ObjectUtil.isAllNotEmpty(pageVO.getUserId(), pageVO.getUserType())) {
PayWalletDO wallet = payWalletService.getOrCreateWallet(pageVO.getUserId(), pageVO.getUserType());
if (wallet != null) {
pageVO.setWalletId(wallet.getId());
}
}
// 查询分页
return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO, null);
}