新增查询钱包余额明细接口
parent
1ffbd9399e
commit
f33b66558c
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.pay.enums.member;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 钱包明细查询类型
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum WalletTransactionQueryTypeEnum implements IntArrayValuable {
|
||||
RECHARGE(1, "充值"),
|
||||
EXPENSE(2, "消费");
|
||||
|
||||
private final Integer type;
|
||||
|
||||
private final String desc;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(WalletTransactionQueryTypeEnum::getType).toArray();
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static WalletTransactionQueryTypeEnum valueOf(Integer type) {
|
||||
return ArrayUtil.firstMatch(o -> o.getType().equals(type), values());
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.enums.member;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 钱包交易大分类
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum WalletTypeEnum {
|
||||
RECHARGE(1, "充值"),
|
||||
EXPENSE(2, "消费");
|
||||
|
||||
private final Integer type;
|
||||
|
||||
private final String desc;
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue