Commit a259e032e15e44361b4db1522330aa63f5680cd7

Authored by YunaiV
1 parent f73cb540

✨ MALL:增加商品列表的分类编号数组、商品编号的筛选

Showing 11 changed files with 102 additions and 11 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java
... ... @@ -67,8 +67,8 @@ public class ProductCategoryController {
67 67 @GetMapping("/list")
68 68 @Operation(summary = "获得商品分类列表")
69 69 @PreAuthorize("@ss.hasPermission('product:category:query')")
70   - public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) {
71   - List<ProductCategoryDO> list = categoryService.getEnableCategoryList(treeListReqVO);
  70 + public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO listReqVO) {
  71 + List<ProductCategoryDO> list = categoryService.getCategoryList(listReqVO);
72 72 list.sort(Comparator.comparing(ProductCategoryDO::getSort));
73 73 return success(ProductCategoryConvert.INSTANCE.convertList(list));
74 74 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java
... ... @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.product.controller.admin.category.vo;
3 3 import io.swagger.v3.oas.annotations.media.Schema;
4 4 import lombok.Data;
5 5  
  6 +import java.util.Collection;
  7 +
6 8 @Schema(description = "管理后台 - 商品分类列表查询 Request VO")
7 9 @Data
8 10 public class ProductCategoryListReqVO {
... ... @@ -16,4 +18,7 @@ public class ProductCategoryListReqVO {
16 18 @Schema(description = "父分类编号", example = "1")
17 19 private Long parentId;
18 20  
  21 + @Schema(description = "父分类编号数组", example = "1,2,3")
  22 + private Collection<Long> parentIds;
  23 +
19 24 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
... ... @@ -4,11 +4,12 @@ import cn.hutool.core.util.StrUtil;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageParam;
5 5 import com.fasterxml.jackson.annotation.JsonIgnore;
6 6 import io.swagger.v3.oas.annotations.media.Schema;
  7 +import jakarta.validation.constraints.AssertTrue;
7 8 import lombok.Data;
8 9 import lombok.EqualsAndHashCode;
9 10 import lombok.ToString;
10 11  
11   -import jakarta.validation.constraints.AssertTrue;
  12 +import java.util.List;
12 13  
13 14 @Schema(description = "用户 App - 商品 SPU 分页 Request VO")
14 15 @Data
... ... @@ -26,9 +27,15 @@ public class AppProductSpuPageReqVO extends PageParam {
26 27 public static final String RECOMMEND_TYPE_NEW = "new";
27 28 public static final String RECOMMEND_TYPE_GOOD = "good";
28 29  
  30 + @Schema(description = "商品 SPU 编号数组", example = "1,3,5")
  31 + private List<Long> ids;
  32 +
29 33 @Schema(description = "分类编号", example = "1")
30 34 private Long categoryId;
31 35  
  36 + @Schema(description = "分类编号数组", example = "1,2,3")
  37 + private List<Long> categoryIds;
  38 +
32 39 @Schema(description = "关键字", example = "好看")
33 40 private String keyword;
34 41  
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java
... ... @@ -21,6 +21,7 @@ public interface ProductCategoryMapper extends BaseMapperX&lt;ProductCategoryDO&gt; {
21 21 return selectList(new LambdaQueryWrapperX<ProductCategoryDO>()
22 22 .likeIfPresent(ProductCategoryDO::getName, listReqVO.getName())
23 23 .eqIfPresent(ProductCategoryDO::getParentId, listReqVO.getParentId())
  24 + .inIfPresent(ProductCategoryDO::getId, listReqVO.getParentIds())
24 25 .eqIfPresent(ProductCategoryDO::getStatus, listReqVO.getStatus())
25 26 .orderByDesc(ProductCategoryDO::getId));
26 27 }
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java
... ... @@ -67,7 +67,7 @@ public interface ProductCategoryService {
67 67 * @param listReqVO 查询条件
68 68 * @return 商品分类列表
69 69 */
70   - List<ProductCategoryDO> getEnableCategoryList(ProductCategoryListReqVO listReqVO);
  70 + List<ProductCategoryDO> getCategoryList(ProductCategoryListReqVO listReqVO);
71 71  
72 72 /**
73 73 * 获得开启状态的商品分类列表
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java
... ... @@ -161,7 +161,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
161 161 }
162 162  
163 163 @Override
164   - public List<ProductCategoryDO> getEnableCategoryList(ProductCategoryListReqVO listReqVO) {
  164 + public List<ProductCategoryDO> getCategoryList(ProductCategoryListReqVO listReqVO) {
165 165 return productCategoryMapper.selectList(listReqVO);
166 166 }
167 167  
... ...
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
... ... @@ -18,17 +18,16 @@ import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
18 18 import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
19 19 import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
20 20 import com.google.common.collect.Maps;
  21 +import jakarta.annotation.Resource;
21 22 import org.springframework.context.annotation.Lazy;
22 23 import org.springframework.stereotype.Service;
23 24 import org.springframework.transaction.annotation.Transactional;
24 25 import org.springframework.validation.annotation.Validated;
25 26  
26   -import jakarta.annotation.Resource;
27 27 import java.util.*;
28 28  
29 29 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
30   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue;
31   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
  30 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
32 31 import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
33 32 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
34 33  
... ... @@ -215,9 +214,15 @@ public class ProductSpuServiceImpl implements ProductSpuService {
215 214 Set<Long> categoryIds = new HashSet<>();
216 215 if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) {
217 216 categoryIds.add(pageReqVO.getCategoryId());
218   - List<ProductCategoryDO> categoryChildren = categoryService.getEnableCategoryList(new ProductCategoryListReqVO()
219   - .setParentId(pageReqVO.getCategoryId()).setStatus(CommonStatusEnum.ENABLE.getStatus()));
220   - categoryIds.addAll(CollectionUtils.convertList(categoryChildren, ProductCategoryDO::getId));
  217 + List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
  218 + .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentId(pageReqVO.getCategoryId()));
  219 + categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
  220 + }
  221 + if (CollUtil.isNotEmpty(pageReqVO.getCategoryIds())) {
  222 + categoryIds.addAll(pageReqVO.getCategoryIds());
  223 + List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
  224 + .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentIds(pageReqVO.getCategoryIds()));
  225 + categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
221 226 }
222 227 // 分页查询
223 228 return productSpuMapper.selectPage(pageReqVO, categoryIds);
... ...
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java
... ... @@ -6,6 +6,7 @@ import lombok.Getter;
6 6  
7 7 import java.util.Arrays;
8 8  
  9 +// TODO 芋艿:弱化这个状态
9 10 /**
10 11 * 促销活动的状态枚举
11 12 *
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java
... ... @@ -145,6 +145,7 @@ public class AppActivityController {
145 145 }
146 146  
147 147 private void getRewardActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
  148 + // TODO @puhui999:有 3 范围,不只 spuId,还有 categoryId,全部
148 149 List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityBySpuIdsAndStatusAndDateTimeLt(
149 150 spuIds, PromotionActivityStatusEnum.RUN.getStatus(), now);
150 151 if (CollUtil.isEmpty(rewardActivityList)) {
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/AppRewardActivityController.java 0 → 100755
  1 +package cn.iocoder.yudao.module.promotion.controller.app.reward;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  5 +import cn.iocoder.yudao.module.promotion.controller.app.reward.vo.AppRewardActivityRespVO;
  6 +import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
  7 +import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
  8 +import io.swagger.v3.oas.annotations.Operation;
  9 +import io.swagger.v3.oas.annotations.Parameter;
  10 +import io.swagger.v3.oas.annotations.tags.Tag;
  11 +import jakarta.annotation.Resource;
  12 +import org.springframework.validation.annotation.Validated;
  13 +import org.springframework.web.bind.annotation.GetMapping;
  14 +import org.springframework.web.bind.annotation.RequestMapping;
  15 +import org.springframework.web.bind.annotation.RequestParam;
  16 +import org.springframework.web.bind.annotation.RestController;
  17 +
  18 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  19 +
  20 +@Tag(name = "用户 App - 满减送活动")
  21 +@RestController
  22 +@RequestMapping("/promotion/reward-activity")
  23 +@Validated
  24 +public class AppRewardActivityController {
  25 +
  26 + @Resource
  27 + private RewardActivityService rewardActivityService;
  28 +
  29 + @GetMapping("/get")
  30 + @Operation(summary = "获得满减送活动")
  31 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  32 + public CommonResult<AppRewardActivityRespVO> getRewardActivity(@RequestParam("id") Long id) {
  33 + RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id);
  34 + return success(BeanUtils.toBean(rewardActivity, AppRewardActivityRespVO.class));
  35 + }
  36 +
  37 +}
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/vo/AppRewardActivityRespVO.java 0 → 100755
  1 +package cn.iocoder.yudao.module.promotion.controller.app.reward.vo;
  2 +
  3 +import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityBaseVO;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +
  7 +import java.util.List;
  8 +
  9 +@Schema(description = "用户 App - 满减送活动 Response VO")
  10 +@Data
  11 +public class AppRewardActivityRespVO {
  12 +
  13 + @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  14 + private Integer id;
  15 +
  16 + @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  17 + private Integer status;
  18 +
  19 + @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦")
  20 + private String name;
  21 +
  22 + @Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  23 + private Integer conditionType;
  24 +
  25 + @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  26 + private Integer productScope;
  27 +
  28 + @Schema(description = "商品 SPU 编号的数组", example = "1,2,3")
  29 + private List<Long> productSpuIds;
  30 +
  31 + @Schema(description = "优惠规则的数组")
  32 + private List<RewardActivityBaseVO.Rule> rules;
  33 +
  34 +}
... ...