浏览代码

文档分类、文档文件过滤调整

FengChaoYu 1 月之前
父节点
当前提交
1f8f2835fc

+ 3 - 4
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/goods/GoodsController.java

@@ -130,14 +130,14 @@ public class GoodsController {
             @ApiParam(value = "商品关键字") @RequestParam(required = false) String keyword,
             @ApiParam(value = "排序 0=综合 1=销量 2=价格升 3=价格降 4=上新") @RequestParam(required = false, defaultValue = "0") Integer sort,
             @ApiParam(value = "分类id") @RequestParam(required = false) String categoryId,
-            @ApiParam(value = "是否只查询以旧换新的商品", required = false) @RequestParam(required = false) Boolean yjhx,
             @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
             @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
     ) throws Exception {
-        IPage<GoodsNewBean> page = goodsLogic.page(request, brandId, minPrice, maxPrice, tag, keyword, categoryId, sort, yjhx, pageNum, pageSize);
+        IPage<GoodsNewBean> page = goodsLogic.page(request, brandId, minPrice, maxPrice, tag, keyword, categoryId, sort, pageNum, pageSize);
         return ResponseHelper.success(page);
     }
 
+    @ApiNotAuth
     @GetMapping("/list/sort/page")
     @ApiOperation(value = "商品列表")
     public ResponseHelper<IPage<GoodsNewBean>> page1(
@@ -149,11 +149,10 @@ public class GoodsController {
             @ApiParam(value = "商品关键字") @RequestParam(required = false) String keyword,
             @ApiParam(value = "排序 0=综合 1=销量 2=价格升 3=价格降 4=上新") @RequestParam(required = false, defaultValue = "0") Integer sort,
             @ApiParam(value = "分类id") @RequestParam(required = false) String categoryId,
-            @ApiParam(value = "是否只查询以旧换新的商品", required = false) @RequestParam(required = false) Boolean yjhx,
             @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
             @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
     ) throws Exception {
-        IPage<GoodsNewBean> page = goodsLogic.page(request, brandId, minPrice, maxPrice, tag, keyword, categoryId, sort, yjhx, pageNum, pageSize);
+        IPage<GoodsNewBean> page = goodsLogic.page(request, brandId, minPrice, maxPrice, tag, keyword, categoryId, sort, pageNum, pageSize);
         return ResponseHelper.success(page);
     }
 

+ 4 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsCategoryBean.java

@@ -1,6 +1,7 @@
 package com.gree.mall.manager.bean.goods;
 
 import com.gree.mall.manager.plus.entity.GoodsCategory;
+import com.gree.mall.manager.plus.entity.GoodsCategoryRela;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -15,4 +16,7 @@ public class GoodsCategoryBean extends GoodsCategory {
 
     @ApiModelProperty( value = "子类别")
     private List<GoodsCategoryBean> children;
+
+    @ApiModelProperty( value = "商品一级分类")
+    private List<GoodsCategoryRela> goodsCategoryRelaList;
 }

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsDocumentsBean.java

@@ -14,6 +14,6 @@ import java.util.List;
 @ApiModel
 public class GoodsDocumentsBean extends GoodsDocuments {
 
-    @ApiModelProperty
+    @ApiModelProperty(value = "文件列表")
     private List<CommonFile> fileList;
 }

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/CommonMapper.java

@@ -640,5 +640,5 @@ public interface CommonMapper {
      * @param page
      * @return
      */
-    IPage<GoodsDocumentsFileVO> goodsDocumentsFileList(Page page, @Param("ex") ZfireParamBean zfireParamBean);
+    IPage<GoodsDocumentsFileVO> goodsDocumentsFileList(Page page, @Param("ex") ZfireParamBean zfireParamBean, @Param("categoryList") List<String> categoryList);
 }

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/CustomGoodsCategoryMapper.java

@@ -9,6 +9,6 @@ public interface CustomGoodsCategoryMapper {
 
 
     List<GoodsCategoryBean> list(@Param("type") Integer type, @Param("level") Integer level, @Param("status") Boolean status,
-                                 @Param("name") String name, @Param("platform") Boolean platform, @Param("companyWechatIds") List<String> companyWechatIds);
+                                 @Param("name") String name, @Param("companyWechatIds") List<String> companyWechatIds);
 
 }

+ 5 - 7
mall-server-api/src/main/java/com/gree/mall/manager/controller/goods/GoodsCategoryController.java

@@ -4,7 +4,6 @@ import com.gree.mall.manager.bean.goods.GoodsCategoryBean;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.goods.GoodsCategoryLogic;
-import com.gree.mall.manager.plus.entity.GoodsCategory;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -31,10 +30,9 @@ public class GoodsCategoryController {
             @ApiParam(value = "层级", required = false) @RequestParam(required = false, defaultValue = "1") Integer categoryLevel,
             @ApiParam(value = "分类名称", required = false) @RequestParam(required = false) String name,
             @ApiParam(value = "状态(true:显示 false:隐藏", required = false) @RequestParam(required = false) Boolean status,
-            @ApiParam(value = "平台分类") @RequestParam(required = false, defaultValue = "false") Boolean platform,
             HttpServletRequest request
     ) throws RemoteServiceException {
-        List<GoodsCategoryBean> list = goodsCategoryLogic.list(type, categoryLevel, name, status, platform, request);
+        List<GoodsCategoryBean> list = goodsCategoryLogic.list(type, categoryLevel, name, status, request);
         return ResponseHelper.success(list);
     }
 
@@ -49,8 +47,8 @@ public class GoodsCategoryController {
     @PostMapping("/update")
     @ApiOperation(value = "修改分类")
     public ResponseHelper update(
-            @ApiParam(value = "object", required = true) @RequestBody GoodsCategory goodsCategory) {
-        goodsCategoryLogic.update(goodsCategory);
+            @ApiParam(value = "object", required = true) @RequestBody GoodsCategoryBean goodsCategoryBean) {
+        goodsCategoryLogic.update(goodsCategoryBean);
         return ResponseHelper.success();
     }
 
@@ -65,10 +63,10 @@ public class GoodsCategoryController {
 
     @GetMapping("/detail")
     @ApiOperation("详情")
-    public ResponseHelper<GoodsCategory> detail(
+    public ResponseHelper<GoodsCategoryBean> detail(
             @ApiParam(value = "分类id", required = true) @RequestParam String categoryId
     ) {
-        GoodsCategory detail = goodsCategoryLogic.detail(categoryId);
+        GoodsCategoryBean detail = goodsCategoryLogic.detail(categoryId);
         return ResponseHelper.success(detail);
     }
 }

+ 2 - 1
mall-server-api/src/main/java/com/gree/mall/manager/controller/goods/GoodsDocumentsController.java

@@ -9,6 +9,7 @@ import com.gree.mall.manager.bean.goods.GoodsDocumentsVO;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.goods.GoodsDocumentsLogic;
+import com.gree.mall.manager.zfire.bean.GoodsDocumentsParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -41,7 +42,7 @@ public class GoodsDocumentsController {
     @PostMapping("/file/list")
     @ApiOperation(value = "文件列表")
     public ResponseHelper<IPage<GoodsDocumentsFileVO>> filePage(
-            @RequestBody ZfireParamBean zfireParamBean
+            @RequestBody GoodsDocumentsParamBean zfireParamBean
     ) throws Exception {
         IPage<GoodsDocumentsFileVO> page = goodsDocumentsLogic.filePage(zfireParamBean);
         return ResponseHelper.success(page, new TypeReference<GoodsDocumentsFileVO>() {});

+ 58 - 11
mall-server-api/src/main/java/com/gree/mall/manager/logic/goods/GoodsCategoryLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.goods;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
 import com.gree.mall.manager.bean.goods.GoodsCategoryBean;
 import com.gree.mall.manager.commonmapper.CustomGoodsCategoryMapper;
@@ -8,6 +9,7 @@ import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
@@ -37,6 +39,10 @@ public class GoodsCategoryLogic {
 
     @Autowired
     GoodsCategoryItemService goodsCategoryItemService;
+    @Resource
+    GoodsCategoryRelaService goodsCategoryRelaService;
+    @Resource
+    GoodsDocumentsService goodsDocumentsService;
 
     /**
      * 分类管理列表
@@ -45,14 +51,14 @@ public class GoodsCategoryLogic {
      * @param status
      * @return
      */
-    public List<GoodsCategoryBean> list(Integer type, Integer level, String name, Boolean status, Boolean platform, HttpServletRequest request) {
+    public List<GoodsCategoryBean> list(Integer type, Integer level, String name, Boolean status, HttpServletRequest request) {
         //获取当前登录企业微信id
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
         List<String> companyWechatIds = adminUser.getCompanyWechatIds();
         if (type == null) {
             type = 1;
         }
-        return customGoodsCategoryMapper.list(type, level, status, name, platform, companyWechatIds);
+        return customGoodsCategoryMapper.list(type, level, status, name, companyWechatIds);
     }
 
     /**
@@ -94,30 +100,53 @@ public class GoodsCategoryLogic {
         //goodsCategory.setCreateTime(new Date());
         goodsCategory.insert();
 
+        // 文档分类处理
+        if (goodsCategoryBean.getType() == 5 && CollectionUtil.isNotEmpty(goodsCategoryBean.getGoodsCategoryRelaList())) {
+            for (GoodsCategoryRela categoryRela : goodsCategoryBean.getGoodsCategoryRelaList()) {
+                categoryRela.setCategoryId(goodsCategory.getCategoryId());
+            }
+
+            goodsCategoryRelaService.saveBatch(goodsCategoryBean.getGoodsCategoryRelaList());
+        }
+
     }
 
     /**
      * 修改分类
      *
-     * @param goodsCategory
+     * @param goodsCategoryBean
      */
     @Transactional(rollbackFor = Exception.class)
-    public void update(GoodsCategory goodsCategory) {
-        GoodsCategory old = goodsCategoryService.getById(goodsCategory.getCategoryId());
+    public void update(GoodsCategoryBean goodsCategoryBean) {
+        GoodsCategory old = goodsCategoryService.getById(goodsCategoryBean.getCategoryId());
         //检查名称不可重复
         Integer count = goodsCategoryService.lambdaQuery()
-                .ne(GoodsCategory::getCategoryId, goodsCategory.getCategoryId())
+                .ne(GoodsCategory::getCategoryId, goodsCategoryBean.getCategoryId())
                 .eq(GoodsCategory::getType, old.getType())
-                .eq(GoodsCategory::getName, goodsCategory.getName())
+                .eq(GoodsCategory::getName, goodsCategoryBean.getName())
                 .eq(GoodsCategory::getCompanyWechatId, old.getCompanyWechatId()).count();
         if (count > 0) {
-            throw new RemoteServiceException("分类名称【" + goodsCategory.getName() + "】已存在");
+            throw new RemoteServiceException("分类名称【" + goodsCategoryBean.getName() + "】已存在");
         }
-        goodsCategoryService.updateById(goodsCategory);
+        goodsCategoryService.updateById(goodsCategoryBean);
         //如果有子集,覆盖子集的一些参数
 //        goodsCategoryService.lambdaUpdate()
 //                .set(GoodsCategory::getIsPromotionDiscount,goodsCategory.getIsPromotionDiscount())
 //                .eq(GoodsCategory::getParentId,goodsCategory.getCategoryId()).update();
+
+        // 文档分类处理
+        if (goodsCategoryBean.getType() == 5) {
+            goodsCategoryRelaService.lambdaUpdate()
+                    .eq(GoodsCategoryRela::getCategoryId, goodsCategoryBean.getCategoryId())
+                    .remove();
+            if (CollectionUtil.isNotEmpty(goodsCategoryBean.getGoodsCategoryRelaList())) {
+                for (GoodsCategoryRela categoryRela : goodsCategoryBean.getGoodsCategoryRelaList()) {
+                    categoryRela.setCategoryId(goodsCategoryBean.getCategoryId());
+                }
+
+                goodsCategoryRelaService.saveBatch(goodsCategoryBean.getGoodsCategoryRelaList());
+            }
+        }
     }
 
 
@@ -148,6 +177,15 @@ public class GoodsCategoryLogic {
             throw new RemoteServiceException("服务分类已被商品规格使用,不可删除");
         }
 
+        final Integer count3 = goodsDocumentsService.lambdaQuery().in(GoodsDocuments::getParentCategoryId, goodsCategoryIds).count();
+        if (count3 > 0) {
+            throw new RemoteServiceException("文档分类已被文件夹使用,不可删除");
+        }
+        final Integer count4 = goodsDocumentsService.lambdaQuery().in(GoodsDocuments::getCategoryId, goodsCategoryIds).count();
+        if (count4 > 0) {
+            throw new RemoteServiceException("文档分类已被文件夹使用,不可删除");
+        }
+
 
         // 删除子类别
         goodsCategoryService.lambdaUpdate()
@@ -169,8 +207,17 @@ public class GoodsCategoryLogic {
     /**
      * 分类详情
      */
-    public GoodsCategory detail(String goodsCategoryId) {
-        return goodsCategoryService.getById(goodsCategoryId);
+    public GoodsCategoryBean detail(String goodsCategoryId) {
+        GoodsCategoryBean bean = new GoodsCategoryBean();
+        final GoodsCategory goodsCategory = goodsCategoryService.getById(goodsCategoryId);
+        BeanUtils.copyProperties(goodsCategory, bean);
+        if (bean.getType() == 5) {
+            final List<GoodsCategoryRela> relaList = goodsCategoryRelaService.lambdaQuery()
+                    .eq(GoodsCategoryRela::getCategoryId, bean.getCategoryId())
+                    .list();
+            bean.setGoodsCategoryRelaList(relaList);
+        }
+        return bean;
     }
 
 }

+ 15 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/goods/GoodsDocumentsLogic.java

@@ -13,8 +13,11 @@ import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.CommonFile;
+import com.gree.mall.manager.plus.entity.GoodsCategoryRela;
 import com.gree.mall.manager.plus.entity.GoodsDocuments;
+import com.gree.mall.manager.plus.service.GoodsCategoryRelaService;
 import com.gree.mall.manager.plus.service.GoodsDocumentsService;
+import com.gree.mall.manager.zfire.bean.GoodsDocumentsParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.RequiredArgsConstructor;
@@ -36,6 +39,7 @@ public class GoodsDocumentsLogic {
     private final CommonLogic commonLogic;
     private final CommonMapper commonMapper;
     private final GoodsDocumentsService goodsDocumentsService;
+    private final GoodsCategoryRelaService goodsCategoryRelaService;
 
     public IPage<GoodsDocumentsVO> page(ZfireParamBean zfireParamBean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
@@ -90,14 +94,23 @@ public class GoodsDocumentsLogic {
         goodsDocumentsService.removeById(id);
     }
 
-    public IPage<GoodsDocumentsFileVO> filePage(ZfireParamBean zfireParamBean) {
+    public IPage<GoodsDocumentsFileVO> filePage(GoodsDocumentsParamBean zfireParamBean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         if (Objects.nonNull(adminUser.getAdminCompanyWechat())) {
             adminUser.setAdminCompanyWechat(null);
         }
         FieldUtils.supplyParam(zfireParamBean, GoodsDocumentsFileVO.class, adminUser);
+
+        List<String> categroyList = null;
+        if (StringUtils.isNotBlank(zfireParamBean.getParentCategoryId())) {
+            final List<GoodsCategoryRela> relaList = goodsCategoryRelaService.lambdaQuery()
+                    .eq(GoodsCategoryRela::getParentCategoryId, zfireParamBean.getParentCategoryId())
+                    .list();
+            categroyList = relaList.stream().map(GoodsCategoryRela::getCategoryId).collect(Collectors.toList());
+        }
+
         IPage<GoodsDocumentsFileVO> list = commonMapper.goodsDocumentsFileList(new Page(zfireParamBean.getPageNum(),
-                zfireParamBean.getPageSize()), zfireParamBean);
+                zfireParamBean.getPageSize()), zfireParamBean, categroyList);
         return list;
     }
 }

+ 1 - 6
mall-server-api/src/main/java/com/gree/mall/manager/logic/goods/GoodsLogic.java

@@ -2,7 +2,6 @@ package com.gree.mall.manager.logic.goods;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -209,7 +208,6 @@ public class GoodsLogic {
      * @return
      */
     public GoodsSpecBean detail(String goodsId, Boolean allStorageSpec) throws RemoteServiceException {
-        System.out.println("开始" + DateUtil.formatDateTime(DateUtil.date()));
         Goods goods = goodsService.getById(goodsId);
         final GoodsDetail goodsDetail = !allStorageSpec ? goodsDetailService.getById(goodsId) : null;
         List<GoodsSpec> goodsSpecs = goodsSpecService.lambdaQuery()
@@ -234,7 +232,6 @@ public class GoodsLogic {
 
         List<GoodsSpecVO> goodsSpecVOS = BeanUtil.copyToList(goodsSpecs, GoodsSpecVO.class);
         List<GoodsSpecVO> groupGoodsSpecVOS = new ArrayList<>();
-        System.out.println("商品规格开始" + DateUtil.formatDateTime(DateUtil.date()));
         for (GoodsSpecVO goodsSpecVO : goodsSpecVOS) {
             GoodsMaterial goodsMaterial = goodsMaterialService.getById(goodsSpecVO.getGoodsCode());
 
@@ -278,7 +275,6 @@ public class GoodsLogic {
             goodsBean.setTemplateId(goodsTemplates.get(0).getTemplateId());
         }
         //查询商品标签
-        System.out.println("商品标签开始" + DateUtil.formatDateTime(DateUtil.date()));
         List<GoodsTagRela> goodsTagRela = goodsTagRelaService.lambdaQuery().eq(GoodsTagRela::getGoodsId, goodsId)
                 .eq(GoodsTagRela::getType, 1).list();
         if (goodsTagRela.size() > 0) {
@@ -294,7 +290,6 @@ public class GoodsLogic {
         }
 
         // 文档列表
-        System.out.println("文档列表开始" + DateUtil.formatDateTime(DateUtil.date()));
         final List<GoodsDocumentsRela> relaList = goodsDocumentsRelaService.lambdaQuery()
                 .eq(GoodsDocumentsRela::getGoodsId, goodsId)
                 .list();
@@ -317,7 +312,7 @@ public class GoodsLogic {
             }
             goodsBean.setGoodsDocumentsRelaList(relaBeanList);
         }
-        System.out.println("结束" + DateUtil.formatDateTime(DateUtil.date()));
+
         return goodsBean;
     }
 

+ 13 - 0
mall-server-api/src/main/java/com/gree/mall/manager/zfire/bean/GoodsDocumentsParamBean.java

@@ -0,0 +1,13 @@
+package com.gree.mall.manager.zfire.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class GoodsDocumentsParamBean extends ZfireParamBean {
+
+    @ApiModelProperty(value = "商品一级分类id")
+    private String parentCategoryId;
+}

+ 6 - 0
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -1222,6 +1222,12 @@
         LEFT JOIN goods_category b ON a.parent_category_id = b.category_id
         LEFT JOIN goods_category c ON a.category_id = c.category_id
         ${ex.query}
+        <if test="categoryList != null and categoryList.size > 0">
+            AND a.parent_category_id IN
+            <foreach item="item" index="index" collection="categoryList" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="ex.orderBy == null or ex.orderBy ==''">
             ORDER BY a.create_time DESC
         </if>

+ 1 - 4
mall-server-api/src/main/resources/mapper/CustomGoodsCategoryMapper.xml

@@ -46,10 +46,7 @@
             <if test='name != null'>
                 AND name like concat('%',#{name,jdbcType=VARCHAR},'%')
             </if>
-            <if test="platform != null and platform">
-                AND company_wechat_id = ''
-            </if>
-            <if test='platform != null and !platform and companyWechatIds != null and companyWechatIds.size > 0' >
+            <if test='companyWechatIds != null and companyWechatIds.size > 0' >
                 AND company_wechat_id in
                 <foreach collection="companyWechatIds" open="(" close=")" item="companyWechatId" separator=",">
                      #{companyWechatId}