From e052ddab2fb607c0269d566f005524a51bcddbe1 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 21 Jul 2024 11:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=91PAY=EF=BC=9A=E7=A7=BB=E9=99=A4=E5=AF=B9=20member=20?= =?UTF-8?q?=E7=9A=84=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/TradeOrderQueryServiceImpl.java | 1 - yudao-module-pay/yudao-module-pay-biz/pom.xml | 5 --- .../admin/wallet/PayWalletController.java | 35 +++---------------- .../wallet/vo/wallet/PayWalletPageReqVO.java | 12 ++++--- .../wallet/vo/wallet/PayWalletRespVO.java | 5 --- .../pay/convert/wallet/PayWalletConvert.java | 13 +------ .../pay/dal/mysql/wallet/PayWalletMapper.java | 8 ++--- .../pay/service/wallet/PayWalletService.java | 2 +- .../service/wallet/PayWalletServiceImpl.java | 4 +-- 9 files changed, 20 insertions(+), 65 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java index 2079960f68..af8e9e139d 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java @@ -222,7 +222,6 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { .setPhone(receiverMobile)); } - // =================== Order Item =================== @Override diff --git a/yudao-module-pay/yudao-module-pay-biz/pom.xml b/yudao-module-pay/yudao-module-pay-biz/pom.xml index 738b133c11..22dc86f0bd 100644 --- a/yudao-module-pay/yudao-module-pay-biz/pom.xml +++ b/yudao-module-pay/yudao-module-pay-biz/pom.xml @@ -23,11 +23,6 @@ yudao-module-pay-api ${revision} - - cn.iocoder.boot - yudao-module-member-api - ${revision} - 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 b4b8575538..15e3815389 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,11 +1,7 @@ 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.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; @@ -14,6 +10,8 @@ import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -21,14 +19,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import jakarta.annotation.Resource; -import jakarta.validation.Valid; -import java.util.List; -import java.util.Map; - 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.*; @Tag(name = "管理后台 - 用户钱包") @RestController @@ -39,38 +31,21 @@ 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(), MEMBER.getValue()); - // TODO jason:如果为空,返回给前端只要 null 就可以了 - 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)); + return success(PayWalletConvert.INSTANCE.convert02(wallet)); } @GetMapping("/page") @Operation(summary = "获得会员钱包分页") @PreAuthorize("@ss.hasPermission('pay:wallet:query')") public CommonResult> getWalletPage(@Valid PayWalletPageReqVO pageVO) { - if (StrUtil.isNotEmpty(pageVO.getNickname())) { - List users = memberUserApi.getUserListByNickname(pageVO.getNickname()); - pageVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); - } - // TODO @jason:管理员也可以先查询下。。 - // 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景 - PageResult pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - List users = memberUserApi.getUserList(convertList(pageResult.getList(), PayWalletDO::getUserId)); - Map userMap = convertMap(users, MemberUserRespDTO::getId); - return success(PayWalletConvert.INSTANCE.convertPage(pageResult, userMap)); + PageResult pageResult = payWalletService.getWalletPage(pageVO); + return success(PayWalletConvert.INSTANCE.convertPage(pageResult)); } } 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 d74bd44b19..a31698216e 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,6 +1,8 @@ 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.pojo.PageParam; +import cn.iocoder.yudao.framework.common.validation.InEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -8,7 +10,6 @@ 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; @@ -18,11 +19,12 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class PayWalletPageReqVO extends PageParam { - @Schema(description = "用户昵称", example = "李四") - private String nickname; + @Schema(description = "用户编号", example = "1024") + private Long userId; - @Schema(description = "用户编号", example = "[1,2]") - private Collection userIds; + @Schema(description = "用户类型", example = "1") + @InEnum(value = UserTypeEnum.class) + private Integer userType; @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 a9eedbdfd0..01b35fb3f3 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,9 +19,4 @@ public class PayWalletRespVO extends PayWalletBaseVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") - private String nickname; - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - } 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 5a003a22eb..3617f23a04 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,16 +1,12 @@ 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 { @@ -18,15 +14,8 @@ public interface PayWalletConvert { AppPayWalletRespVO convert(PayWalletDO bean); - PayWalletRespVO convert02(String nickname,String avatar, PayWalletDO bean); + PayWalletRespVO convert02(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()).setAvatar(user.getAvatar()))); - return pageResult; - } - } 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 ce672255a6..4bbaff8b5d 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(Integer userType, PayWalletPageReqVO reqVO) { + default PageResult selectPage(PayWalletPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(PayWalletDO::getUserId, reqVO.getUserIds()) - .eqIfPresent(PayWalletDO::getUserType, userType) + .eqIfPresent(PayWalletDO::getUserId, reqVO.getUserId()) + .eqIfPresent(PayWalletDO::getUserType, reqVO.getUserType()) .betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(PayWalletDO::getId)); } @@ -31,7 +31,7 @@ public interface PayWalletMapper extends BaseMapperX { * @param id 钱包 id * @param price 消费金额 */ - default int updateWhenConsumptionRefund(Long id, Integer price){ + default int updateWhenConsumptionRefund(Long id, Integer price) { LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() .setSql(" balance = balance + " + price + ", total_expense = total_expense - " + price) 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 e98d82681a..358d149da3 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 @@ -36,7 +36,7 @@ public interface PayWalletService { * @param pageReqVO 分页查询 * @return 会员钱包分页 */ - PageResult getWalletPage(Integer userType, PayWalletPageReqVO pageReqVO); + PageResult getWalletPage(PayWalletPageReqVO pageReqVO); /** * 钱包订单支付 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 58c36c3120..513786143d 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 @@ -65,8 +65,8 @@ public class PayWalletServiceImpl implements PayWalletService { } @Override - public PageResult getWalletPage(Integer userType,PayWalletPageReqVO pageReqVO) { - return walletMapper.selectPage(userType, pageReqVO); + public PageResult getWalletPage(PayWalletPageReqVO pageReqVO) { + return walletMapper.selectPage(pageReqVO); } @Override