Commit e052ddab2fb607c0269d566f005524a51bcddbe1
1 parent
fe3f144c
【代码代码】PAY:移除对 member 的依赖
Showing
9 changed files
with
20 additions
and
65 deletions
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java
yudao-module-pay/yudao-module-pay-biz/pom.xml
| ... | ... | @@ -23,11 +23,6 @@ |
| 23 | 23 | <artifactId>yudao-module-pay-api</artifactId> |
| 24 | 24 | <version>${revision}</version> |
| 25 | 25 | </dependency> |
| 26 | - <dependency> | |
| 27 | - <groupId>cn.iocoder.boot</groupId> | |
| 28 | - <artifactId>yudao-module-member-api</artifactId> | |
| 29 | - <version>${revision}</version> | |
| 30 | - </dependency> | |
| 31 | 26 | |
| 32 | 27 | <!-- 业务组件 --> |
| 33 | 28 | <dependency> | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.controller.admin.wallet; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollectionUtil; | |
| 4 | -import cn.hutool.core.util.StrUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | |
| 8 | -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 9 | 5 | import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; |
| 10 | 6 | import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; |
| 11 | 7 | 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; |
| 14 | 10 | import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; |
| 15 | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 16 | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 13 | +import jakarta.annotation.Resource; | |
| 14 | +import jakarta.validation.Valid; | |
| 17 | 15 | import lombok.extern.slf4j.Slf4j; |
| 18 | 16 | import org.springframework.security.access.prepost.PreAuthorize; |
| 19 | 17 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -21,14 +19,8 @@ import org.springframework.web.bind.annotation.GetMapping; |
| 21 | 19 | import org.springframework.web.bind.annotation.RequestMapping; |
| 22 | 20 | import org.springframework.web.bind.annotation.RestController; |
| 23 | 21 | |
| 24 | -import jakarta.annotation.Resource; | |
| 25 | -import jakarta.validation.Valid; | |
| 26 | -import java.util.List; | |
| 27 | -import java.util.Map; | |
| 28 | - | |
| 29 | 22 | import static cn.iocoder.yudao.framework.common.enums.UserTypeEnum.MEMBER; |
| 30 | 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 32 | 24 | |
| 33 | 25 | @Tag(name = "管理后台 - 用户钱包") |
| 34 | 26 | @RestController |
| ... | ... | @@ -39,38 +31,21 @@ public class PayWalletController { |
| 39 | 31 | |
| 40 | 32 | @Resource |
| 41 | 33 | private PayWalletService payWalletService; |
| 42 | - @Resource | |
| 43 | - private MemberUserApi memberUserApi; | |
| 44 | 34 | |
| 45 | 35 | @GetMapping("/get") |
| 46 | 36 | @PreAuthorize("@ss.hasPermission('pay:wallet:query')") |
| 47 | 37 | @Operation(summary = "获得用户钱包明细") |
| 48 | 38 | public CommonResult<PayWalletRespVO> getWallet(PayWalletUserReqVO reqVO) { |
| 49 | 39 | PayWalletDO wallet = payWalletService.getOrCreateWallet(reqVO.getUserId(), MEMBER.getValue()); |
| 50 | - // TODO jason:如果为空,返回给前端只要 null 就可以了 | |
| 51 | - MemberUserRespDTO memberUser = memberUserApi.getUser(reqVO.getUserId()); | |
| 52 | - String nickname = memberUser == null ? "" : memberUser.getNickname(); | |
| 53 | - String avatar = memberUser == null ? "" : memberUser.getAvatar(); | |
| 54 | - return success(PayWalletConvert.INSTANCE.convert02(nickname, avatar, wallet)); | |
| 40 | + return success(PayWalletConvert.INSTANCE.convert02(wallet)); | |
| 55 | 41 | } |
| 56 | 42 | |
| 57 | 43 | @GetMapping("/page") |
| 58 | 44 | @Operation(summary = "获得会员钱包分页") |
| 59 | 45 | @PreAuthorize("@ss.hasPermission('pay:wallet:query')") |
| 60 | 46 | public CommonResult<PageResult<PayWalletRespVO>> getWalletPage(@Valid PayWalletPageReqVO pageVO) { |
| 61 | - if (StrUtil.isNotEmpty(pageVO.getNickname())) { | |
| 62 | - List<MemberUserRespDTO> users = memberUserApi.getUserListByNickname(pageVO.getNickname()); | |
| 63 | - pageVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); | |
| 64 | - } | |
| 65 | - // TODO @jason:管理员也可以先查询下。。 | |
| 66 | - // 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景 | |
| 67 | - PageResult<PayWalletDO> pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO); | |
| 68 | - if (CollectionUtil.isEmpty(pageResult.getList())) { | |
| 69 | - return success(new PageResult<>(pageResult.getTotal())); | |
| 70 | - } | |
| 71 | - List<MemberUserRespDTO> users = memberUserApi.getUserList(convertList(pageResult.getList(), PayWalletDO::getUserId)); | |
| 72 | - Map<Long, MemberUserRespDTO> userMap = convertMap(users, MemberUserRespDTO::getId); | |
| 73 | - return success(PayWalletConvert.INSTANCE.convertPage(pageResult, userMap)); | |
| 47 | + PageResult<PayWalletDO> pageResult = payWalletService.getWalletPage(pageVO); | |
| 48 | + return success(PayWalletConvert.INSTANCE.convertPage(pageResult)); | |
| 74 | 49 | } |
| 75 | 50 | |
| 76 | 51 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 7 | import lombok.Data; |
| 6 | 8 | import lombok.EqualsAndHashCode; |
| ... | ... | @@ -8,7 +10,6 @@ import lombok.ToString; |
| 8 | 10 | import org.springframework.format.annotation.DateTimeFormat; |
| 9 | 11 | |
| 10 | 12 | import java.time.LocalDateTime; |
| 11 | -import java.util.Collection; | |
| 12 | 13 | |
| 13 | 14 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 14 | 15 | |
| ... | ... | @@ -18,11 +19,12 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 18 | 19 | @ToString(callSuper = true) |
| 19 | 20 | public class PayWalletPageReqVO extends PageParam { |
| 20 | 21 | |
| 21 | - @Schema(description = "用户昵称", example = "李四") | |
| 22 | - private String nickname; | |
| 22 | + @Schema(description = "用户编号", example = "1024") | |
| 23 | + private Long userId; | |
| 23 | 24 | |
| 24 | - @Schema(description = "用户编号", example = "[1,2]") | |
| 25 | - private Collection<Long> userIds; | |
| 25 | + @Schema(description = "用户类型", example = "1") | |
| 26 | + @InEnum(value = UserTypeEnum.class) | |
| 27 | + private Integer userType; | |
| 26 | 28 | |
| 27 | 29 | @Schema(description = "创建时间") |
| 28 | 30 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ... | ... |
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 { |
| 19 | 19 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 20 | 20 | private LocalDateTime createTime; |
| 21 | 21 | |
| 22 | - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") | |
| 23 | - private String nickname; | |
| 24 | - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") | |
| 25 | - private String avatar; | |
| 26 | - | |
| 27 | 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 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 5 | -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 6 | 4 | import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; |
| 7 | 5 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; |
| 8 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 9 | 7 | import org.mapstruct.Mapper; |
| 10 | 8 | import org.mapstruct.factory.Mappers; |
| 11 | 9 | |
| 12 | -import java.util.Map; | |
| 13 | - | |
| 14 | 10 | @Mapper |
| 15 | 11 | public interface PayWalletConvert { |
| 16 | 12 | |
| ... | ... | @@ -18,15 +14,8 @@ public interface PayWalletConvert { |
| 18 | 14 | |
| 19 | 15 | AppPayWalletRespVO convert(PayWalletDO bean); |
| 20 | 16 | |
| 21 | - PayWalletRespVO convert02(String nickname,String avatar, PayWalletDO bean); | |
| 17 | + PayWalletRespVO convert02(PayWalletDO bean); | |
| 22 | 18 | |
| 23 | 19 | PageResult<PayWalletRespVO> convertPage(PageResult<PayWalletDO> page); |
| 24 | 20 | |
| 25 | - default PageResult<PayWalletRespVO> convertPage(PageResult<PayWalletDO> page, Map<Long, MemberUserRespDTO> userMap) { | |
| 26 | - PageResult<PayWalletRespVO> pageResult = convertPage(page); | |
| 27 | - pageResult.getList().forEach(wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(), | |
| 28 | - user -> wallet.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); | |
| 29 | - return pageResult; | |
| 30 | - } | |
| 31 | - | |
| 32 | 21 | } | ... | ... |
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> { |
| 17 | 17 | PayWalletDO::getUserType, userType); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - default PageResult<PayWalletDO> selectPage(Integer userType, PayWalletPageReqVO reqVO) { | |
| 20 | + default PageResult<PayWalletDO> selectPage(PayWalletPageReqVO reqVO) { | |
| 21 | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<PayWalletDO>() |
| 22 | - .inIfPresent(PayWalletDO::getUserId, reqVO.getUserIds()) | |
| 23 | - .eqIfPresent(PayWalletDO::getUserType, userType) | |
| 22 | + .eqIfPresent(PayWalletDO::getUserId, reqVO.getUserId()) | |
| 23 | + .eqIfPresent(PayWalletDO::getUserType, reqVO.getUserType()) | |
| 24 | 24 | .betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime()) |
| 25 | 25 | .orderByDesc(PayWalletDO::getId)); |
| 26 | 26 | } |
| ... | ... | @@ -31,7 +31,7 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> { |
| 31 | 31 | * @param id 钱包 id |
| 32 | 32 | * @param price 消费金额 |
| 33 | 33 | */ |
| 34 | - default int updateWhenConsumptionRefund(Long id, Integer price){ | |
| 34 | + default int updateWhenConsumptionRefund(Long id, Integer price) { | |
| 35 | 35 | LambdaUpdateWrapper<PayWalletDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<PayWalletDO>() |
| 36 | 36 | .setSql(" balance = balance + " + price |
| 37 | 37 | + ", total_expense = total_expense - " + price) | ... | ... |
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 { |
| 36 | 36 | * @param pageReqVO 分页查询 |
| 37 | 37 | * @return 会员钱包分页 |
| 38 | 38 | */ |
| 39 | - PageResult<PayWalletDO> getWalletPage(Integer userType, PayWalletPageReqVO pageReqVO); | |
| 39 | + PageResult<PayWalletDO> getWalletPage(PayWalletPageReqVO pageReqVO); | |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * 钱包订单支付 | ... | ... |
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 { |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | @Override |
| 68 | - public PageResult<PayWalletDO> getWalletPage(Integer userType,PayWalletPageReqVO pageReqVO) { | |
| 69 | - return walletMapper.selectPage(userType, pageReqVO); | |
| 68 | + public PageResult<PayWalletDO> getWalletPage(PayWalletPageReqVO pageReqVO) { | |
| 69 | + return walletMapper.selectPage(pageReqVO); | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | @Override | ... | ... |