mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	新增查询钱包余额明细接口
This commit is contained in:
		@@ -22,7 +22,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti
 | 
			
		||||
/**
 | 
			
		||||
 * @author jason
 | 
			
		||||
 */
 | 
			
		||||
@Tag(name = "用户 APP - 支付钱包")
 | 
			
		||||
@Tag(name = "用户 APP - 钱包")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/pay/wallet")
 | 
			
		||||
@Validated
 | 
			
		||||
@@ -33,7 +33,7 @@ public class AppPayWalletController {
 | 
			
		||||
    private PayWalletService payWalletService;
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/get")
 | 
			
		||||
    @Operation(summary = "获取支付钱包")
 | 
			
		||||
    @Operation(summary = "获取钱包")
 | 
			
		||||
    public CommonResult<AppPayWalletRespVO> getPayWallet() {
 | 
			
		||||
        PayWalletDO payWallet = payWalletService.getPayWallet(getLoginUserId(), UserTypeEnum.MEMBER.getValue());
 | 
			
		||||
        return success(PayWalletConvert.INSTANCE.convert(payWallet));
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,43 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.controller.app.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.AppPayWalletTransactionPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.AppPayWalletTransactionRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 | 
			
		||||
 | 
			
		||||
@Tag(name = "用户 APP - 钱包余额明细")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/pay/wallet-transaction")
 | 
			
		||||
@Validated
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class AppPayWalletTransactionController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private PayWalletTransactionService payWalletTransactionService;
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/page")
 | 
			
		||||
    @Operation(summary = "获得钱包余额明细分页")
 | 
			
		||||
    public CommonResult<PageResult<AppPayWalletTransactionRespVO>> pageWalletTransaction(
 | 
			
		||||
            @Valid AppPayWalletTransactionPageReqVO pageVO) {
 | 
			
		||||
        PageResult<PayWalletTransactionDO> result = payWalletTransactionService.getWalletTransactionPage(getLoginUserId(),
 | 
			
		||||
                UserTypeEnum.MEMBER.getValue(), pageVO);
 | 
			
		||||
        return success(PayWalletTransactionConvert.INSTANCE.convertPage(result));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,16 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.enums.member.WalletTransactionQueryTypeEnum;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "用户 APP - 钱包余额明细分页 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class AppPayWalletTransactionPageReqVO extends PageParam {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "余额明细查询分类",  example = "1")
 | 
			
		||||
    @InEnum(value = WalletTransactionQueryTypeEnum.class, message = "查询类型必须是 {value}")
 | 
			
		||||
    private Integer type;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "用户 APP - 钱包余额明细分页 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class AppPayWalletTransactionRespVO {
 | 
			
		||||
    @Schema(description = "交易金额, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
 | 
			
		||||
    private Integer amount;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    private Integer bizType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
 | 
			
		||||
    private LocalDateTime transactionTime;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,15 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.convert.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.AppPayWalletTransactionRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
 | 
			
		||||
import org.mapstruct.Mapper;
 | 
			
		||||
import org.mapstruct.factory.Mappers;
 | 
			
		||||
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface PayWalletTransactionConvert {
 | 
			
		||||
 | 
			
		||||
    PayWalletTransactionConvert INSTANCE = Mappers.getMapper(PayWalletTransactionConvert.class);
 | 
			
		||||
 | 
			
		||||
    PageResult<AppPayWalletTransactionRespVO> convertPage(PageResult<PayWalletTransactionDO> page);
 | 
			
		||||
}
 | 
			
		||||
@@ -27,22 +27,13 @@ public class PayWalletTransactionDO extends BaseDO {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 会员钱包 id
 | 
			
		||||
     *
 | 
			
		||||
     * 关联 {@link PayWalletDO#getId()}
 | 
			
		||||
     */
 | 
			
		||||
    private Long walletId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户 id
 | 
			
		||||
     *
 | 
			
		||||
     * 关联 MemberUserDO 的 id 编号
 | 
			
		||||
     */
 | 
			
		||||
    private Long userId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 关联业务
 | 
			
		||||
     *
 | 
			
		||||
     * 枚举 {@link WalletBizTypeEnum#getBizType()}
 | 
			
		||||
     * 钱包交易业务分类
 | 
			
		||||
     * 关联枚举 {@link WalletBizTypeEnum#getBizType()}
 | 
			
		||||
     */
 | 
			
		||||
    private Integer bizType;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,31 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.enums.member.WalletTransactionQueryTypeEnum;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> {
 | 
			
		||||
 | 
			
		||||
    default PageResult<PayWalletTransactionDO> selectPageByWalletIdAndQueryType(Long walletId,
 | 
			
		||||
                                                                                WalletTransactionQueryTypeEnum queryType,
 | 
			
		||||
                                                                                PageParam pageParam) {
 | 
			
		||||
        LambdaQueryWrapperX<PayWalletTransactionDO> query = new LambdaQueryWrapperX<PayWalletTransactionDO>()
 | 
			
		||||
                .eq(PayWalletTransactionDO::getWalletId, walletId);
 | 
			
		||||
        if (WalletTransactionQueryTypeEnum.RECHARGE == queryType ) {
 | 
			
		||||
            query.ge(PayWalletTransactionDO::getAmount, 0);
 | 
			
		||||
        }
 | 
			
		||||
        if (WalletTransactionQueryTypeEnum.EXPENSE == queryType ) {
 | 
			
		||||
            query.lt(PayWalletTransactionDO::getAmount, 0);
 | 
			
		||||
        }
 | 
			
		||||
        query.orderByDesc(PayWalletTransactionDO::getTransactionTime);
 | 
			
		||||
        return selectPage(pageParam, query);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,14 +3,14 @@ package cn.iocoder.yudao.module.pay.service.wallet;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 支付钱包 Service 接口
 | 
			
		||||
 * 钱包 Service 接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author jason
 | 
			
		||||
 */
 | 
			
		||||
public interface PayWalletService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 得到用户的支付钱包
 | 
			
		||||
     * 获取钱包信息
 | 
			
		||||
     * @param userId 用户 id
 | 
			
		||||
     * @param userType 用户类型
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 支付钱包 Service 实现类
 | 
			
		||||
 * 钱包 Service 实现类
 | 
			
		||||
 *
 | 
			
		||||
 * @author jason
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,23 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.service.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.AppPayWalletTransactionPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 钱包余额明细 Service 接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author jason
 | 
			
		||||
 */
 | 
			
		||||
public interface PayWalletTransactionService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询钱包余额明细, 分页
 | 
			
		||||
     *
 | 
			
		||||
     * @param userId   用户 id
 | 
			
		||||
     * @param userType 用户类型
 | 
			
		||||
     * @param pageVO   分页查询参数
 | 
			
		||||
     */
 | 
			
		||||
    PageResult<PayWalletTransactionDO> getWalletTransactionPage(Long userId, Integer userType,
 | 
			
		||||
                                                                AppPayWalletTransactionPageReqVO pageVO);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,41 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.service.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.AppPayWalletTransactionPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.enums.member.WalletTransactionQueryTypeEnum;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
			
		||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_NOT_FOUND;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 钱包余额明细 Service 实现类
 | 
			
		||||
 *
 | 
			
		||||
 * @author jason
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class PayWalletTransactionServiceImpl implements  PayWalletTransactionService{
 | 
			
		||||
    @Resource
 | 
			
		||||
    private PayWalletService payWalletService;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private PayWalletTransactionMapper payWalletTransactionMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public PageResult<PayWalletTransactionDO> getWalletTransactionPage(Long userId, Integer userType,
 | 
			
		||||
                                                                       AppPayWalletTransactionPageReqVO pageVO) {
 | 
			
		||||
        PayWalletDO payWallet = payWalletService.getPayWallet(userId, userType);
 | 
			
		||||
        if (payWallet == null) {
 | 
			
		||||
            log.error("[pageWalletTransaction] 用户 {} 钱包不存在", userId);
 | 
			
		||||
            throw exception(WALLET_NOT_FOUND);
 | 
			
		||||
        }
 | 
			
		||||
        return payWalletTransactionMapper.selectPageByWalletIdAndQueryType(payWallet.getId(),
 | 
			
		||||
                WalletTransactionQueryTypeEnum.valueOf(pageVO.getType()), pageVO);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user