From 89e847c8cd044ccc4187c40043d4ced04a32b985 Mon Sep 17 00:00:00 2001
From: jason <2667446@qq.com>
Date: Sat, 21 Oct 2023 15:28:07 +0800
Subject: [PATCH] =?UTF-8?q?=E9=92=B1=E5=8C=85=EF=BC=8C=E8=BD=AC=E8=B4=A6?=
=?UTF-8?q?=20review=20=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sql/mysql/pay_wallet.sql | 2 +-
.../transfer/dto/PayTransferCreateReqDTO.java | 8 ++--
.../module/pay/enums/ErrorCodeConstants.java | 1 +
.../enums/member/PayWalletBizTypeEnum.java | 11 ++++-
.../enums/transfer/PayTransferTypeEnum.java | 41 +++++++++++++++++++
yudao-module-pay/yudao-module-pay-biz/pom.xml | 5 +++
.../pay/api/transfer/PayTransferApiImpl.java | 9 ++--
.../transfer/PayDemoTransferCreateReqVO.java | 3 +-
.../admin/transfer/PayTransferController.java | 2 +-
.../admin/wallet/PayWalletController.java | 35 ++++++++++++++--
.../PayWalletTransactionController.java | 3 +-
.../WalletRechargePackagePageReqVO.java | 8 ----
.../wallet/vo/wallet/PayWalletPageReqVO.java | 19 +++++----
.../wallet/vo/wallet/PayWalletRespVO.java | 6 ++-
.../wallet/vo/wallet/PayWalletUserReqVO.java | 8 ----
.../AppPayWalletRechargeController.java | 5 ++-
.../AppPayWalletRechargeCreateReqVO.java | 8 +++-
.../convert/transfer/PayTransferConvert.java | 4 +-
.../pay/convert/wallet/PayWalletConvert.java | 16 +++++++-
.../dataobject/transfer/PayTransferDO.java | 4 +-
.../transfer/PayTransferExtensionDO.java | 1 +
.../pay/dal/mysql/wallet/PayWalletMapper.java | 6 +--
.../PayWalletRechargePackageMapper.java | 8 ++--
.../demo/PayDemoTransferServiceImpl.java | 5 ++-
.../transfer/PayTransferServiceImpl.java | 2 +-
.../PayWalletRechargePackageServiceImpl.java | 27 +++++++++---
.../wallet/PayWalletRechargeService.java | 3 +-
.../wallet/PayWalletRechargeServiceImpl.java | 11 +++--
.../pay/service/wallet/PayWalletService.java | 5 +--
.../service/wallet/PayWalletServiceImpl.java | 6 +--
.../PayWalletTransactionServiceImpl.java | 2 +
.../bo/WalletTransactionCreateReqBO.java | 13 +++++-
32 files changed, 205 insertions(+), 82 deletions(-)
create mode 100644 yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java
diff --git a/sql/mysql/pay_wallet.sql b/sql/mysql/pay_wallet.sql
index 0586fdd15..e69b97b7b 100644
--- a/sql/mysql/pay_wallet.sql
+++ b/sql/mysql/pay_wallet.sql
@@ -9,7 +9,7 @@ CREATE TABLE `pay_transfer`
`app_id` bigint NOT NULL COMMENT '应用编号',
`merchant_order_id` varchar(64) NOT NULL COMMENT '商户订单编号',
`price` int NOT NULL COMMENT '转账金额,单位:分',
- `title` varchar(512) NOT NULL COMMENT '转账标题',
+ `subject` varchar(512) NOT NULL COMMENT '转账标题',
`payee_info` varchar(512) NOT NULL COMMENT '收款人信息,不同类型和渠道不同',
`status` tinyint NOT NULL COMMENT '转账状态',
`success_time` datetime NULL COMMENT '转账成功时间',
diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java
index fec0bd174..2ea7b25a8 100644
--- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java
+++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java
@@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.pay.api.transfer.dto;
+import cn.iocoder.yudao.framework.common.validation.InEnum;
+import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum;
import lombok.Data;
import javax.validation.constraints.Min;
@@ -23,7 +25,7 @@ public class PayTransferCreateReqDTO {
* 类型
*/
@NotNull(message = "转账类型不能为空")
- // TODO @jason:枚举的校验
+ @InEnum(PayTransferTypeEnum.class)
private Integer type;
/**
@@ -35,14 +37,14 @@ public class PayTransferCreateReqDTO {
/**
* 转账金额,单位:分
*/
- // TODO @jason:这个金额是不是非空哈
@Min(value = 1, message = "转账金额必须大于零")
+ @NotNull(message = "转账金额不能为空")
private Integer price;
- // TODO @jason:这个标题,是不是不允许空呀
/**
* 转账标题
*/
+ @NotEmpty(message = "转账标题不能为空")
private String title;
@NotEmpty(message = "收款方信息不能为空")
diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java
index 4b3f1cfad..476d7417b 100644
--- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java
+++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java
@@ -62,6 +62,7 @@ public interface ErrorCodeConstants {
ErrorCode WALLET_RECHARGE_PACKAGE_AND_PRICE_IS_EMPTY = new ErrorCode(1_007_008_011, "充值金额和充钱套餐不能同时为空");
ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_012, "钱包充值套餐不存在");
ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_013, "钱包充值套餐已禁用");
+ ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_014, "钱包充值套餐名称已存在");
// ========== 转账模块 1-007-009-000 ==========
ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}");
diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/PayWalletBizTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/PayWalletBizTypeEnum.java
index 508b728af..76ef5cc58 100644
--- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/PayWalletBizTypeEnum.java
+++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/PayWalletBizTypeEnum.java
@@ -1,8 +1,11 @@
package cn.iocoder.yudao.module.pay.enums.member;
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
+import java.util.Arrays;
+
/**
* 钱包交易业务分类
*
@@ -10,7 +13,7 @@ import lombok.Getter;
*/
@AllArgsConstructor
@Getter
-public enum PayWalletBizTypeEnum {
+public enum PayWalletBizTypeEnum implements IntArrayValuable {
RECHARGE(1, "充值"),
RECHARGE_REFUND(2, "充值退款"),
@@ -28,4 +31,10 @@ public enum PayWalletBizTypeEnum {
*/
private final String description;
+ public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayWalletBizTypeEnum::getType).toArray();
+
+ @Override
+ public int[] array() {
+ return ARRAYS;
+ }
}
diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java
new file mode 100644
index 000000000..b86b37384
--- /dev/null
+++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java
@@ -0,0 +1,41 @@
+package cn.iocoder.yudao.module.pay.enums.transfer;
+
+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 PayTransferTypeEnum implements IntArrayValuable {
+
+ ALIPAY_BALANCE(1, "支付宝余额"),
+ WX_BALANCE(2, "微信余额"),
+ BANK_CARD(3, "银行卡"),
+ WALLET_BALANCE(4, "钱包余额");
+
+ public static final String ALIPAY_LOGON_ID = "ALIPAY_LOGON_ID";
+ public static final String ALIPAY_ACCOUNT_NAME = "ALIPAY_ACCOUNT_NAME";
+
+ private final Integer type;
+ private final String name;
+
+ public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayTransferTypeEnum::getType).toArray();
+
+ @Override
+ public int[] array() {
+ return ARRAYS;
+ }
+
+ public static PayTransferTypeEnum typeOf(Integer type) {
+ return ArrayUtil.firstMatch(item -> item.getType().equals(type), values());
+ }
+
+}
diff --git a/yudao-module-pay/yudao-module-pay-biz/pom.xml b/yudao-module-pay/yudao-module-pay-biz/pom.xml
index 35948df65..7bd50f89e 100644
--- a/yudao-module-pay/yudao-module-pay-biz/pom.xml
+++ b/yudao-module-pay/yudao-module-pay-biz/pom.xml
@@ -24,6 +24,11 @@
${revision}
+
+ cn.iocoder.boot
+ yudao-module-member-api
+ ${revision}
+
cn.iocoder.boot
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java
index d9f5d5663..396b3eca0 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java
@@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.pay.api.transfer;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
+import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
+import javax.annotation.Resource;
+
/**
* 转账单 API 实现类
*
@@ -12,11 +15,11 @@ import org.springframework.validation.annotation.Validated;
@Service
@Validated
public class PayTransferApiImpl implements PayTransferApi {
+ @Resource
+ private PayTransferService payTransferService;
@Override
public Long createTransfer(PayTransferCreateReqDTO reqDTO) {
- // TODO @jason:貌似没实现噢
- return null;
+ return payTransferService.createTransfer(reqDTO);
}
-
}
\ No newline at end of file
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java
index 6db343ea3..41bafe676 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java
@@ -17,11 +17,10 @@ import java.util.Map;
@Data
public class PayDemoTransferCreateReqVO {
- // TODO @jason:这个字段,是不是叫 type 就好了。
@Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "转账类型不能为空")
@InEnum(PayTransferTypeEnum.class)
- private Integer transferType;
+ private Integer type;
@NotNull(message = "转账金额不能为空")
@Min(value = 1, message = "转账金额必须大于零")
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java
index 5c416b623..6d8592058 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java
@@ -29,7 +29,7 @@ public class PayTransferController {
@PostMapping("/submit")
@Operation(summary = "提交转账订单")
- // TODO @jason:权限的设置
+ // TODO @jason:权限的设置, 管理后台页面加的时候加一下
public CommonResult submitPayTransfer(@Valid @RequestBody PayTransferSubmitReqVO reqVO) {
PayTransferSubmitRespVO respVO = payTransferService.submitTransfer(reqVO, getClientIP());
return success(respVO);
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java
index 7deed8eb7..1d70e5d9d 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java
@@ -1,7 +1,12 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
+import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO;
@@ -19,8 +24,14 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import static cn.iocoder.yudao.framework.common.enums.UserTypeEnum.MEMBER;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
@Tag(name = "管理后台 - 用户钱包")
@RestController
@@ -31,21 +42,37 @@ public class PayWalletController {
@Resource
private PayWalletService payWalletService;
+ @Resource
+ private MemberUserApi memberUserApi;
@GetMapping("/get")
@PreAuthorize("@ss.hasPermission('pay:wallet:query')")
@Operation(summary = "获得用户钱包明细")
public CommonResult getWallet(PayWalletUserReqVO reqVO) {
- PayWalletDO wallet = payWalletService.getOrCreateWallet(reqVO.getUserId(), reqVO.getUserType());
- return success(PayWalletConvert.INSTANCE.convert02(wallet));
+ PayWalletDO wallet = payWalletService.getOrCreateWallet(reqVO.getUserId(), MEMBER.getValue());
+ MemberUserRespDTO memberUser = memberUserApi.getUser(reqVO.getUserId());
+ String nickname = memberUser == null ? "" : memberUser.getNickname();
+ String avatar = memberUser == null ? "" : memberUser.getAvatar();
+ return success(PayWalletConvert.INSTANCE.convert02(nickname, avatar, wallet));
}
@GetMapping("/page")
@Operation(summary = "获得会员钱包分页")
@PreAuthorize("@ss.hasPermission('pay:wallet:query')")
public CommonResult> getWalletPage(@Valid PayWalletPageReqVO pageVO) {
- PageResult pageResult = payWalletService.getWalletPage(pageVO);
- return success(PayWalletConvert.INSTANCE.convertPage(pageResult));
+ if (StrUtil.isNotEmpty(pageVO.getNickname())) {
+ Set userIds = CollectionUtils.convertSet(memberUserApi.getUserListByNickname(pageVO.getNickname()),
+ MemberUserRespDTO::getId);
+ pageVO.setUserIds(userIds);
+ }
+ // 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景
+ PageResult pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO);
+ if (CollectionUtil.isEmpty(pageResult.getList())) {
+ return success(new PageResult<>(pageResult.getTotal()));
+ }
+ List userIds = convertList(pageResult.getList(), PayWalletDO::getUserId);
+ Map userMap = convertMap(memberUserApi.getUserList(userIds),MemberUserRespDTO::getId);
+ return success(PayWalletConvert.INSTANCE.convertPage(pageResult, userMap));
}
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java
index 66891ba81..37dd51642 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java
@@ -10,6 +10,7 @@ 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.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -32,7 +33,7 @@ public class PayWalletTransactionController {
@GetMapping("/page")
@Operation(summary = "获得钱包流水分页")
- // TODO @jason:权限校验,缺一个
+ @PreAuthorize("@ss.hasPermission('pay:wallet:query')")
public CommonResult> getWalletTransactionPage(
@Valid PayWalletTransactionPageReqVO pageReqVO) {
PageResult result = payWalletTransactionService.getWalletTransactionPage(pageReqVO);
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java
index 1914958ae..346e85902 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java
@@ -20,14 +20,6 @@ public class WalletRechargePackagePageReqVO extends PageParam {
@Schema(description = "套餐名", example = "李四")
private String name;
- // TODO @jason:payPrice 和 bonusPrice 可以去掉。。。一般太少检索啦;
-
- @Schema(description = "支付金额", example = "16454")
- private Integer payPrice;
-
- @Schema(description = "赠送金额", example = "20887")
- private Integer bonusPrice;
-
@Schema(description = "状态", example = "2")
private Integer status;
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java
index fcf22f51b..d74bd44b1 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java
@@ -1,12 +1,14 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
-import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import lombok.*;
-import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
+
import java.time.LocalDateTime;
+import java.util.Collection;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -16,12 +18,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class PayWalletPageReqVO extends PageParam {
- @Schema(description = "用户编号", example = "14138")
- private Long userId;
+ @Schema(description = "用户昵称", example = "李四")
+ private String nickname;
- @Schema(description = "用户类型", example = "1")
- @InEnum(UserTypeEnum.class)
- private Integer userType;
+ @Schema(description = "用户编号", example = "[1,2]")
+ private Collection userIds;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java
index 2f49b50e0..eafb52fc3 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java
@@ -19,6 +19,10 @@ public class PayWalletRespVO extends PayWalletBaseVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
- // TODO @jason:要不把用户昵称 + avatar 也读取下?
+ @Schema(description = "用户昵称")
+ private String nickname;
+
+ @Schema(description = "用户头像")
+ private String avatar;
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java
index 84507497b..72647f148 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java
@@ -1,7 +1,5 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
-import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
-import cn.iocoder.yudao.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -14,10 +12,4 @@ public class PayWalletUserReqVO {
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "用户编号不能为空")
private Long userId;
-
- @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
- @NotNull(message = "用户类型不能为空")
- @InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}")
- private Integer userType;
-
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java
index e4ef75be9..5f0a64286 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java
@@ -19,6 +19,7 @@ import javax.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType;
@@ -35,9 +36,9 @@ public class AppPayWalletRechargeController {
@PostMapping("/create")
@Operation(summary = "创建钱包充值记录(发起充值)")
public CommonResult createWalletRecharge(
- @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) {
+ @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) {
PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge(
- getLoginUserId(), getLoginUserType(), reqVO);
+ getLoginUserId(), getLoginUserType(), getClientIP(), reqVO);
return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge));
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java
index 007cb91d9..1421fb0b5 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java
@@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Min;
+import java.util.Objects;
@Schema(description = "用户 APP - 创建钱包充值 Request VO")
@Data
@@ -16,6 +18,8 @@ public class AppPayWalletRechargeCreateReqVO {
@Schema(description = "充值套餐编号", example = "1024")
private Long packageId;
- // TODO @jaosn:写个 AssertTrue 的校验方法,payPrice 和 packageId 必须二选一
-
+ @AssertTrue(message = "充值金额和充钱套餐不能同时为空")
+ public boolean validatePayPriceAndPackageId() {
+ return Objects.nonNull(payPrice) || Objects.nonNull(packageId);
+ }
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java
index 7a31a1904..69512f81c 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java
@@ -11,9 +11,9 @@ import org.mapstruct.factory.Mappers;
public interface PayTransferConvert {
PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class);
-
+ @Mapping(source = "title", target = "subject")
PayTransferDO convert(PayTransferCreateReqDTO dto);
- @Mapping(source = "transferType", target = "type")
+
PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo);
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java
index 3617f23a0..31661e65e 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java
@@ -1,12 +1,16 @@
package cn.iocoder.yudao.module.pay.convert.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
+import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
+import java.util.Map;
+
@Mapper
public interface PayWalletConvert {
@@ -14,8 +18,18 @@ public interface PayWalletConvert {
AppPayWalletRespVO convert(PayWalletDO bean);
- PayWalletRespVO convert02(PayWalletDO bean);
+ PayWalletRespVO convert02(String nickname,String avatar, PayWalletDO bean);
PageResult convertPage(PageResult page);
+ default PageResult convertPage(PageResult page, Map userMap){
+ PageResult pageResult = convertPage(page);
+ pageResult.getList().forEach( wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(),
+ user -> {
+ wallet.setNickname(user.getNickname());
+ wallet.setAvatar(user.getAvatar());
+ }));
+ return pageResult;
+ }
+
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java
index 84fb470e0..507157a7a 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java
@@ -64,11 +64,11 @@ public class PayTransferDO extends BaseDO {
* 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一
*/
private String merchantOrderId;
- // TODO @jason:这个字段,要不要改成 subject。。。和 payorderdo 保持一致;哈哈哈,我也忘记为啥当时选了这个名字了。。。
+
/**
* 转账标题
*/
- private String title;
+ private String subject;
// ========== 转账相关字段 ==========
/**
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java
index 9a3736b49..58e79dc84 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java
@@ -11,6 +11,7 @@ import lombok.Data;
import java.util.Map;
// TODO @jason:转账是不是类似 refund,不用拓展单呀?支付做拓展单的原因,是因为它存在不确定性,可以切换多种;转账和退款,都是明确方式的;
+// @芋艿 转账是不是也存在多种方式。 例如转账到银行卡。 可以使用微信,也可以使用支付宝。 支付宝账号余额不够,可以切换到微信
/**
* 转账拓展单 DO
*
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java
index e34c76c0c..ce672255a 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java
@@ -17,10 +17,10 @@ public interface PayWalletMapper extends BaseMapperX {
PayWalletDO::getUserType, userType);
}
- default PageResult selectPage(PayWalletPageReqVO reqVO) {
+ default PageResult selectPage(Integer userType, PayWalletPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX()
- .eqIfPresent(PayWalletDO::getUserId, reqVO.getUserId())
- .eqIfPresent(PayWalletDO::getUserType, reqVO.getUserType())
+ .inIfPresent(PayWalletDO::getUserId, reqVO.getUserIds())
+ .eqIfPresent(PayWalletDO::getUserType, userType)
.betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(PayWalletDO::getId));
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java
index 563055854..f9c3aea65 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java
@@ -12,14 +12,14 @@ import org.apache.ibatis.annotations.Mapper;
public interface PayWalletRechargePackageMapper extends BaseMapperX {
default PageResult selectPage(WalletRechargePackagePageReqVO reqVO) {
- // TODO @jason:排序按照充值金额
return selectPage(reqVO, new LambdaQueryWrapperX()
.likeIfPresent(PayWalletRechargePackageDO::getName, reqVO.getName())
- .eqIfPresent(PayWalletRechargePackageDO::getPayPrice, reqVO.getPayPrice())
- .eqIfPresent(PayWalletRechargePackageDO::getBonusPrice, reqVO.getBonusPrice())
.eqIfPresent(PayWalletRechargePackageDO::getStatus, reqVO.getStatus())
.betweenIfPresent(PayWalletRechargePackageDO::getCreateTime, reqVO.getCreateTime())
- .orderByDesc(PayWalletRechargePackageDO::getId));
+ .orderByDesc(PayWalletRechargePackageDO::getPayPrice));
}
+ default PayWalletRechargePackageDO selectByName(String name){
+ return selectOne(PayWalletRechargePackageDO::getName, name);
+ }
}
\ No newline at end of file
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java
index 8e7389132..d4da016ac 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java
@@ -46,10 +46,10 @@ public class PayDemoTransferServiceImpl implements PayDemoTransferService {
@Transactional(rollbackFor = Exception.class)
public Long createDemoTransfer(Long userId, @Valid PayDemoTransferCreateReqVO vo) {
// 1 校验收款账号
- validatePayeeInfo(vo.getTransferType(), vo.getPayeeInfo());
+ validatePayeeInfo(vo.getType(), vo.getPayeeInfo());
// 2 保存示例转账业务表
- PayDemoTransferDO demoTransfer = new PayDemoTransferDO().setUserId(userId).setType(vo.getTransferType())
+ PayDemoTransferDO demoTransfer = new PayDemoTransferDO().setUserId(userId).setType(vo.getType())
.setPrice(vo.getPrice()).setPayeeInfo(vo.getPayeeInfo())
.setTransferStatus(WAITING.getStatus());
demoTransferMapper.insert(demoTransfer);
@@ -65,6 +65,7 @@ public class PayDemoTransferServiceImpl implements PayDemoTransferService {
}
// TODO @jason:可以参考 AppBrokerageWithdrawCreateReqVO 搞下字段哈,进行校验
+ // @jason payeeinfo 字段确定改一下
private void validatePayeeInfo(Integer transferType, Map payeeInfo) {
PayTransferTypeEnum transferTypeEnum = typeOf(transferType);
switch (transferTypeEnum) {
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java
index b31a9d561..286f60232 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java
@@ -79,7 +79,7 @@ public class PayTransferServiceImpl implements PayTransferService {
// 3. 调用三方渠道发起转账
PayTransferUnifiedReqDTO transferUnifiedReq = new PayTransferUnifiedReqDTO()
.setOutTransferNo(transferExtension.getNo()).setPrice(transfer.getPrice())
- .setType(transfer.getType()).setTitle(transfer.getTitle())
+ .setType(transfer.getType()).setTitle(transfer.getSubject())
.setPayeeInfo(transfer.getPayeeInfo()).setUserIp(userIp)
.setChannelExtras(reqVO.getChannelExtras());
PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq);
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java
index 6b73f623b..4d99d1391 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java
@@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.pay.service.wallet;
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO;
@@ -14,9 +13,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
-import java.util.Collection;
-import java.util.List;
-
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
@@ -50,6 +46,8 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
@Override
public Long createWalletRechargePackage(WalletRechargePackageCreateReqVO createReqVO) {
+ // 校验套餐名是否唯一
+ validateRechargePackageNameUnique(null, createReqVO.getName());
// 插入
PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO);
walletRechargePackageMapper.insert(walletRechargePackage);
@@ -57,16 +55,33 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
return walletRechargePackage.getId();
}
- // TODO @jason:校验下,套餐名唯一
@Override
public void updateWalletRechargePackage(WalletRechargePackageUpdateReqVO updateReqVO) {
// 校验存在
validateWalletRechargePackageExists(updateReqVO.getId());
+ // 校验套餐名是否唯一
+ validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName());
// 更新
PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO);
walletRechargePackageMapper.updateById(updateObj);
}
+ private void validateRechargePackageNameUnique(Long id, String name) {
+ if (StrUtil.isBlank(name)) {
+ return;
+ }
+ PayWalletRechargePackageDO rechargePackage = walletRechargePackageMapper.selectByName(name);
+ if (rechargePackage == null) {
+ return ;
+ }
+ if (id == null) {
+ throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS);
+ }
+ if (!id.equals(rechargePackage.getId())) {
+ throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS);
+ }
+ }
+
@Override
public void deleteWalletRechargePackage(Long id) {
// 校验存在
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java
index 3101d3ecf..752ce89af 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java
@@ -16,9 +16,10 @@ public interface PayWalletRechargeService {
* @param userId 用户 id
* @param userType 用户类型
* @param createReqVO 钱包充值请求 VO
+ * @param userIp 用户Ip
* @return 钱包充值记录
*/
- PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType,
+ PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp,
AppPayWalletRechargeCreateReqVO createReqVO);
/**
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
index f09f78960..fd8c9f94b 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
@@ -29,7 +29,6 @@ import static cn.hutool.core.util.ObjectUtil.notEqual;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
-import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE;
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
@@ -63,13 +62,13 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
@Override
@Transactional(rollbackFor = Exception.class)
- public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType,
+ public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp,
AppPayWalletRechargeCreateReqVO reqVO) {
- // 1.1 校验参数 TODO @jason:AppPayWalletRechargeCreateReqVO 看下校验;
+
if (Objects.isNull(reqVO.getPayPrice()) && Objects.isNull(reqVO.getPackageId())) {
+ // TODO @jason @AssertTrue 貌似没有效果。需要查下原因
throw exception(WALLET_RECHARGE_PACKAGE_AND_PRICE_IS_EMPTY);
}
-
// 1.1 计算充值金额
int payPrice;
int bonusPrice = 0;
@@ -87,7 +86,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
// 2.1 创建支付单
Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO()
- .setAppId(WALLET_PAY_APP_ID).setUserIp(getClientIP()) // TODO @jason:clientIp 从 controller 传递进来噢
+ .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp)
.setMerchantOrderId(recharge.getId().toString()) // 业务的订单编号
.setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("")
.setPrice(recharge.getPayPrice())
@@ -181,7 +180,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
// 退款失败
if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) {
// 2.2 解冻余额
- payWalletService.unFreezePrice(walletRecharge.getWalletId(), walletRecharge.getTotalPrice());
+ payWalletService.unfreezePrice(walletRecharge.getWalletId(), walletRecharge.getTotalPrice());
updateObj.setRefundStatus(FAILURE.getStatus());
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
index 0a6de3ef4..8175caef3 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
@@ -37,7 +37,7 @@ public interface PayWalletService {
* @param pageReqVO 分页查询
* @return 会员钱包分页
*/
- PageResult getWalletPage(PayWalletPageReqVO pageReqVO);
+ PageResult getWalletPage(Integer userType, PayWalletPageReqVO pageReqVO);
/**
* 钱包订单支付
@@ -90,13 +90,12 @@ public interface PayWalletService {
*/
void freezePrice(Long id, Integer price);
- // TODO @jason:unfreeze 是单词哈,f 不用大写
/**
* 解冻钱包余额
*
* @param id 钱包编号
* @param price 解冻金额
*/
- void unFreezePrice(Long id, Integer price);
+ void unfreezePrice(Long id, Integer price);
}
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
index b76d2028d..94601de94 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
@@ -63,8 +63,8 @@ public class PayWalletServiceImpl implements PayWalletService {
}
@Override
- public PageResult getWalletPage(PayWalletPageReqVO pageReqVO) {
- return walletMapper.selectPage(pageReqVO);
+ public PageResult getWalletPage(Integer userType,PayWalletPageReqVO pageReqVO) {
+ return walletMapper.selectPage(userType, pageReqVO);
}
@Override
@@ -196,7 +196,7 @@ public class PayWalletServiceImpl implements PayWalletService {
}
@Override
- public void unFreezePrice(Long id, Integer price) {
+ public void unfreezePrice(Long id, Integer price) {
int updateCounts = walletMapper.unFreezePrice(id, price);
if (updateCounts == 0) {
throw exception(WALLET_FREEZE_PRICE_NOT_ENOUGH);
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java
index fd02b4976..317ec458c 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java
@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
@@ -22,6 +23,7 @@ import javax.annotation.Resource;
*/
@Service
@Slf4j
+@Validated
public class PayWalletTransactionServiceImpl implements PayWalletTransactionService {
/**
diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java
index 736415154..9714be971 100644
--- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java
+++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java
@@ -1,8 +1,12 @@
package cn.iocoder.yudao.module.pay.service.wallet.bo;
+import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
import lombok.Data;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
/**
* 创建钱包流水 BO
*
@@ -11,12 +15,11 @@ import lombok.Data;
@Data
public class WalletTransactionCreateReqBO {
- // TODO @jason:bo 的话,最好加个参数校验哈;
-
/**
* 钱包编号
*
*/
+ @NotNull(message = "钱包编号不能为空")
private Long walletId;
/**
@@ -24,11 +27,13 @@ public class WalletTransactionCreateReqBO {
*
* 正值表示余额增加,负值表示余额减少
*/
+ @NotNull(message = "交易金额不能为空")
private Integer price;
/**
* 交易后余额,单位分
*/
+ @NotNull(message = "交易后余额不能为空")
private Integer balance;
/**
@@ -36,15 +41,19 @@ public class WalletTransactionCreateReqBO {
*
* 枚举 {@link PayWalletBizTypeEnum#getType()}
*/
+ @NotNull(message = "关联业务分类不能为空")
+ @InEnum(PayWalletBizTypeEnum.class)
private Integer bizType;
/**
* 关联业务编号
*/
+ @NotEmpty(message = "关联业务编号不能为空")
private String bizId;
/**
* 流水说明
*/
+ @NotEmpty(message = "流水说明不能为空")
private String title;
}