mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
✨ MALL:增加商品列表的分类编号数组、商品编号的筛选
This commit is contained in:
parent
f73cb540cf
commit
a259e032e1
@ -67,8 +67,8 @@ public class ProductCategoryController {
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得商品分类列表")
|
||||
@PreAuthorize("@ss.hasPermission('product:category:query')")
|
||||
public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) {
|
||||
List<ProductCategoryDO> list = categoryService.getEnableCategoryList(treeListReqVO);
|
||||
public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO listReqVO) {
|
||||
List<ProductCategoryDO> list = categoryService.getCategoryList(listReqVO);
|
||||
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
||||
return success(ProductCategoryConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.product.controller.admin.category.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Schema(description = "管理后台 - 商品分类列表查询 Request VO")
|
||||
@Data
|
||||
public class ProductCategoryListReqVO {
|
||||
@ -16,4 +18,7 @@ public class ProductCategoryListReqVO {
|
||||
@Schema(description = "父分类编号", example = "1")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "父分类编号数组", example = "1,2,3")
|
||||
private Collection<Long> parentIds;
|
||||
|
||||
}
|
||||
|
@ -4,11 +4,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 商品 SPU 分页 Request VO")
|
||||
@Data
|
||||
@ -26,9 +27,15 @@ public class AppProductSpuPageReqVO extends PageParam {
|
||||
public static final String RECOMMEND_TYPE_NEW = "new";
|
||||
public static final String RECOMMEND_TYPE_GOOD = "good";
|
||||
|
||||
@Schema(description = "商品 SPU 编号数组", example = "1,3,5")
|
||||
private List<Long> ids;
|
||||
|
||||
@Schema(description = "分类编号", example = "1")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "分类编号数组", example = "1,2,3")
|
||||
private List<Long> categoryIds;
|
||||
|
||||
@Schema(description = "关键字", example = "好看")
|
||||
private String keyword;
|
||||
|
||||
|
@ -21,6 +21,7 @@ public interface ProductCategoryMapper extends BaseMapperX<ProductCategoryDO> {
|
||||
return selectList(new LambdaQueryWrapperX<ProductCategoryDO>()
|
||||
.likeIfPresent(ProductCategoryDO::getName, listReqVO.getName())
|
||||
.eqIfPresent(ProductCategoryDO::getParentId, listReqVO.getParentId())
|
||||
.inIfPresent(ProductCategoryDO::getId, listReqVO.getParentIds())
|
||||
.eqIfPresent(ProductCategoryDO::getStatus, listReqVO.getStatus())
|
||||
.orderByDesc(ProductCategoryDO::getId));
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public interface ProductCategoryService {
|
||||
* @param listReqVO 查询条件
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
List<ProductCategoryDO> getEnableCategoryList(ProductCategoryListReqVO listReqVO);
|
||||
List<ProductCategoryDO> getCategoryList(ProductCategoryListReqVO listReqVO);
|
||||
|
||||
/**
|
||||
* 获得开启状态的商品分类列表
|
||||
|
@ -161,7 +161,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductCategoryDO> getEnableCategoryList(ProductCategoryListReqVO listReqVO) {
|
||||
public List<ProductCategoryDO> getCategoryList(ProductCategoryListReqVO listReqVO) {
|
||||
return productCategoryMapper.selectList(listReqVO);
|
||||
}
|
||||
|
||||
|
@ -18,17 +18,16 @@ import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
|
||||
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import com.google.common.collect.Maps;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
@ -215,9 +214,15 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
Set<Long> categoryIds = new HashSet<>();
|
||||
if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) {
|
||||
categoryIds.add(pageReqVO.getCategoryId());
|
||||
List<ProductCategoryDO> categoryChildren = categoryService.getEnableCategoryList(new ProductCategoryListReqVO()
|
||||
.setParentId(pageReqVO.getCategoryId()).setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
categoryIds.addAll(CollectionUtils.convertList(categoryChildren, ProductCategoryDO::getId));
|
||||
List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentId(pageReqVO.getCategoryId()));
|
||||
categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(pageReqVO.getCategoryIds())) {
|
||||
categoryIds.addAll(pageReqVO.getCategoryIds());
|
||||
List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentIds(pageReqVO.getCategoryIds()));
|
||||
categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
|
||||
}
|
||||
// 分页查询
|
||||
return productSpuMapper.selectPage(pageReqVO, categoryIds);
|
||||
|
@ -6,6 +6,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// TODO 芋艿:弱化这个状态
|
||||
/**
|
||||
* 促销活动的状态枚举
|
||||
*
|
||||
|
@ -145,6 +145,7 @@ public class AppActivityController {
|
||||
}
|
||||
|
||||
private void getRewardActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
// TODO @puhui999:有 3 范围,不只 spuId,还有 categoryId,全部
|
||||
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, PromotionActivityStatusEnum.RUN.getStatus(), now);
|
||||
if (CollUtil.isEmpty(rewardActivityList)) {
|
||||
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.reward;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.reward.vo.AppRewardActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 满减送活动")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/reward-activity")
|
||||
@Validated
|
||||
public class AppRewardActivityController {
|
||||
|
||||
@Resource
|
||||
private RewardActivityService rewardActivityService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得满减送活动")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<AppRewardActivityRespVO> getRewardActivity(@RequestParam("id") Long id) {
|
||||
RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id);
|
||||
return success(BeanUtils.toBean(rewardActivity, AppRewardActivityRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.reward.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityBaseVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 满减送活动 Response VO")
|
||||
@Data
|
||||
public class AppRewardActivityRespVO {
|
||||
|
||||
@Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer conditionType;
|
||||
|
||||
@Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer productScope;
|
||||
|
||||
@Schema(description = "商品 SPU 编号的数组", example = "1,2,3")
|
||||
private List<Long> productSpuIds;
|
||||
|
||||
@Schema(description = "优惠规则的数组")
|
||||
private List<RewardActivityBaseVO.Rule> rules;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user