Bladeren bron

Merge branch 'master' of http://git.zonelife.cn:3000/fubojin/smqjh

zhangxin 1 dag geleden
bovenliggende
commit
530e953dcc
19 gewijzigde bestanden met toevoegingen van 395 en 107 verwijderingen
  1. 11 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProd.java
  2. 60 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProdHb.java
  3. 6 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/param/CategoryProductDTO.java
  4. 26 8
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropController.java
  5. 48 0
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropHbController.java
  6. 0 11
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ShopCategoryController.java
  7. 2 2
      yami-shop-platform/src/main/resources/application.yml
  8. 22 0
      yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdHbMapper.java
  9. 7 0
      yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdMapper.java
  10. 24 0
      yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdHbService.java
  11. 22 0
      yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdService.java
  12. 0 6
      yami-shop-service/src/main/java/com/yami/shop/service/IShopCategoryService.java
  13. 1 5
      yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBGoodsService.java
  14. 11 30
      yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBGoodsService.java
  15. 25 0
      yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdHbServiceImpl.java
  16. 82 4
      yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdServiceImpl.java
  17. 0 27
      yami-shop-service/src/main/java/com/yami/shop/service/impl/ShopCategoryServiceImpl.java
  18. 21 0
      yami-shop-service/src/main/resources/mapper/CategoryProdHbMapper.xml
  19. 27 14
      yami-shop-service/src/main/resources/mapper/CategoryProdMapper.xml

+ 11 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProd.java

@@ -33,6 +33,17 @@ public class CategoryProd implements Serializable {
      */
 
     private Long prodId;
+    /**
+     * 商品名称
+     */
+    @TableField(exist = false)
+    private String prodName;
+
+    /**
+     * 商品上架状态(0:商家下架、1:上架、2:违规下架、3:平台审核)
+     */
+    @TableField(exist = false)
+    private Integer status;
 
     private String code;
 

+ 60 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProdHb.java

@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.bean.model;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@TableName("tz_category_prod_hb")
+public class CategoryProdHb implements Serializable {
+    @TableId
+    private Long id;
+
+    /**
+     * 分类编码
+     */
+    private String code;
+
+
+    /**
+     * 商品属性id即表tz_prod_prop中的prop_id
+     */
+    private Long prodId;
+    /**
+     * 商品名称
+     */
+    @TableField(exist = false)
+    private String prodName;
+
+    /**
+     * 商品上架状态(0:商家下架、1:上架、2:违规下架、3:平台审核)
+     */
+    @TableField(exist = false)
+    private Integer status;
+
+    /**
+     * 0 正常,1 删除
+     */
+    private Integer isDelete;
+
+    /**
+     * 创建时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+}

+ 6 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/param/CategoryProductDTO.java

@@ -13,6 +13,12 @@ public class CategoryProductDTO {
     @NotNull(message = "门店分类id不能为空")
     private Long categoryId;
 
+    /**
+     * 分类ParentCode
+     */
+    @NotNull(message = "分类ParentCode不能为空")
+    private String parentCode;
+
      /**
      * 分类code
      */

+ 26 - 8
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropController.java

@@ -14,19 +14,20 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.param.CategoryProductDTO;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.R;
 import com.yami.shop.service.CategoryProdService;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 
 /**
- * 分类绑定商品管理
+ * 门店分类绑定商品管理
  *
  * @author fbj
  * @version 1.0.0
@@ -57,11 +58,28 @@ public class CategoryPropController {
      */
     @GetMapping("/pageByCode")
     public R<IPage<CategoryProd>> pageByCode(CategoryProd categoryProd, PageParam<CategoryProd> page) {
-        IPage<CategoryProd> list = categoryProdService.page(page, new LambdaQueryWrapper<CategoryProd>()
-                .eq(CategoryProd::getCode, categoryProd.getCode())
-                .eq(CategoryProd::getIsDelete, 0)
-                .eq(ObjectUtil.isNotEmpty(categoryProd.getShopId()), CategoryProd::getShopId, categoryProd.getShopId()));
+        IPage<CategoryProd> list = categoryProdService.pageByCode(categoryProd, page);
         return R.SUCCESS(list);
     }
 
+
+    /**
+     * 绑定分类商品
+     */
+    @PostMapping("/categoryProduct")
+    @ApiOperation(value = "绑定门店分类商品", notes = "绑定门店分类商品")
+    public R categoryProduct(@Valid @RequestBody CategoryProductDTO categoryProductDTO) {
+        categoryProdService.categoryProduct(categoryProductDTO);
+        return R.SUCCESS("绑定商品成功");
+    }
+
+    /**
+     * 取消分类绑定商品
+     */
+    @PostMapping("/cancelCategoryProduct")
+    @ApiOperation(value = "取消分类绑定商品", notes = "取消分类绑定商品")
+    public R cancelCategoryProduct(@Valid @RequestBody CategoryProductDTO categoryProductDTO) {
+        categoryProdService.cancelCategoryProduct(categoryProductDTO);
+        return R.SUCCESS();
+    }
 }

+ 48 - 0
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropHbController.java

@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.platform.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+import com.yami.shop.common.util.R;
+import com.yami.shop.service.CategoryProdHbService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * 海博分类绑定商品管理
+ *
+ * @author fbj
+ * @version 1.0.0
+ * @since 2025-9-26
+ */
+@RestController
+@RequestMapping("/platform/categoryProdHb")
+public class CategoryPropHbController {
+
+    @Autowired
+    private CategoryProdHbService categoryProdHbService;
+
+
+    /**
+     * 分页通过code查询分类绑定商品
+     */
+    @GetMapping("/pageByCode")
+    public R<IPage<CategoryProdHb>> pageByCode(CategoryProdHb categoryProd, PageParam<CategoryProdHb> page) {
+        IPage<CategoryProdHb> list = categoryProdHbService.pageByCode(categoryProd, page);
+        return R.SUCCESS(list);
+    }
+
+}

+ 0 - 11
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ShopCategoryController.java

@@ -189,16 +189,5 @@ public class ShopCategoryController {
         return R.FAIL("删除门店前台类目失败");
     }
 
-    /**
-     * 绑定分类商品
-     */
-    @PostMapping("/categoryProduct")
-    @ApiOperation(value = "绑定门店分类商品", notes = "绑定门店分类商品")
-    public R categoryProduct(@Valid @RequestBody CategoryProductDTO categoryProductDTO) {
-        shopCategoryService.categoryProduct(categoryProductDTO);
-        return R.SUCCESS("绑定商品成功");
-    }
-
-
 
 }

+ 2 - 2
yami-shop-platform/src/main/resources/application.yml

@@ -1,8 +1,8 @@
 spring:
   # 环境 dev|prod|docker quartz定时任务
   profiles:
-#    active: dev
-    active: prod
+    active: dev
+#    active: prod
   #文件上传设置
   servlet:
 

+ 22 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdHbMapper.java

@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+import org.apache.ibatis.annotations.Param;
+
+public interface CategoryProdHbMapper extends BaseMapper<CategoryProdHb> {
+	IPage<CategoryProdHb> pageByCode(PageParam<CategoryProdHb> page, @Param("categoryProd")CategoryProdHb categoryProd);
+}

+ 7 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdMapper.java

@@ -12,6 +12,8 @@ package com.yami.shop.dao;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.common.util.PageParam;
 import org.apache.ibatis.annotations.Param;
 
 import com.yami.shop.bean.model.CategoryProd;
@@ -24,4 +26,9 @@ public interface CategoryProdMapper extends BaseMapper<CategoryProd> {
 	void deleteByCategoryId(Long categoryId);
 
 	void deleteByProdId(Long prodId);
+
+	/**
+     * 通过code查询分类绑定商品
+     */
+    IPage<CategoryProd> pageByCode(PageParam<CategoryProd> page, @Param("categoryProd") CategoryProd categoryProd);
 }

+ 24 - 0
yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdHbService.java

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+
+public interface CategoryProdHbService extends IService<CategoryProdHb> {
+
+    /**
+     * 通过code查询分类绑定商品
+     */
+    IPage<CategoryProdHb> pageByCode(CategoryProdHb categoryProd, PageParam<CategoryProdHb> page);
+}

+ 22 - 0
yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdService.java

@@ -10,8 +10,11 @@
 
 package com.yami.shop.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.param.CategoryProductDTO;
+import com.yami.shop.common.util.PageParam;
 
 /**
  *
@@ -19,4 +22,23 @@ import com.yami.shop.bean.model.CategoryProd;
  */
 public interface CategoryProdService extends IService<CategoryProd> {
 
+    /**
+     * 通过code查询分类绑定商品
+     * @param categoryProd 查询参数
+     * @return 分类绑定商品
+     */
+    IPage<CategoryProd> pageByCode(CategoryProd categoryProd, PageParam<CategoryProd> page);
+
+
+    /**
+     * 绑定分类商品
+     * @param categoryProductDTO 分类商品参数
+     */
+    void categoryProduct(CategoryProductDTO categoryProductDTO);
+
+    /**
+     * 取消绑定分类商品
+     * @param categoryProductDTO 分类商品参数
+     */
+    void cancelCategoryProduct(CategoryProductDTO categoryProductDTO);
 }

+ 0 - 6
yami-shop-service/src/main/java/com/yami/shop/service/IShopCategoryService.java

@@ -44,10 +44,4 @@ public interface IShopCategoryService extends IService<ShopCategory> {
      */
     IPage<Category> listByParentIdAndShopId(Long parentId, Long shopId, Integer current, Integer size);
 
-    /**
-     * 绑定分类商品
-     * @param categoryProductDTO 分类商品参数
-     */
-    void categoryProduct(CategoryProductDTO categoryProductDTO);
-
 }

+ 1 - 5
yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBGoodsService.java

@@ -23,11 +23,7 @@ public interface IHBGoodsService {
      * @return 商品信息响应
      */
     HBR addHBGoods(JSONObject hbRequest);
-    /**
-     * 修改商品信息
-     * @param hbRequest 海博传入参数
-     */
-    HBR updateGoods(JSONObject hbRequest);
+
     /**
      * 修改商品状态信息
      * @param hbRequest 海博传入参数

+ 11 - 30
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBGoodsService.java

@@ -45,7 +45,7 @@ public class HBGoodsService implements IHBGoodsService {
 
     private final FrontCategoryMapper frontCategoryMapper;
     private final ShopCategoryMapper shopCategoryMapper;
-    private final CategoryProdMapper categoryProdMapper;
+    private final CategoryProdHbMapper categoryProdHbMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -163,20 +163,6 @@ public class HBGoodsService implements IHBGoodsService {
         return HBR.success();
     }
 
-    @Override
-    public HBR updateGoods(JSONObject hbRequest) {
-        try {
-            String bodyStr = hbRequest.getString("body");
-            log.info("商品,body:{}", bodyStr);
-            JSONObject bodyJson = JSON.parseObject(bodyStr); // 使用Fastjson的解析方法
-            String outStationNo = bodyJson.getString("outStationNo");
-        } catch (Exception e) {
-            log.error("商品失败:{}", e.getMessage(), e);
-            return HBR.error("未知异常");
-
-        }
-        return HBR.success();
-    }
 
     @Override
     public HBR updateGoodsStatus(JSONObject hbRequest) {
@@ -206,10 +192,10 @@ public class HBGoodsService implements IHBGoodsService {
                         .eq(ShopSku::getShopId, shopDetail.getShopId()));
 
                 //处理门店-分类管理
-                List<CategoryProd> categoryProds = categoryProdMapper.selectList(new LambdaQueryWrapper<CategoryProd>()
-                        .eq(CategoryProd::getProdId, sku.getProdId())
-                        .eq(CategoryProd::getIsDelete, 0));
-                for (CategoryProd categoryProd : categoryProds) {
+                List<CategoryProdHb> categoryProds = categoryProdHbMapper.selectList(new LambdaQueryWrapper<CategoryProdHb>()
+                        .eq(CategoryProdHb::getProdId, sku.getProdId())
+                        .eq(CategoryProdHb::getIsDelete, 0));
+                for (CategoryProdHb categoryProd : categoryProds) {
                     FrontCategory frontCategory = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
                             .eq(FrontCategory::getCode, categoryProd.getCode()));
                     addShopCategory(frontCategory, shopDetail.getShopId(), shopDetail.getHbStationId());
@@ -617,10 +603,6 @@ public class HBGoodsService implements IHBGoodsService {
             String ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCodeLevel2");
             if (StringUtils.isEmpty(ztFrontCategoryCodeLevel)) {
                 ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
-//            } else {
-//                //如果是二级,一级对应商品不存在也需要添加
-//                addCategoryProd(spuId, ztFrontCategoryCodeLevel);
-//                ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
             }
             addCategoryProd(spuId, ztFrontCategoryCodeLevel);
 
@@ -629,17 +611,16 @@ public class HBGoodsService implements IHBGoodsService {
     }
 
     private void addCategoryProd(Long spuId, String ztFrontCategoryCodeLevel) {
-        CategoryProd categoryProd = new CategoryProd();
+        CategoryProdHb categoryProd = new CategoryProdHb();
         categoryProd.setCode(ztFrontCategoryCodeLevel);
         categoryProd.setProdId(spuId);
         categoryProd.setIsDelete(0);
-        CategoryProd integer = categoryProdMapper.selectOne(new LambdaQueryWrapper<CategoryProd>()
-                .eq(CategoryProd::getProdId, spuId)
-                .eq(CategoryProd::getIsDelete, 0)
-                .eq(CategoryProd::getCode, ztFrontCategoryCodeLevel));
+        CategoryProdHb integer = categoryProdHbMapper.selectOne(new LambdaQueryWrapper<CategoryProdHb>()
+                .eq(CategoryProdHb::getProdId, spuId)
+                .eq(CategoryProdHb::getIsDelete, 0)
+                .eq(CategoryProdHb::getCode, ztFrontCategoryCodeLevel));
         if (integer == null) {
-            categoryProdMapper.insert(categoryProd);
-
+            categoryProdHbMapper.insert(categoryProd);
         }
         //门店分类处理
         List<ShopSku> shopCategoryList = shopSkuMapper.selectList(new LambdaQueryWrapper<ShopSku>()

+ 25 - 0
yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdHbServiceImpl.java

@@ -0,0 +1,25 @@
+
+package com.yami.shop.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+import com.yami.shop.dao.CategoryProdHbMapper;
+import com.yami.shop.service.CategoryProdHbService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class CategoryProdHbServiceImpl extends ServiceImpl<CategoryProdHbMapper, CategoryProdHb> implements CategoryProdHbService {
+
+    @Autowired
+    private CategoryProdHbMapper categoryPropHbMapper;
+
+    @Override
+    public IPage<CategoryProdHb> pageByCode(CategoryProdHb categoryProd, PageParam<CategoryProdHb> page) {
+        return categoryPropHbMapper.pageByCode(page, categoryProd);
+    }
+
+}

+ 82 - 4
yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdServiceImpl.java

@@ -1,16 +1,23 @@
 
 package com.yami.shop.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.param.CategoryProductDTO;
+import com.yami.shop.common.exception.GlobalException;
+import com.yami.shop.common.util.PageParam;
 import com.yami.shop.dao.CategoryProdMapper;
 import com.yami.shop.service.CategoryProdService;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
 
 /**
- *
  * Created by lgh on 2018/07/13.
  */
 @Service
@@ -19,4 +26,75 @@ public class CategoryProdServiceImpl extends ServiceImpl<CategoryProdMapper, Cat
     @Autowired
     private CategoryProdMapper categoryPropMapper;
 
+    @Override
+    public IPage<CategoryProd> pageByCode(CategoryProd categoryProd, PageParam<CategoryProd> page) {
+        return categoryPropMapper.pageByCode(page, categoryProd);
+    }
+
+
+    @Override
+    public void categoryProduct(CategoryProductDTO categoryProductDTO) {
+        List<Long> prodIdList = categoryProductDTO.getProdIdList();
+        if (ObjectUtils.isEmpty(prodIdList)) {
+            new GlobalException("新增商品为空!请选择商品");
+        }
+        for (Long aLong : prodIdList) {
+
+            Integer integer = categoryPropMapper.selectCount(new LambdaQueryWrapper<CategoryProd>().eq(CategoryProd::getProdId, aLong)
+                    .eq(CategoryProd::getIsDelete, 0)
+                    .eq(CategoryProd::getShopId, categoryProductDTO.getShopId())
+                    .eq(CategoryProd::getCode, categoryProductDTO.getCode()));
+
+            if (integer > 0) {
+                new GlobalException("该门店分类对应商品ID=" + aLong + " 已存在!请勿重复添加");
+            }
+            CategoryProd categoryProd = new CategoryProd();
+            categoryProd.setCategoryId(categoryProductDTO.getCategoryId());
+            categoryProd.setProdId(aLong);
+            categoryProd.setShopId(categoryProductDTO.getShopId());
+            categoryProd.setCode(categoryProductDTO.getCode());
+            categoryProd.setIsDelete(0);
+            categoryProd.setCreateTime(new Date());
+            categoryPropMapper.insert(categoryProd);
+
+            //查看父类绑定商品是否存在不存在添加
+            Integer integer1 = categoryPropMapper.selectCount(new LambdaQueryWrapper<CategoryProd>()
+                    .eq(CategoryProd::getCode, categoryProductDTO.getParentCode())
+                    .eq(CategoryProd::getIsDelete, 0));
+            if (integer1 == 0) {
+                CategoryProd categoryProdParent = new CategoryProd();
+                categoryProdParent.setCategoryId(categoryProductDTO.getCategoryId());
+                categoryProdParent.setProdId(aLong);
+                categoryProdParent.setShopId(categoryProductDTO.getShopId());
+                categoryProdParent.setCode(categoryProductDTO.getParentCode());
+                categoryProdParent.setIsDelete(0);
+                categoryProdParent.setCreateTime(new Date());
+                categoryPropMapper.insert(categoryProdParent);
+            }
+
+        }
+    }
+
+    @Override
+    public void cancelCategoryProduct(CategoryProductDTO categoryProductDTO) {
+        List<Long> prodIdList = categoryProductDTO.getProdIdList();
+        if (ObjectUtils.isEmpty(prodIdList)) {
+            new GlobalException("取消商品为空!请选择商品");
+        }
+
+        for (Long aLong : prodIdList) {
+
+            CategoryProd categoryProd = categoryPropMapper.selectOne(new LambdaQueryWrapper<CategoryProd>().eq(CategoryProd::getProdId, aLong)
+                    .eq(CategoryProd::getIsDelete, 0)
+                    .eq(CategoryProd::getShopId, categoryProductDTO.getShopId())
+                    .eq(CategoryProd::getCode, categoryProductDTO.getCode()));
+
+            if (ObjectUtils.isEmpty(categoryProd)) {
+                new GlobalException("该门店分类对应商品ID=" + aLong + " 不存在!请勿重复取消");
+            }
+            categoryProd.setIsDelete(1);
+            categoryPropMapper.deleteById(categoryProd);
+        }
+
+    }
 }

+ 0 - 27
yami-shop-service/src/main/java/com/yami/shop/service/impl/ShopCategoryServiceImpl.java

@@ -186,33 +186,6 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryMapper, Sho
         return res;
     }
 
-    @Override
-    public void categoryProduct(CategoryProductDTO categoryProductDTO) {
-        List<Long> prodIdList = categoryProductDTO.getProdIdList();
-        if (ObjectUtils.isEmpty(prodIdList)) {
-            new GlobalException("新增商品为空!请选择商品");
-        }
-        for (Long aLong : prodIdList) {
-
-            Integer integer = categoryProdMapper.selectCount(new LambdaQueryWrapper<CategoryProd>().eq(CategoryProd::getProdId, aLong)
-                    .eq(CategoryProd::getIsDelete, 0)
-                    .eq(CategoryProd::getShopId, categoryProductDTO.getShopId())
-                    .eq(CategoryProd::getCode, categoryProductDTO.getCode()));
-
-            if (integer > 0) {
-                new GlobalException("该门店分类对应商品ID="+aLong+" 已存在!请勿重复添加");
-            }
-            CategoryProd categoryProd = new CategoryProd();
-            categoryProd.setCategoryId(categoryProductDTO.getCategoryId());
-            categoryProd.setProdId(aLong);
-            categoryProd.setShopId(categoryProductDTO.getShopId());
-            categoryProd.setCode(categoryProductDTO.getCode());
-            categoryProd.setIsDelete(0);
-            categoryProd.setCreateTime(new Date());
-            categoryProdMapper.insert(categoryProd);
-
-        }
-    }
 
     /**
      * 添加对应的二级和三级类目

+ 21 - 0
yami-shop-service/src/main/resources/mapper/CategoryProdHbMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.yami.shop.dao.CategoryProdHbMapper">
+
+
+    <select id="pageByCode" resultType="com.yami.shop.bean.model.CategoryProdHb">
+        select cp.*, p.prod_name as prodName, p.status
+        from tz_category_prod_hb cp
+        join tz_prod p on cp.prod_id = p.prod_id
+        where p.is_delete = 0 and cp.is_delete = 0
+        <if test="categoryProd.code != null">
+            and cp.code = #{categoryProd.code}
+        </if>
+        <if test="categoryProd.prodName != null">
+            and p.prod_name like concat('%',#{categoryProd.prodName},'%')
+        </if>
+        order by cp.id desc
+    </select>
+
+
+</mapper>

+ 27 - 14
yami-shop-service/src/main/resources/mapper/CategoryProdMapper.xml

@@ -1,21 +1,34 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yami.shop.dao.CategoryProdMapper">
-  <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.CategoryProd">
-    <!--
-      WARNING - @mbg.generated
-    -->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="category_id" jdbcType="BIGINT" property="categoryId" />
-    <result column="prop_id" jdbcType="BIGINT" property="propId" />
-  </resultMap>
 
+    <delete id="deleteByCategoryId">
+        delete
+        from tz_category_prod
+        where category_id = #{categoryId}
+    </delete>
 
-  <delete id="deleteByCategoryId">
-  	delete from tz_category_prod where category_id = #{categoryId}
-  </delete>
+    <delete id="deleteByProdId">
+        delete
+        from tz_category_prod
+        where prod_id = #{prodId}
+    </delete>
+
+    <select id="pageByCode" resultType="com.yami.shop.bean.model.CategoryProd">
+        select cp.*, p.prod_name as prodName, p.status
+        from tz_category_prod cp
+        join tz_prod p on cp.prod_id = p.prod_id
+        where p.is_delete = 0 and cp.is_delete = 0
+        <if test="categoryProd.code != null">
+            and cp.code = #{categoryProd.code}
+        </if>
+        <if test="categoryProd.shopId != null">
+            and cp.shop_id = #{categoryProd.shopId}
+        </if>
+        <if test="categoryProd.prodName != null">
+            and p.prod_name like concat('%',#{categoryProd.prodName},'%')
+        </if>
+        order by cp.id desc
+    </select>
 
-  <delete id="deleteByProdId">
-  	delete from tz_category_prod where prod_id = #{prodId}
-  </delete>
 </mapper>