Commit 94a32d34b2a6c9aaba0228bb59b572dca55b003b

Authored by YunaiV
1 parent a4e2cacc

1. 会员用户,增加 point 积分字段

2. 增加获得优惠劵、收藏数量的 API 接口
Showing 18 changed files with 119 additions and 13 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java
... ... @@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.*;
20 20 import javax.annotation.Resource;
21 21 import javax.validation.Valid;
22 22 import java.util.List;
23   -import java.util.Objects;
24 23  
25 24 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
26 25 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
... ... @@ -84,8 +83,15 @@ public class AppFavoriteController {
84 83 @Operation(summary = "检查是否收藏过商品")
85 84 @PreAuthenticated
86 85 public CommonResult<Boolean> isFavoriteExists(AppFavoriteReqVO reqVO) {
87   - ProductFavoriteDO favoriteDO = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
88   - return success(Objects.nonNull(favoriteDO));
  86 + ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
  87 + return success(favorite != null);
  88 + }
  89 +
  90 + @GetMapping(value = "/get-count")
  91 + @Operation(summary = "获得商品收藏数量")
  92 + @PreAuthenticated
  93 + public CommonResult<Long> getFavoriteCount() {
  94 + return success(productFavoriteService.getFavoriteCount(getLoginUserId()));
89 95 }
90 96  
91 97 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java
... ... @@ -21,4 +21,8 @@ public interface ProductFavoriteMapper extends BaseMapperX&lt;ProductFavoriteDO&gt; {
21 21 .orderByDesc(ProductFavoriteDO::getId));
22 22 }
23 23  
  24 + default Long selectCountByUserId(Long userId) {
  25 + return selectCount(ProductFavoriteDO::getUserId, userId);
  26 + }
  27 +
24 28 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java
... ... @@ -16,7 +16,7 @@ public interface ProductFavoriteService {
16 16 /**
17 17 * 创建商品收藏
18 18 *
19   - * @param userId 用户 id
  19 + * @param userId 用户编号
20 20 * @param spuId SPU 编号
21 21 */
22 22 Long createFavorite(Long userId, Long spuId);
... ... @@ -24,7 +24,7 @@ public interface ProductFavoriteService {
24 24 /**
25 25 * 取消商品收藏
26 26 *
27   - * @param userId 用户 id
  27 + * @param userId 用户编号
28 28 * @param spuId SPU 编号
29 29 */
30 30 void deleteFavorite(Long userId, Long spuId);
... ... @@ -32,7 +32,7 @@ public interface ProductFavoriteService {
32 32 /**
33 33 * 分页查询用户收藏列表
34 34 *
35   - * @param userId 用户 id
  35 + * @param userId 用户编号
36 36 * @param reqVO 请求 vo
37 37 */
38 38 PageResult<ProductFavoriteDO> getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO);
... ... @@ -40,9 +40,17 @@ public interface ProductFavoriteService {
40 40 /**
41 41 * 获取收藏过商品
42 42 *
43   - * @param userId 用户id
  43 + * @param userId 用户编号
44 44 * @param spuId SPU 编号
45 45 */
46 46 ProductFavoriteDO getFavorite(Long userId, Long spuId);
47 47  
  48 + /**
  49 + * 获取用户收藏数量
  50 + *
  51 + * @param userId 用户编号
  52 + * @return 数量
  53 + */
  54 + Long getFavoriteCount(Long userId);
  55 +
48 56 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java
... ... @@ -10,7 +10,6 @@ import org.springframework.validation.annotation.Validated;
10 10  
11 11 import javax.annotation.Resource;
12 12 import javax.validation.Valid;
13   -import java.util.Objects;
14 13  
15 14 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
16 15 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_EXISTS;
... ... @@ -31,7 +30,7 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
31 30 @Override
32 31 public Long createFavorite(Long userId, Long spuId) {
33 32 ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
34   - if (Objects.nonNull(favorite)) {
  33 + if (favorite != null) {
35 34 throw exception(FAVORITE_EXISTS);
36 35 }
37 36  
... ... @@ -43,7 +42,7 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
43 42 @Override
44 43 public void deleteFavorite(Long userId, Long spuId) {
45 44 ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
46   - if (Objects.isNull(favorite)) {
  45 + if (favorite == null) {
47 46 throw exception(FAVORITE_NOT_EXISTS);
48 47 }
49 48  
... ... @@ -60,4 +59,9 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
60 59 return productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
61 60 }
62 61  
  62 + @Override
  63 + public Long getFavoriteCount(Long userId) {
  64 + return productFavoriteMapper.selectCountByUserId(userId);
  65 + }
  66 +
63 67 }
... ...
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java
... ... @@ -15,7 +15,9 @@ import java.util.Arrays;
15 15 @Getter
16 16 public enum DecoratePageEnum implements IntArrayValuable {
17 17  
18   - INDEX(1, "首页");
  18 + INDEX(1, "首页"),
  19 + MY(2, "个人中心"),
  20 + ;
19 21  
20 22 private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray();
21 23  
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java
... ... @@ -2,22 +2,26 @@ package cn.iocoder.yudao.module.promotion.controller.app.coupon;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
5 6 import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO;
6 7 import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchRespVO;
7 8 import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO;
8 9 import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO;
9 10 import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
  11 +import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
10 12 import io.swagger.v3.oas.annotations.Operation;
11 13 import io.swagger.v3.oas.annotations.tags.Tag;
12 14 import org.springframework.validation.annotation.Validated;
13 15 import org.springframework.web.bind.annotation.*;
14 16  
  17 +import javax.annotation.Resource;
15 18 import java.time.LocalDateTime;
16 19 import java.util.ArrayList;
17 20 import java.util.List;
18 21 import java.util.Random;
19 22  
20 23 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  24 +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
21 25  
22 26 @Tag(name = "用户 App - 优惠劵")
23 27 @RestController
... ... @@ -25,6 +29,9 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
25 29 @Validated
26 30 public class AppCouponController {
27 31  
  32 + @Resource
  33 + private CouponService couponService;
  34 +
28 35 // TODO 芋艿:待实现
29 36 @PostMapping("/take")
30 37 @Operation(summary = "领取优惠劵")
... ... @@ -93,4 +100,11 @@ public class AppCouponController {
93 100 return success(new PageResult<>(list, 20L));
94 101 }
95 102  
  103 + @GetMapping(value = "/get-unused-count")
  104 + @Operation(summary = "获得未使用的优惠劵数量")
  105 + @PreAuthenticated
  106 + public CommonResult<Long> getUnusedCouponCount() {
  107 + return success(couponService.getUnusedCouponCount(getLoginUserId()));
  108 + }
  109 +
96 110 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java
... ... @@ -49,4 +49,10 @@ public interface CouponMapper extends BaseMapperX&lt;CouponDO&gt; {
49 49 .eq(CouponDO::getId, id).eq(CouponDO::getStatus, status));
50 50 }
51 51  
  52 + default Long selectCountByUserIdAndStatus(Long userId, Integer status) {
  53 + return selectCount(new LambdaQueryWrapperX<CouponDO>()
  54 + .eq(CouponDO::getUserId, userId)
  55 + .eq(CouponDO::getStatus, status));
  56 + }
  57 +
52 58 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java
... ... @@ -67,4 +67,12 @@ public interface CouponService {
67 67 */
68 68 List<CouponDO> getCouponList(Long userId, Integer status);
69 69  
  70 + /**
  71 + * 获得未使用的优惠劵数量
  72 + *
  73 + * @param userId 用户编号
  74 + * @return 未使用的优惠劵数量
  75 + */
  76 + Long getUnusedCouponCount(Long userId);
  77 +
70 78 }
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
... ... @@ -120,4 +120,9 @@ public class CouponServiceImpl implements CouponService {
120 120 }
121 121 }
122 122  
  123 + @Override
  124 + public Long getUnusedCouponCount(Long userId) {
  125 + return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus());
  126 + }
  127 +
123 128 }
... ...
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/TradeAfterSaleStatusEnum.java
... ... @@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
5 5 import lombok.Getter;
6 6  
7 7 import java.util.Arrays;
  8 +import java.util.Collection;
8 9  
9 10 import static cn.hutool.core.util.ArrayUtil.firstMatch;
10 11  
... ... @@ -56,6 +57,18 @@ public enum TradeAfterSaleStatusEnum implements IntArrayValuable {
56 57 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeAfterSaleStatusEnum::getStatus).toArray();
57 58  
58 59 /**
  60 + * 进行中的售后状态
  61 + *
  62 + * 不包括已经结束的状态
  63 + */
  64 + public static final Collection<Integer> APPLYING_STATUSES = Arrays.asList(
  65 + APPLY.getStatus(),
  66 + SELLER_AGREE.getStatus(),
  67 + BUYER_DELIVERY.getStatus(),
  68 + WAIT_REFUND.getStatus()
  69 + );
  70 +
  71 + /**
59 72 * 状态
60 73 */
61 74 private final Integer status;
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java
... ... @@ -50,6 +50,12 @@ public class AppTradeAfterSaleController {
50 50 return success(TradeAfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id)));
51 51 }
52 52  
  53 + @GetMapping(value = "/get-applying-count")
  54 + @Operation(summary = "获得进行中的售后订单数量")
  55 + public CommonResult<Long> getApplyingAfterSaleCount() {
  56 + return success(afterSaleService.getApplyingAfterSaleCount(getLoginUserId()));
  57 + }
  58 +
53 59 // TODO 芋艿:待实现
54 60 @GetMapping(value = "/get-reason-list")
55 61 @Operation(summary = "获得售后原因")
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/TradeAfterSaleMapper.java
... ... @@ -9,6 +9,8 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO;
9 9 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
10 10 import org.apache.ibatis.annotations.Mapper;
11 11  
  12 +import java.util.Collection;
  13 +
12 14 @Mapper
13 15 public interface TradeAfterSaleMapper extends BaseMapperX<TradeAfterSaleDO> {
14 16  
... ... @@ -40,4 +42,10 @@ public interface TradeAfterSaleMapper extends BaseMapperX&lt;TradeAfterSaleDO&gt; {
40 42 TradeAfterSaleDO::getUserId, userId);
41 43 }
42 44  
  45 + default Long selectCountByUserIdAndStatus(Long userId, Collection<Integer> statuses) {
  46 + return selectCount(new LambdaQueryWrapperX<TradeAfterSaleDO>()
  47 + .eq(TradeAfterSaleDO::getUserId, userId)
  48 + .in(TradeAfterSaleDO::getStatus, statuses));
  49 + }
  50 +
43 51 }
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleService.java
... ... @@ -108,4 +108,12 @@ public interface TradeAfterSaleService {
108 108 */
109 109 void cancelAfterSale(Long userId, Long id);
110 110  
  111 + /**
  112 + * 【会员】获得正在进行中的售后订单数量
  113 + *
  114 + * @param userId
  115 + * @return 数量
  116 + */
  117 + Long getApplyingAfterSaleCount(Long userId);
  118 +
111 119 }
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
... ... @@ -398,6 +398,11 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
398 398 TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
399 399 }
400 400  
  401 + @Override
  402 + public Long getApplyingAfterSaleCount(Long userId) {
  403 + return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, TradeAfterSaleStatusEnum.APPLYING_STATUSES);
  404 + }
  405 +
401 406 @Deprecated
402 407 private void createAfterSaleLog(Long userId, Integer userType, TradeAfterSaleDO afterSale,
403 408 Integer beforeStatus, Integer afterStatus) {
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.http renamed to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.http
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.java renamed to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.java
... ... @@ -27,7 +27,7 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_IS_EMP
27 27 @RequestMapping("/member/user")
28 28 @Validated
29 29 @Slf4j
30   -public class AppUserController {
  30 +public class AppMemberUserController {
31 31  
32 32 @Resource
33 33 private MemberUserService userService;
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppUserInfoRespVO.java
... ... @@ -14,9 +14,13 @@ public class AppUserInfoRespVO {
14 14 @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
15 15 private String nickname;
16 16  
17   - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "/infra/file/get/35a12e57-4297-4faa-bf7d-7ed2f211c952")
  17 + @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.png")
18 18 private String avatar;
19 19  
20 20 @Schema(description = "用户手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300")
21 21 private String mobile;
  22 +
  23 + @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
  24 + private Integer point;
  25 +
22 26 }
... ...
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java
... ... @@ -102,6 +102,11 @@ public class MemberUserDO extends TenantBaseDO {
102 102  
103 103 // ========== 其它信息 ==========
104 104  
  105 + /**
  106 + * 积分
  107 + */
  108 + private Integer point;
  109 +
105 110 // TODO 积分、成长值、会员等级等等
106 111  
107 112 }
... ...