From fdb2d7339fbec1163d53ebd1bce35207aa55290b Mon Sep 17 00:00:00 2001 From: luowenfeng <1092164058@qq.com> Date: Wed, 21 Sep 2022 15:57:32 +0800 Subject: [PATCH] =?UTF-8?q?feature(=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0):?= =?UTF-8?q?=20=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/spu/vo/ProductSpuPageReqVO.java | 15 + .../dal/mysql/spu/ProductSpuMapper.java | 27 ++ .../service/sku/ProductSkuService.java | 7 + .../service/sku/ProductSkuServiceImpl.java | 8 + .../service/spu/ProductSpuServiceImpl.java | 21 +- .../src/views/mall/product/property/value.vue | 64 ++-- .../src/views/mall/product/spu/index.vue | 358 ++++++++++++++---- .../src/views/mall/product/spu/save.vue | 283 +++++++------- 8 files changed, 535 insertions(+), 248 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java index 2f0dd57e0..3edda8b40 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java @@ -29,4 +29,19 @@ public class ProductSpuPageReqVO extends PageParam { @ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)") private Integer status; + @ApiModelProperty(value = "销量最小值", example = "1") + private Integer salesCountMin; + + @ApiModelProperty(value = "销量最大值", example = "1024") + private Integer salesCountMax; + + @ApiModelProperty(value = "市场价最小值", example = "1") + private Integer marketPriceMin; + + @ApiModelProperty(value = "市场价最大值", example = "1024") + private Integer marketPriceMax; + + @ApiModelProperty(value = "tab 状态 null 全部, 0:销售中(上架) 1:仓库中(下架) 2:预警中", example = "1") + private Integer tabStatus; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java index 49243c8d4..c2ade63c7 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java @@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReq import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 商品spu Mapper * @@ -20,7 +22,32 @@ public interface ProductSpuMapper extends BaseMapperX { .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) .eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus()) + .leIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMax()) + .geIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMin()) + .leIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMax()) + .geIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMin()) .orderByDesc(ProductSpuDO::getSort)); } + default PageResult selectPage(ProductSpuPageReqVO reqVO, List spuIds) { + LambdaQueryWrapperX productSpuDOLambdaQueryWrapperX = new LambdaQueryWrapperX() + .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) + .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) + .eqIfPresent(ProductSpuDO::getStatus, reqVO.getStatus()) + .leIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMax()) + .geIfPresent(ProductSpuDO::getSalesCount, reqVO.getSalesCountMin()) + .leIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMax()) + .geIfPresent(ProductSpuDO::getMarketPrice, reqVO.getMarketPriceMin()) + .orderByDesc(ProductSpuDO::getSort); + + if(reqVO.getTabStatus()!= null && reqVO.getTabStatus() == 2){ + productSpuDOLambdaQueryWrapperX.inIfPresent(ProductSpuDO::getId, spuIds); + }else{ + productSpuDOLambdaQueryWrapperX.eqIfPresent(ProductSpuDO::getStatus, reqVO.getTabStatus()); + } + + return selectPage(reqVO, productSpuDOLambdaQueryWrapperX); + } + + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java index 5316f4764..288e2fbb1 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java @@ -83,4 +83,11 @@ public interface ProductSkuService { */ void deleteSkuBySpuId(Long spuId); + /** + * 获得商品预警中的spu集合 + * + * @return 商品spuId集合 + */ + List getRemindSpuIds(); + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java index 96cea6171..be205178d 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.product.service.sku; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO; import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; @@ -14,6 +15,7 @@ import cn.iocoder.yudao.module.product.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum; import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -131,6 +133,12 @@ public class ProductSkuServiceImpl implements ProductSkuService { productSkuMapper.deleteBySpuId(spuId); } + @Override + public List getRemindSpuIds() { + List productSkuDOS = productSkuMapper.selectList(new QueryWrapper().apply("stock <= warn_stock")); + return productSkuDOS.stream().map(ProductSkuDO::getSpuId).distinct().collect(Collectors.toList()); + } + @Override @Transactional public void updateProductSkus(Long spuId, List skus) { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 9fb13411b..3a0a68d3b 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.product.service.spu; import cn.hutool.core.bean.BeanUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO; import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyViewRespVO; +import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO; import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; @@ -190,16 +190,15 @@ public class ProductSpuServiceImpl implements ProductSpuService { @Override public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { - PageResult spuVOs = ProductSpuConvert.INSTANCE.convertPage(ProductSpuMapper.selectPage(pageReqVO)); - // 查询 sku 的信息 -// List spuIds = spuVOs.getList().stream().map(ProductSpuRespVO::getId).collect(Collectors.toList()); -// List skus = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuIds(spuIds)); - // TODO @franky:使用 CollUtil 里的方法替代哈 - // TODO 芋艿:临时注释 -// Map> skuMap = skus.stream().collect(Collectors.groupingBy(ProductSkuRespVO::getSpuId)); -// // 将 spu 和 sku 进行组装 -// spuVOs.getList().forEach(p -> p.setSkus(skuMap.get(p.getId()))); - return spuVOs; + List remindSpuIds= null; + // todo @yunai 预警类型的判断应该可以优化,看下怎么处理 + if(pageReqVO.getTabStatus() != null && pageReqVO.getTabStatus() == 2){ + remindSpuIds= productSkuService.getRemindSpuIds(); + if(remindSpuIds.isEmpty()){ + remindSpuIds.add(null); + } + } + return ProductSpuConvert.INSTANCE.convertPage(ProductSpuMapper.selectPage(pageReqVO, remindSpuIds)); } @Override diff --git a/yudao-ui-admin/src/views/mall/product/property/value.vue b/yudao-ui-admin/src/views/mall/product/property/value.vue index 99e8f3593..8a116869d 100644 --- a/yudao-ui-admin/src/views/mall/product/property/value.vue +++ b/yudao-ui-admin/src/views/mall/product/property/value.vue @@ -24,7 +24,8 @@ 新增 + v-hasPermi="['system:dict:create']">新增 + - - + - + + :options="categoryList" :props="propName" clearable ref="category"/> - + + + + + + + + + - + + + + + + + + + + + + + + + + - + + + + + + + + 搜索 重置 @@ -35,77 +82,211 @@ 新增 + v-hasPermi="['product:spu:create']">新增 + - + - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + +