chao 4 лет назад
Родитель
Сommit
9f9b4fcd9e

+ 91 - 0
src/main/java/com/caimei365/commodity/controller/ProductShopApi.java

@@ -1,12 +1,20 @@
 package com.caimei365.commodity.controller;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.dto.BrandDto;
+import com.caimei365.commodity.model.dto.FeaturedDto;
 import com.caimei365.commodity.model.dto.ProductDto;
+import com.caimei365.commodity.model.dto.SoldOutDto;
+import com.caimei365.commodity.model.po.BrandPo;
 import com.caimei365.commodity.model.search.ProductListVo;
+import com.caimei365.commodity.model.vo.BrandVo;
+import com.caimei365.commodity.model.vo.PaginationVo;
 import com.caimei365.commodity.model.vo.ProductFormVo;
+import com.caimei365.commodity.model.vo.SecondListVo;
 import com.caimei365.commodity.service.ShopService;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -117,4 +125,87 @@ public class ProductShopApi {
         return shopService.getProductForm(productId);
     }
 
+    /**
+     * 供应商-商品编辑-品牌联想
+     */
+    @ApiOperation("供应商-商品编辑-品牌联想(旧:/supplier/brandManagement)")
+    @ApiImplicitParams({
+        @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
+        @ApiImplicitParam(required = true, name = "name", value = "关键词")
+    })
+    @GetMapping("/brand/select")
+    public ResponseJson<List<BrandVo>> brandAssociation(Integer userId, String name) {
+        return shopService.brandAssociation(userId, name);
+    }
+
+    /**
+     * 供应商-品牌检测
+     */
+    @ApiOperation("供应商-品牌检测(旧:/supplier/brandDetection)")
+    @ApiImplicitParam(required = true, name = "name", value = "品牌名称")
+    @GetMapping("/brand/check")
+    public ResponseJson<BrandVo> brandDetection(String name) {
+        return shopService.brandDetection(name);
+    }
+
+    /**
+     * 供应商-提交新品牌
+     *
+     * @param brandDto {
+     *                 name        品牌名字
+     *                 source      添加来源 0:后台添加,1:供应商添加
+     *                 userId      添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
+     *                 logo        品牌logo
+     *                 description 品牌描述
+     * }
+     */
+    @ApiOperation("供应商-提交新品牌(旧:/supplier/addBrand)")
+    @PostMapping("/brand/add")
+    public ResponseJson<BrandPo> addBrand(BrandDto brandDto) {
+        return shopService.addBrand(brandDto);
+    }
+
+    /**
+     * 供应商-品牌管理
+     */
+    @ApiOperation("供应商-品牌管理(旧:/supplier/brandManagement)")
+    @ApiImplicitParams({
+        @ApiImplicitParam(required = false, name = "name", value = "品牌名称"),
+        @ApiImplicitParam(required = false, name = "status", value = "品牌状态 0:待审核,1:审核通过,2:审核失败"),
+        @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
+        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @GetMapping("/brand/list")
+    public ResponseJson<PaginationVo<BrandVo>> brandManagement(String name, Integer status, Integer userId,
+                                                               @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                               @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        return shopService.brandManagement(name, status, userId, pageNum, pageSize);
+    }
+
+    /**
+     * 供应商-添加,删除主页推荐
+     *
+     * @param featuredDto {
+     *                    productId    商品Id
+     *                    featuredFlag 供应商主推商品标志 0删除 1添加
+     *                    shop         供应商Id
+     *                    }
+     */
+    @ApiOperation("供应商-添加,删除主页推荐(旧:/supplier/switchFeatured)")
+    @PostMapping("/featured/switch")
+    public ResponseJson switchFeatured(FeaturedDto featuredDto) {
+        return shopService.switchFeatured(featuredDto);
+    }
+
+    /**
+     * 供应商-批量下架商品
+     *
+     * @param soldOutDto {productIds 商品id集合,以','隔开}
+     */
+    @PostMapping("/soldOut")
+    public ResponseJson soldOut(SoldOutDto soldOutDto) {
+        return shopService.soldOutProducts(soldOutDto.getProductIds());
+    }
+
 }

+ 7 - 0
src/main/java/com/caimei365/commodity/mapper/PromotionsMapper.java

@@ -37,4 +37,11 @@ public interface PromotionsMapper {
      * 获取促销活动所有凑单商品
      */
     List<ProductListVo> getProductListByPromotions(Integer promotionsId, @Param("visibilityList") List<Integer> visibilityList);
+
+    /**
+     * 查询商品是否是满赠赠品
+     * @param productId
+     * @return
+     */
+    PromotionsVo getPromotionGiftsByProductId(Integer productId);
 }

+ 30 - 4
src/main/java/com/caimei365/commodity/mapper/ShopMapper.java

@@ -1,10 +1,8 @@
 package com.caimei365.commodity.mapper;
 
-import com.caimei365.commodity.model.po.ProductDetailInfoPo;
-import com.caimei365.commodity.model.po.ProductImagePo;
-import com.caimei365.commodity.model.po.ProductParameterPo;
-import com.caimei365.commodity.model.po.ProductPo;
+import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.search.ProductListVo;
+import com.caimei365.commodity.model.vo.BrandVo;
 import com.caimei365.commodity.model.vo.ProductFormVo;
 import com.caimei365.commodity.model.vo.ProductItemVo;
 import com.caimei365.commodity.model.vo.ShopVo;
@@ -117,4 +115,32 @@ public interface ShopMapper {
      * 获取用户身份
      */
     Integer getUserIdentityById(Integer userId);
+    /**
+     * 供应商-商品编辑-品牌联想
+     */
+    List<BrandVo> getBrandAssociation(Integer userId, String name);
+    /**
+     * 供应商-商品编辑-品牌检测
+     */
+    BrandVo getBrandByName(String name);
+    /**
+     * 供应商-提交新品牌
+     */
+    void insertBrand(BrandPo brand);
+    /**
+     * 供应商-更新品牌
+     */
+    void updateBrand(BrandPo brand);
+    /**
+     * 供应商-品牌管理
+     */
+    List<BrandVo> getShopBrandList(String name, Integer status, Integer userId);
+    /**
+     * 供应商-添加,删除主页推荐
+     */
+    int updateProductFeatured(Integer productId, Integer shopId, Integer featuredFlag);
+    /**
+     * 供应商-下架商品
+     */
+    void updateProductValidFlag(Integer productId, Integer validFlag);
 }

+ 45 - 0
src/main/java/com/caimei365/commodity/model/dto/BrandDto.java

@@ -0,0 +1,45 @@
+package com.caimei365.commodity.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/23
+ */
+@Data
+public class BrandDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    @ApiModelProperty("品牌id")
+    private Integer id;
+    /**
+     * 品牌名字
+     */
+    @ApiModelProperty("品牌名字")
+    private String name;
+    /**
+     * 添加来源 0:后台添加 ,1:供应商添加
+     */
+    @ApiModelProperty("添加来源 0:后台添加,1:供应商添加")
+    private Integer source;
+    /**
+     * 添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
+     */
+    @ApiModelProperty("用户id")
+    private Integer userId;
+    /**
+     * 品牌logo
+     */
+    @ApiModelProperty("品牌logo")
+    private String logo;
+    /**
+     * 品牌描述
+     */
+    @ApiModelProperty("品牌描述")
+    private String description;
+
+}

+ 32 - 0
src/main/java/com/caimei365/commodity/model/dto/FeaturedDto.java

@@ -0,0 +1,32 @@
+package com.caimei365.commodity.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/23
+ */
+@Data
+public class FeaturedDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 商品Id
+     */
+    @ApiModelProperty("供应商Id")
+    private Integer shopId;
+    /**
+     * 商品Id
+     */
+    @ApiModelProperty("商品Id")
+    private Integer productId;
+    /**
+     * 供应商主推商品标志 0删除 1添加
+     */
+    @ApiModelProperty("供应商主推商品标志 0删除 1添加")
+    private Integer featuredFlag;
+}

+ 23 - 0
src/main/java/com/caimei365/commodity/model/dto/SoldOutDto.java

@@ -0,0 +1,23 @@
+package com.caimei365.commodity.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/23
+ */
+@Data
+public class SoldOutDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 商品id集合,以','隔开
+     */
+    @ApiModelProperty("商品id集合,以','隔开")
+    private String productIds;
+}
+

+ 57 - 0
src/main/java/com/caimei365/commodity/model/po/BrandPo.java

@@ -0,0 +1,57 @@
+package com.caimei365.commodity.model.po;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/23
+ */
+@Data
+public class BrandPo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+    /**
+     * 品牌名字
+     */
+    private String name;
+    /**
+     * 添加来源 0:后台添加, 1:供应商添加
+     */
+    private Integer source;
+    /**
+     * 添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
+     */
+    private Integer userId;
+    /**
+     * 品牌状态 0:待审核,1:审核通过,2:审核失败
+     */
+    private Integer status;
+    /**
+     * 删除标记 0 否,其余是
+     */
+    private Integer delFlag;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createDate;
+    /**
+     * 最后更新时间
+     */
+    private Date updateDate;
+    /**
+     * 品牌logo
+     */
+    private String logo;
+    /**
+     * 品牌描述
+     */
+    private String description;
+}

+ 43 - 41
src/main/java/com/caimei365/commodity/model/vo/BrandVo.java

@@ -1,8 +1,10 @@
 package com.caimei365.commodity.model.vo;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import java.io.Serializable;
+import java.util.Date;
 
 
 /**
@@ -20,47 +22,47 @@ public class BrandVo implements Serializable {
      * 品牌名字
      */
     private String name;
-//    /**
-//     * 添加来源 0:后台添加 ,1:供应商添加
-//     */
-//    private String source;
-//    /**
-//     * 添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
-//     */
-//    private Integer userId;
-//    /**
-//     * 品牌状态 0:待审核,1:审核通过,2:审核失败
-//     */
-//    private String status;
-//    /**
-//     * 审核备注
-//     */
-//    private String auditNote;
-//    /**
-//     * 排序
-//     */
-//    private Integer sort;
-//    /**
-//     * 删除标记 0 否,其余是
-//     */
-//    private String delFlag;
-//    /**
-//     * 创建时间
-//     */
-//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-//    private Date createDate;
-//    /**
-//     * 最后更新时间
-//     */
-//    private Date updateDate;
-//    /**
-//     * 品牌logo
-//     */
-//    private String logo;
-//    /**
-//     * 品牌描述
-//     */
-//    private String description;
+    /**
+     * 添加来源 0:后台添加 ,1:供应商添加
+     */
+    private String source;
+    /**
+     * 添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
+     */
+    private Integer userId;
+    /**
+     * 品牌状态 0:待审核,1:审核通过,2:审核失败
+     */
+    private String status;
+    /**
+     * 审核备注
+     */
+    private String auditNote;
+    /**
+     * 排序
+     */
+    private Integer sort;
+    /**
+     * 删除标记 0 否,其余是
+     */
+    private String delFlag;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createDate;
+    /**
+     * 最后更新时间
+     */
+    private Date updateDate;
+    /**
+     * 品牌logo
+     */
+    private String logo;
+    /**
+     * 品牌描述
+     */
+    private String description;
 
 }
 

+ 62 - 0
src/main/java/com/caimei365/commodity/service/ShopService.java

@@ -1,8 +1,13 @@
 package com.caimei365.commodity.service;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.dto.BrandDto;
+import com.caimei365.commodity.model.dto.FeaturedDto;
 import com.caimei365.commodity.model.dto.ProductDto;
+import com.caimei365.commodity.model.po.BrandPo;
 import com.caimei365.commodity.model.search.ProductListVo;
+import com.caimei365.commodity.model.vo.BrandVo;
+import com.caimei365.commodity.model.vo.PaginationVo;
 import com.caimei365.commodity.model.vo.ProductFormVo;
 
 import java.util.List;
@@ -86,4 +91,61 @@ public interface ShopService {
      * @param productId 商品Id
      */
     ResponseJson<ProductFormVo> getProductForm(Integer productId);
+
+    /**
+     * 供应商-商品编辑-品牌联想
+     *
+     * @param userId  用户Id
+     * @param name    关键词
+     */
+    ResponseJson<List<BrandVo>> brandAssociation(Integer userId, String name);
+
+    /**
+     * 供应商-商品编辑-品牌检测
+     *
+     * @param name 品牌名称
+     */
+    ResponseJson<BrandVo> brandDetection(String name);
+
+    /**
+     * 供应商-提交新品牌
+     *
+     * @param brandDto {
+     *                 name        品牌名字
+     *                 source      添加来源 0:后台添加,1:供应商添加
+     *                 userId      添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
+     *                 logo        品牌logo
+     *                 description 品牌描述
+     * }
+     */
+    ResponseJson<BrandPo> addBrand(BrandDto brandDto);
+
+    /**
+     * 供应商-品牌管理
+     *
+     * @param name     品牌名称
+     * @param status   品牌状态 0:待审核,1:审核通过,2:审核失败
+     * @param userId   用户Id
+     * @param pageNum  页码
+     * @param pageSize 每页数量
+     */
+    ResponseJson<PaginationVo<BrandVo>> brandManagement(String name, Integer status, Integer userId, int pageNum, int pageSize);
+
+    /**
+     * 供应商-商品编辑-品牌联想
+     *
+     * @param featuredDto {
+     *                    productId    商品Id
+     *                    featuredFlag 供应商主推商品标志 0删除 1添加
+     *                    shop         供应商Id
+     *                    }
+     */
+    ResponseJson switchFeatured(FeaturedDto featuredDto);
+
+    /**
+     * 供应商-批量下架商品
+     *
+     * @param  productIds 商品id集合,以','隔开
+     */
+    ResponseJson soldOutProducts(String productIds);
 }

+ 206 - 7
src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java

@@ -3,17 +3,15 @@ package com.caimei365.commodity.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.commodity.components.PriceUtilService;
+import com.caimei365.commodity.mapper.PromotionsMapper;
 import com.caimei365.commodity.mapper.ShopMapper;
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.dto.BrandDto;
+import com.caimei365.commodity.model.dto.FeaturedDto;
 import com.caimei365.commodity.model.dto.ProductDto;
-import com.caimei365.commodity.model.po.ProductDetailInfoPo;
-import com.caimei365.commodity.model.po.ProductImagePo;
-import com.caimei365.commodity.model.po.ProductParameterPo;
-import com.caimei365.commodity.model.po.ProductPo;
+import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.search.ProductListVo;
-import com.caimei365.commodity.model.vo.PaginationVo;
-import com.caimei365.commodity.model.vo.ProductFormVo;
-import com.caimei365.commodity.model.vo.ProductItemVo;
+import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.ShopService;
 import com.caimei365.commodity.utils.ImageUtils;
 import com.github.pagehelper.PageHelper;
@@ -38,6 +36,8 @@ public class ShopServiceImpl implements ShopService {
     @Resource
     private ShopMapper shopMapper;
     @Resource
+    private PromotionsMapper promotionsMapper;
+    @Resource
     private PriceUtilService priceUtilService;
     @Value("${caimei.wwwDomain}")
     private String domain;
@@ -367,4 +367,203 @@ public class ShopServiceImpl implements ShopService {
         product.setParametersList(parametersList);
         return ResponseJson.success(product);
     }
+
+    /**
+     * 供应商-商品编辑-品牌联想
+     *
+     * @param userId 用户Id
+     * @param name   关键词
+     */
+    @Override
+    public ResponseJson<List<BrandVo>> brandAssociation(Integer userId, String name) {
+        if (null == userId) {
+            return ResponseJson.error("参数异常:用户id不能为空!", null);
+        }
+        if (StringUtils.isBlank(name)) {
+            return ResponseJson.error("参数异常:联想关键词不能为空!", null);
+        }
+        List<BrandVo> bindList = shopMapper.getBrandAssociation(userId, name);
+        if (null == bindList || bindList.size() == 0) {
+            return ResponseJson.error("品牌名称暂未被采美收录", null);
+        }
+        return ResponseJson.success(bindList);
+    }
+
+    /**
+     * 供应商-商品编辑-品牌检测
+     *
+     * @param name 品牌名称
+     */
+    @Override
+    public ResponseJson<BrandVo> brandDetection(String name) {
+        if (StringUtils.isBlank(name)) {
+            return ResponseJson.error("参数异常:品牌名称不能为空!", null);
+        }
+        BrandVo brand = shopMapper.getBrandByName(name);
+        if (null == brand) {
+            return ResponseJson.error("品牌名称暂未被采美收录", null);
+        }
+        return ResponseJson.success(brand);
+    }
+
+    /**
+     * 供应商-提交新品牌
+     *
+     * @param brandDto {
+     *                 name        品牌名字
+     *                 source      添加来源 0:后台添加,1:供应商添加
+     *                 userId      添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
+     *                 logo        品牌logo
+     *                 description 品牌描述
+     *                 }
+     */
+    @Override
+    public ResponseJson<BrandPo> addBrand(BrandDto brandDto) {
+        if (StringUtils.isBlank(brandDto.getName())) {
+            return ResponseJson.error("参数异常:品牌名称不能为空!", null);
+        }
+        if (null == brandDto.getUserId()) {
+            return ResponseJson.error("参数异常:用户id不能为空!", null);
+        }
+        BrandVo brandVo = shopMapper.getBrandByName(brandDto.getName());
+        if (brandVo != null) {
+            if (null == brandDto.getId()) {
+                return ResponseJson.error("该品牌已存在,无需重复提交", null);
+            } else if (!brandDto.getId().equals(brandVo.getId())) {
+                return ResponseJson.error("该品牌已存在,无需重复提交", null);
+            }
+        }
+        BrandPo brand = new BrandPo();
+        brand.setName(brandDto.getName());
+        brand.setUserId(brandDto.getUserId());
+        brand.setSource(brandDto.getSource());
+        brand.setLogo(brandDto.getLogo());
+        brand.setDescription(brandDto.getDescription());
+        brand.setStatus(0);
+        brand.setDelFlag(0);
+        Date createDate = new Date();
+        brand.setUpdateDate(createDate);
+        if (null == brand.getId()) {
+            brand.setCreateDate(createDate);
+            shopMapper.insertBrand(brand);
+        } else {
+            shopMapper.updateBrand(brand);
+        }
+        return ResponseJson.success(brand);
+
+    }
+
+    /**
+     * 供应商-品牌管理
+     *
+     * @param name     品牌名称
+     * @param status   品牌状态 0:待审核,1:审核通过,2:审核失败
+     * @param userId   用户Id
+     * @param pageNum  页码
+     * @param pageSize 每页数量
+     */
+    @Override
+    public ResponseJson<PaginationVo<BrandVo>> brandManagement(String name, Integer status, Integer userId, int pageNum, int pageSize) {
+        if (null == userId) {
+            return ResponseJson.error("参数异常:用户id不能为空!", null);
+        }
+        PageHelper.startPage(pageNum, pageSize);
+        List<BrandVo> brandList = shopMapper.getShopBrandList(name, status, userId);
+        PaginationVo<BrandVo> brandPage = new PaginationVo<>(brandList);
+        return ResponseJson.success(brandPage);
+
+
+
+    }
+
+    /**
+     * 供应商-添加,删除主页推荐
+     *
+     * @param featuredDto {
+     *                    productId    商品Id
+     *                    featuredFlag 供应商主推商品标志 0删除 1添加
+     *                    shop         供应商Id
+     *                    }
+     */
+    @Override
+    public ResponseJson switchFeatured(FeaturedDto featuredDto) {
+        if (null == featuredDto.getShopId()) {
+            return ResponseJson.error("参数异常:供应商Id不能为空!");
+        }
+        if (null == featuredDto.getProductId()) {
+            return ResponseJson.error("参数异常:商品Id不能为空!");
+        }
+        if (null == featuredDto.getFeaturedFlag()) {
+            return ResponseJson.error("参数异常:供应商主推商品标志不能为空!");
+        }
+        if (1 == featuredDto.getFeaturedFlag()){
+            int featuredCount = shopMapper.getMainProductsCount(featuredDto.getShopId());
+            if (featuredCount >= 4) {
+                return ResponseJson.error("主推商品已经上限了!");
+            }
+        }
+        int flag = shopMapper.updateProductFeatured(featuredDto.getProductId(), featuredDto.getShopId(), featuredDto.getFeaturedFlag());
+        if (flag > 0) {
+            return ResponseJson.success();
+        } else{
+            return ResponseJson.error("供应商主推商品标志更新失败!");
+        }
+    }
+
+    /**
+     * 供应商-批量下架商品
+     *
+     * @param productIds 商品id集合,以','隔开
+     */
+    @Override
+    public ResponseJson soldOutProducts(String productIds) {
+        if (StringUtils.isBlank(productIds)) {
+            return ResponseJson.error("参数异常:请传入商品Id!");
+        }
+        String[] split = productIds.split(",");
+        for (String productId : split) {
+            if (StringUtils.isNotBlank(productId)) {
+                ProductFormVo product = shopMapper.getProductForm(Integer.valueOf(productId));
+                if (2 == product.getValidFlag()) {
+                    return ResponseJson.error("只能下架已上架的商品");
+                }
+                PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(product.getProductId());
+                if (null != promotions) {
+                    StringBuilder message = new StringBuilder();
+                    if (promotions.getType() == 1) {
+                        message = new StringBuilder("单品");
+                    } else if (promotions.getType() == 2) {
+                        message = new StringBuilder("凑单");
+                    } else {
+                        message = new StringBuilder("店铺");
+                    }
+                    if (promotions.getMode() == 1) {
+                        message.append("优惠");
+                    } else if (promotions.getMode() == 2) {
+                        message.append("满减");
+                    } else {
+                        message.append("满赠");
+                    }
+                    return ResponseJson.error("此商品正在参与" + message + "促销活动,活动期间不能下架,如需强行下架,请联系客服:0755-22907771");
+                }
+                PromotionsVo promotionsGift = promotionsMapper.getPromotionGiftsByProductId(product.getProductId());
+                if (null != promotionsGift) {
+                    String message;
+                    if (promotionsGift.getType() == 1) {
+                        message = "单品满赠";
+                    } else if (promotionsGift.getType() == 2) {
+                        message = "凑单满赠";
+                    } else {
+                        message = "店铺满赠";
+                    }
+                    return ResponseJson.error("此商品是正在进行的" + message + "促销活动的赠品,活动期间不能下架,如需强行下架,请联系客服:0755-22907771");
+                }
+                product.setValidFlag(3);
+                shopMapper.updateProductValidFlag(product.getProductId(), product.getValidFlag());
+            }
+        }
+        return ResponseJson.success();
+    }
+
+
 }

+ 21 - 0
src/main/resources/mapper/PromotionsMapper.xml

@@ -110,4 +110,25 @@
         and p.validFlag = 2
         order by p.productID desc
     </select>
+    <select id="getPromotionGiftsByProductId" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
+        select pr.id,
+               pr.name,
+               pr.description,
+               pr.type,
+               pr.mode,
+               pr.touchPrice,
+               pr.reducedPrice,
+               pr.beginTime,
+               pr.endTime,
+               pr.status,
+               cpg.productId
+        from cm_promotions pr
+        left join cm_promotions_gift cpg on pr.id = cpg.promotionsId
+        where cpg.productId = #{productId}
+        and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
+        and pr.mode = 3
+        and pr.delFlag not in (1,2)
+        order by pr.type desc
+        limit 1
+    </select>
 </mapper>

+ 72 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -249,6 +249,40 @@
             #{orderInfo}
           )
     </insert>
+    <insert id="insertBrand">
+        insert into cm_brand (name, source, userID, status, delFlag, createDate, updateDate, logo, description)
+        values (#{name},#{source},#{userId},#{status}, #{delFlag},#{createDate},#{updateDate},#{logo},#{description})
+    </insert>
+    <update id="updateBrand">
+        update cm_brand
+        <set>
+            <if test="name != null">
+                `name` = #{name},
+            </if>
+            <if test="source != null">
+                `source` = #{source},
+            </if>
+            <if test="userId != null">
+                userID = #{userId},
+            </if>
+            <if test="status != null">
+                `status` = #{status},
+            </if>
+            <if test="delFlag != null">
+                delFlag = #{delFlag},
+            </if>
+            <if test="updateDate != null">
+                updateDate = #{updateDate},
+            </if>
+            <if test="logo != null">
+                logo = #{logo},
+            </if>
+            <if test="description != null">
+                description = #{description},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
     <update id="updateProductImage">
         update productimage set productID = #{productId}, shopID = #{shopId}, addTime = #{addTime},
                                 image = #{image}, mainFlag = #{mainFlag}, sortIndex = #{sortIndex}
@@ -268,6 +302,14 @@
         where
           productDetailInfoID = #{productDetailInfoId}
     </update>
+    <update id="updateProductFeatured">
+        update product set featuredFlag = #{featuredFlag}
+        where productID = #{productId}
+        and shopID = #{shopId}
+    </update>
+    <update id="updateProductValidFlag">
+        update product set validFlag = #{validFlag} where productID = #{productId}
+    </update>
     <delete id="deleteProductImage">
         delete from productimage where productImageID = #{id}
     </delete>
@@ -417,4 +459,34 @@
         select userIdentity from user
         where userID = #{userId}
     </select>
+    <select id="getBrandAssociation" resultType="com.caimei365.commodity.model.vo.BrandVo">
+        select id, name from cm_brand
+        where
+          status = '1' and delFlag = '0'
+          and name like CONCAT("%",#{name},"%")
+        order by
+          case when ( source = '1' and userID = #{userId} )
+               then 0
+               else 1
+          end asc,
+        LENGTH(name) asc
+    </select>
+    <select id="getBrandByName" resultType="com.caimei365.commodity.model.vo.BrandVo">
+        select id, name from cm_brand where name = #{name} and delFlag = '0'
+    </select>
+    <select id="getShopBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
+        select id, name, source, userId, status, auditNote, sort, delFlag, logo, description, createDate, updateDate
+        from cm_brand
+        <where>
+          userID = #{userId}
+          and delFlag = '0'
+          <if test="name != null and name != ''">
+              and name like CONCAT("%",#{name},"%")
+          </if>
+          <if test="status != null and status != ''">
+                and status = #{status}
+          </if>
+        </where>
+        order by createDate desc
+    </select>
 </mapper>