Commit be6399238b7eaeb47f6816383ebfb00043a24828
1 parent
6b7f0719
会员详情,查询钱包信息
Showing
7 changed files
with
155 additions
and
15 deletions
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletRespVO; | |
| 5 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletUserReqVO; | |
| 6 | +import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; | |
| 7 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; | |
| 8 | +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | +import lombok.extern.slf4j.Slf4j; | |
| 12 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 16 | +import org.springframework.web.bind.annotation.RestController; | |
| 17 | + | |
| 18 | +import javax.annotation.Resource; | |
| 19 | + | |
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 21 | + | |
| 22 | +@Tag(name = "管理后台 - 用户钱包") | |
| 23 | +@RestController | |
| 24 | +@RequestMapping("/pay/wallet") | |
| 25 | +@Validated | |
| 26 | +@Slf4j | |
| 27 | +public class PayWalletController { | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private PayWalletService payWalletService; | |
| 31 | + | |
| 32 | + @GetMapping("/user-wallet") | |
| 33 | + @PreAuthorize("@ss.hasPermission('pay:wallet:query')") | |
| 34 | + @Operation(summary = "获得用户钱包明细") | |
| 35 | + public CommonResult<PayWalletRespVO> getByUser(PayWalletUserReqVO reqVO) { | |
| 36 | + PayWalletDO wallet = payWalletService.getWalletByUserIdAndType(reqVO.getUserId(), reqVO.getUserType()); | |
| 37 | + return success(PayWalletConvert.INSTANCE.convert02(wallet)); | |
| 38 | + } | |
| 39 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/PayWalletBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 用户钱包 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | + */ | |
| 12 | +@Data | |
| 13 | +public class PayWalletBaseVO { | |
| 14 | + | |
| 15 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20020") | |
| 16 | + @NotNull(message = "用户编号不能为空") | |
| 17 | + private Long userId; | |
| 18 | + | |
| 19 | + @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 20 | + @NotNull(message = "用户类型不能为空") | |
| 21 | + private Byte userType; | |
| 22 | + | |
| 23 | + @Schema(description = "余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 24 | + @NotNull(message = "余额,单位分不能为空") | |
| 25 | + private Integer balance; | |
| 26 | + | |
| 27 | + @Schema(description = "累计支出,单位分", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 28 | + @NotNull(message = "累计支出,单位分不能为空") | |
| 29 | + private Integer totalExpense; | |
| 30 | + | |
| 31 | + @Schema(description = "累计充值,单位分", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 32 | + @NotNull(message = "累计充值,单位分不能为空") | |
| 33 | + private Integer totalRecharge; | |
| 34 | + | |
| 35 | + @Schema(description = "冻结金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "20737") | |
| 36 | + @NotNull(message = "冻结金额,单位分不能为空") | |
| 37 | + private Integer freezePrice; | |
| 38 | + | |
| 39 | +} | |
| 0 | 40 | \ No newline at end of file | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/PayWalletRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 用户钱包 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class PayWalletRespVO extends PayWalletBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29528") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/PayWalletUserReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 用户钱包明细 Request VO") | |
| 11 | +@Data | |
| 12 | +public class PayWalletUserReqVO { | |
| 13 | + | |
| 14 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 15 | + @NotNull(message = "用户编号不能为空") | |
| 16 | + private Long userId; | |
| 17 | + | |
| 18 | + @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 19 | + @NotNull(message = "用户类型不能为空") | |
| 20 | + @InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}") | |
| 21 | + private Integer userType; | |
| 22 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.convert.wallet; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletRespVO; | |
| 3 | 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; |
| 4 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 5 | 6 | import org.mapstruct.Mapper; |
| ... | ... | @@ -11,4 +12,6 @@ public interface PayWalletConvert { |
| 11 | 12 | PayWalletConvert INSTANCE = Mappers.getMapper(PayWalletConvert.class); |
| 12 | 13 | |
| 13 | 14 | AppPayWalletRespVO convert(PayWalletDO bean); |
| 15 | + | |
| 16 | + PayWalletRespVO convert02(PayWalletDO wallet); | |
| 14 | 17 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
| ... | ... | @@ -13,10 +13,10 @@ public interface PayWalletService { |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * 获取钱包信息 |
| 16 | - * | |
| 16 | + * <p> | |
| 17 | 17 | * 如果不存在,则创建钱包。由于用户注册时候不会创建钱包 |
| 18 | 18 | * |
| 19 | - * @param userId 用户编号 | |
| 19 | + * @param userId 用户编号 | |
| 20 | 20 | * @param userType 用户类型 |
| 21 | 21 | */ |
| 22 | 22 | PayWalletDO getOrCreateWallet(Long userId, Integer userType); |
| ... | ... | @@ -31,10 +31,10 @@ public interface PayWalletService { |
| 31 | 31 | /** |
| 32 | 32 | * 钱包订单支付 |
| 33 | 33 | * |
| 34 | - * @param userId 用户 id | |
| 35 | - * @param userType 用户类型 | |
| 34 | + * @param userId 用户 id | |
| 35 | + * @param userType 用户类型 | |
| 36 | 36 | * @param outTradeNo 外部订单号 |
| 37 | - * @param price 金额 | |
| 37 | + * @param price 金额 | |
| 38 | 38 | */ |
| 39 | 39 | PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price); |
| 40 | 40 | |
| ... | ... | @@ -43,17 +43,17 @@ public interface PayWalletService { |
| 43 | 43 | * |
| 44 | 44 | * @param outRefundNo 外部退款号 |
| 45 | 45 | * @param refundPrice 退款金额 |
| 46 | - * @param reason 退款原因 | |
| 46 | + * @param reason 退款原因 | |
| 47 | 47 | */ |
| 48 | 48 | PayWalletTransactionDO orderRefund(String outRefundNo, Integer refundPrice, String reason); |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * 扣减钱包余额 |
| 52 | 52 | * |
| 53 | - * @param walletId 钱包 id | |
| 54 | - * @param bizId 业务关联 id | |
| 55 | - * @param bizType 业务关联分类 | |
| 56 | - * @param price 扣减金额 | |
| 53 | + * @param walletId 钱包 id | |
| 54 | + * @param bizId 业务关联 id | |
| 55 | + * @param bizType 业务关联分类 | |
| 56 | + * @param price 扣减金额 | |
| 57 | 57 | * @return 钱包流水 |
| 58 | 58 | */ |
| 59 | 59 | PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, |
| ... | ... | @@ -63,9 +63,9 @@ public interface PayWalletService { |
| 63 | 63 | * 增加钱包余额 |
| 64 | 64 | * |
| 65 | 65 | * @param walletId 钱包 id |
| 66 | - * @param bizId 业务关联 id | |
| 67 | - * @param bizType 业务关联分类 | |
| 68 | - * @param price 增加金额 | |
| 66 | + * @param bizId 业务关联 id | |
| 67 | + * @param bizType 业务关联分类 | |
| 68 | + * @param price 增加金额 | |
| 69 | 69 | * @return 钱包流水 |
| 70 | 70 | */ |
| 71 | 71 | PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, |
| ... | ... | @@ -74,15 +74,25 @@ public interface PayWalletService { |
| 74 | 74 | /** |
| 75 | 75 | * 冻结钱包部分余额 |
| 76 | 76 | * |
| 77 | - * @param id 钱包编号 | |
| 77 | + * @param id 钱包编号 | |
| 78 | 78 | * @param price 冻结金额 |
| 79 | 79 | */ |
| 80 | 80 | void freezePrice(Long id, Integer price); |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * 解冻钱包余额 |
| 84 | - * @param id 钱包编号 | |
| 84 | + * | |
| 85 | + * @param id 钱包编号 | |
| 85 | 86 | * @param price 解冻金额 |
| 86 | 87 | */ |
| 87 | 88 | void unFreezePrice(Long id, Integer price); |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 获得用户的钱包明细 | |
| 92 | + * | |
| 93 | + * @param userId 用户编号 | |
| 94 | + * @param userType 用户类型 | |
| 95 | + * @return 用户的钱包明细 | |
| 96 | + */ | |
| 97 | + PayWalletDO getWalletByUserIdAndType(Long userId, Integer userType); | |
| 88 | 98 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
| ... | ... | @@ -195,4 +195,9 @@ public class PayWalletServiceImpl implements PayWalletService { |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | + @Override | |
| 199 | + public PayWalletDO getWalletByUserIdAndType(Long userId, Integer userType) { | |
| 200 | + return walletMapper.selectByUserIdAndType(userId, userType); | |
| 201 | + } | |
| 202 | + | |
| 198 | 203 | } | ... | ... |