Ver código fonte

联合丽格1.0.2

huangzhiguo 1 ano atrás
pai
commit
25ae48a3b0
30 arquivos alterados com 650 adições e 424 exclusões
  1. 64 39
      src/main/java/com/caimei365/commodity/components/PriceUtilService.java
  2. 11 3
      src/main/java/com/caimei365/commodity/controller/ProductShopApi.java
  3. 2 1
      src/main/java/com/caimei365/commodity/mapper/MallProductMapper.java
  4. 14 0
      src/main/java/com/caimei365/commodity/mapper/PriceMapper.java
  5. 0 5
      src/main/java/com/caimei365/commodity/mapper/SearchMapper.java
  6. 21 6
      src/main/java/com/caimei365/commodity/mapper/ShopMapper.java
  7. 15 0
      src/main/java/com/caimei365/commodity/model/dto/ProductDto.java
  8. 20 0
      src/main/java/com/caimei365/commodity/model/dto/Sku.java
  9. 5 0
      src/main/java/com/caimei365/commodity/model/dto/SoldOutDto.java
  10. 4 0
      src/main/java/com/caimei365/commodity/model/po/ProductPo.java
  11. 20 1
      src/main/java/com/caimei365/commodity/model/vo/MallOrganizeProductVo.java
  12. 10 4
      src/main/java/com/caimei365/commodity/model/vo/MallProductSkuVo.java
  13. 20 0
      src/main/java/com/caimei365/commodity/model/vo/ProductFormVo.java
  14. 12 0
      src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java
  15. 4 2
      src/main/java/com/caimei365/commodity/service/ShopService.java
  16. 2 1
      src/main/java/com/caimei365/commodity/service/impl/MallProductServiceImpl.java
  17. 4 37
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  18. 89 14
      src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java
  19. 7 7
      src/main/resources/mapper/CouponMapper.xml
  20. 5 5
      src/main/resources/mapper/HeheMapper.xml
  21. 73 92
      src/main/resources/mapper/MallOrganizeMapper.xml
  22. 19 28
      src/main/resources/mapper/MallProductMapper.xml
  23. 72 61
      src/main/resources/mapper/PageMapper.xml
  24. 50 51
      src/main/resources/mapper/PriceMapper.xml
  25. 3 3
      src/main/resources/mapper/PromotionsMapper.xml
  26. 23 24
      src/main/resources/mapper/SearchMapper.xml
  27. 5 3
      src/main/resources/mapper/SecondHandMapper.xml
  28. 5 5
      src/main/resources/mapper/SellerMapper.xml
  29. 67 30
      src/main/resources/mapper/ShopMapper.xml
  30. 4 2
      src/main/resources/mapper/UserLikeMapper.xml

+ 64 - 39
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -10,6 +10,7 @@ import com.caimei365.commodity.utils.ImageUtils;
 import com.caimei365.commodity.utils.MathUtil;
 import com.caimei365.commodity.utils.MathUtil;
 import com.google.common.util.concurrent.AtomicDouble;
 import com.google.common.util.concurrent.AtomicDouble;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
@@ -284,51 +285,75 @@ public class PriceUtilService {
      * @param product ProductItemVo
      * @param product ProductItemVo
      */
      */
     public void setProductDetails(Integer userId, ProductItemVo product, Integer ind) {
     public void setProductDetails(Integer userId, ProductItemVo product, Integer ind) {
-        Integer organizeId = priceMapper.getOrganize(userId);
-        organizeId = organizeId == null?0:organizeId;
         // 设置图片
         // 设置图片
         product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
         product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
         // 数据库获取基本价格信息
         // 数据库获取基本价格信息
         PriceVo price = priceMapper.getDetailPrice(product.getProductId());
         PriceVo price = priceMapper.getDetailPrice(product.getProductId());
-        if (0 == organizeId) {
-            // 根据用户id设置详细价格
-            setPriceByUserId(price, userId, ind);
-            // 设置价格
-            product.setActStatus(price.getActStatus());
-            product.setPromotions(price.getPromotions());
-            product.setUserIdentity(price.getUserIdentity());
-            product.setSvipProductFlag(price.getSvipProductFlag());
-            product.setSvipPriceTag(price.getSvipPriceTag());
-            product.setPrice(price.getPrice());
-            product.setSkuId(price.getSkuId());
-            product.setOriginalPrice(price.getOriginalPrice());
-            product.setPriceGrade(getPriceGrade(price.getPrice()));
-            product.setMinBuyNumber(price.getMinBuyNumber());
-            product.setUnit(price.getUnit());
-            product.setStock(price.getStock());
-            product.setSkus(price.getSkus());
+        // 根据用户id设置详细价格
+        setPriceByUserId(price, userId, ind);
+        // 设置价格
+        product.setActStatus(price.getActStatus());
+        product.setPromotions(price.getPromotions());
+        product.setUserIdentity(price.getUserIdentity());
+        product.setSvipProductFlag(price.getSvipProductFlag());
+        product.setSvipPriceTag(price.getSvipPriceTag());
+        product.setPrice(price.getPrice());
+        product.setSkuId(price.getSkuId());
+        product.setOriginalPrice(price.getOriginalPrice());
+        product.setPriceGrade(getPriceGrade(price.getPrice()));
+        product.setMinBuyNumber(price.getMinBuyNumber());
+        product.setUnit(price.getUnit());
+        product.setStock(price.getStock());
+        product.setSkus(price.getSkus());
+    }
+
+    /**
+     * 设置供应商商品主图及价格
+     *
+     * @param product ProductItemVo
+     */
+    public void setShopProductDetails(ProductItemVo product) {
+        // 设置图片
+        product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
+        // 数据库获取基本价格信息
+        PriceVo price = null;
+        if ( StringUtils.isNotBlank(product.getGroundMall()) && product.getGroundMall().contains("0")) {
+            price = priceMapper.getMinPrice(product.getProductId());
         } else {
         } else {
-            List<MallProductSkuVo> organizeSkus = priceMapper.findOrganizeSkus(product.getProductId());
-            if (null != organizeSkus) {
-                product.setPrice(organizeSkus.get(0).getPrice());
-                product.setMinBuyNumber(organizeSkus.get(0).getMinBuyNumber());
-                product.setUnit(organizeSkus.get(0).getUnit());
-                product.setStock(organizeSkus.get(0).getStock());
-                product.setOrganizeSkus(organizeSkus);
-                product.setSkuId(organizeSkus.get(0).getSkuId());
-                /*product.setActStatus(price.getActStatus());
-                product.setPromotions(price.getPromotions());
-                product.setUserIdentity(price.getUserIdentity());
-                product.setSvipProductFlag(price.getSvipProductFlag());
-                product.setSvipPriceTag(price.getSvipPriceTag());*/
-                //设置展示的价格等级
-                product.setPriceGrade(getPriceGrade(product.getPrice()));
-            }
-            // 价格等级
-            organizeSkus.forEach(o -> {
-                o.setPriceGrade(getPriceGrade(o.getPrice()));
-            });
+            price = priceMapper.getOrganizeMinPrice(product.getProductId());
         }
         }
+        // 设置价格
+        product.setPrice(price.getPrice());
+        product.setNormalPrice(price.getNormalPrice());
+        product.setSkuId(price.getSkuId());
+    }
+
+    /**
+     * 设置商品主图及价格 -- 组织
+     *
+     * @param userId  用户Id
+     * @param product ProductItemVo
+     */
+    public void setOrganizeProductDetails(Integer userId, ProductItemVo product) {
+        Integer organizeId = priceMapper.getOrganize(userId);
+        organizeId = organizeId == null?0:organizeId;
+        // 设置图片
+        product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
+        List<MallProductSkuVo> organizeSkus = priceMapper.findOrganizeSkus(product.getProductId());
+        if (null != organizeSkus) {
+            product.setPrice(organizeSkus.get(0).getPrice());
+            product.setMinBuyNumber(organizeSkus.get(0).getMinBuyNumber());
+            product.setUnit(organizeSkus.get(0).getUnit());
+            product.setOrganizeSkus(organizeSkus);
+            product.setSkuId(organizeSkus.get(0).getId());
+//            product.setSkus(organizeSkus);
+            //设置展示的价格等级
+            product.setPriceGrade(getPriceGrade(product.getPrice()));
+        }
+        // 价格等级
+        organizeSkus.forEach(o -> {
+            o.setPriceGrade(getPriceGrade(o.getPrice()));
+        });
     }
     }
 
 
 }
 }

+ 11 - 3
src/main/java/com/caimei365/commodity/controller/ProductShopApi.java

@@ -13,6 +13,7 @@ import com.caimei365.commodity.model.vo.ProductFormVo;
 import com.caimei365.commodity.service.ShopService;
 import com.caimei365.commodity.service.ShopService;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import java.util.List;
 import java.util.List;
@@ -59,15 +60,16 @@ public class ProductShopApi {
             @ApiImplicitParam(required = false, name = "bigTypeId", value = "一级分类Id"),
             @ApiImplicitParam(required = false, name = "bigTypeId", value = "一级分类Id"),
             @ApiImplicitParam(required = false, name = "smallTypeId", value = "二级分类Id"),
             @ApiImplicitParam(required = false, name = "smallTypeId", value = "二级分类Id"),
             @ApiImplicitParam(required = false, name = "tinyTypeId", value = "三级级分类Id"),
             @ApiImplicitParam(required = false, name = "tinyTypeId", value = "三级级分类Id"),
+            @ApiImplicitParam(required = false, name = "groundMall", value = "订单来源"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     })
     @GetMapping("/product/list")
     @GetMapping("/product/list")
     public ResponseJson<Map<String, Object>> getShopProducts(Integer showFlag, Integer shopId, String name, String productCode,
     public ResponseJson<Map<String, Object>> getShopProducts(Integer showFlag, Integer shopId, String name, String productCode,
-                                                             Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer newvalidFlag,
+                                                             Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer groundMall, Integer newvalidFlag,
                                                              @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                              @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                              @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
                                                              @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
-        return shopService.getShopProducts(showFlag, shopId, name, productCode, validFlag, featuredFlag, commodityType, bigTypeId, smallTypeId, tinyTypeId, newvalidFlag, pageNum, pageSize);
+        return shopService.getShopProducts(showFlag, shopId, name, productCode, validFlag, featuredFlag, commodityType, bigTypeId, smallTypeId, tinyTypeId, groundMall, newvalidFlag, pageNum, pageSize);
     }
     }
 
 
     /**
     /**
@@ -209,7 +211,13 @@ public class ProductShopApi {
     @ApiOperation("供应商-批量下架商品(旧:/supplier/soldOut)")
     @ApiOperation("供应商-批量下架商品(旧:/supplier/soldOut)")
     @PostMapping("/product/offline")
     @PostMapping("/product/offline")
     public ResponseJson soldOut(SoldOutDto soldOutDto) {
     public ResponseJson soldOut(SoldOutDto soldOutDto) {
-        return shopService.soldOutProducts(soldOutDto.getProductIds());
+        if (StringUtils.isBlank(soldOutDto.getProductIds())) {
+            return ResponseJson.error("参数异常:请传入商品Id!");
+        }
+        if (null == soldOutDto.getGroundMallType()) {
+            return ResponseJson.error("参数异常:上架平台类型");
+        }
+        return shopService.soldOutProducts(soldOutDto.getProductIds(), soldOutDto.getGroundMallType());
     }
     }
 
 
 }
 }

+ 2 - 1
src/main/java/com/caimei365/commodity/mapper/MallProductMapper.java

@@ -1,5 +1,6 @@
 package com.caimei365.commodity.mapper;
 package com.caimei365.commodity.mapper;
 
 
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.vo.MallOrganizeProductVo;
 import com.caimei365.commodity.model.vo.MallOrganizeProductVo;
 import com.caimei365.commodity.model.vo.MallProductSkuVo;
 import com.caimei365.commodity.model.vo.MallProductSkuVo;
 import com.caimei365.commodity.model.vo.ProductDetailVo;
 import com.caimei365.commodity.model.vo.ProductDetailVo;
@@ -27,5 +28,5 @@ public interface MallProductMapper {
      * 商品sku信息
      * 商品sku信息
      * @return
      * @return
      */
      */
-    List<MallProductSkuVo> getMallSkus(@Param("mallProductId") Integer mallProductId);
+    List<Sku> getMallSkus(@Param("mallProductId") Integer mallProductId);
 }
 }

+ 14 - 0
src/main/java/com/caimei365/commodity/mapper/PriceMapper.java

@@ -24,6 +24,20 @@ public interface PriceMapper {
      * 根据商品id查找价格
      * 根据商品id查找价格
      */
      */
     PriceVo getDetailPrice(Integer productId);
     PriceVo getDetailPrice(Integer productId);
+
+    /**
+     * 采美sku最低价
+     * @param productId
+     * @return
+     */
+    PriceVo getMinPrice(Integer productId);
+
+    /**
+     * 外部商城sku最低价
+     * @param productId
+     * @return
+     */
+    PriceVo getOrganizeMinPrice(Integer productId);
     /**
     /**
      * 根据商品Id查找组织商品价格
      * 根据商品Id查找组织商品价格
      * @param productId
      * @param productId

+ 0 - 5
src/main/java/com/caimei365/commodity/mapper/SearchMapper.java

@@ -35,11 +35,6 @@ public interface SearchMapper {
      */
      */
     List<ProductDO> searchProductList();
     List<ProductDO> searchProductList();
 
 
-    /**
-     * 根据商品id查找 星范商品数量
-     */
-    Integer countMallProduct(Integer productId);
-
     /**
     /**
      * 根据商品id查找 星范商品
      * 根据商品id查找 星范商品
      */
      */

+ 21 - 6
src/main/java/com/caimei365/commodity/mapper/ShopMapper.java

@@ -3,11 +3,9 @@ package com.caimei365.commodity.mapper;
 import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.search.ProductListVo;
 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;
+import com.caimei365.commodity.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -45,7 +43,7 @@ public interface ShopMapper {
     /**
     /**
      * 获取供应商-我的商品列表
      * 获取供应商-我的商品列表
      */
      */
-    List<ProductItemVo> getShopProductsSelect(Integer showFlag, Integer newvalidFlag, Integer shopId, String name, String productCode, Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId);
+    List<ProductItemVo> getShopProductsSelect(Integer showFlag, Integer newvalidFlag, Integer shopId, String name, String productCode, Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer groundMall);
 
 
     /**
     /**
      * 列表显示分类
      * 列表显示分类
@@ -71,6 +69,21 @@ public interface ShopMapper {
      * 编辑商品
      * 编辑商品
      */
      */
     void updateProduct(ProductPo product);
     void updateProduct(ProductPo product);
+    /**
+     * 商品状态
+     * @param organizeId
+     * @param productId
+     * @param validFlag
+     */
+    void insertVaildFlag(@Param("organizeId") Integer organizeId,@Param("productId") Integer productId,@Param("validFlag") Integer validFlag);
+
+    /**
+     * 修改商品状态
+     * @param organizeId
+     * @param productId
+     * @param validFlag
+     */
+    void updateVaildFlag(@Param("organizeId") Integer organizeId,@Param("productId") Integer productId,@Param("validFlag") Integer validFlag);
 
 
     /**
     /**
      * 获取商品图片
      * 获取商品图片
@@ -192,7 +205,7 @@ public interface ShopMapper {
     /**
     /**
      * 供应商-下架商品
      * 供应商-下架商品
      */
      */
-    void updateProductValidFlag(Integer productId, Integer validFlag);
+    void updateProductValidFlag(@Param("productId") Integer productId,@Param("validFlag") Integer validFlag,@Param("organizeId") Integer organizeId);
 
 
     /**
     /**
      * 供应商-更新商品编码
      * 供应商-更新商品编码
@@ -217,4 +230,6 @@ public interface ShopMapper {
     void insertSku(Sku s);
     void insertSku(Sku s);
 
 
     void updateSku(Sku s);
     void updateSku(Sku s);
+
+    void insertProductInfo(@Param("organizeId") Integer organizeId, @Param("productId") Integer productId, @Param("validFlag") Integer validFlag);
 }
 }

+ 15 - 0
src/main/java/com/caimei365/commodity/model/dto/ProductDto.java

@@ -206,4 +206,19 @@ public class ProductDto implements Serializable {
      */
      */
     @ApiModelProperty("sku参数json")
     @ApiModelProperty("sku参数json")
     public String skus;
     public String skus;
+    /**
+     * 外部skus
+     */
+    @ApiModelProperty("外部skus json")
+    public String mallSkus;
+    /**
+     * 上架商城
+     */
+    @ApiModelProperty("上架商城")
+    private String groundMall;
+    /**
+     * 外部商城商品Id
+     */
+    @ApiModelProperty("外部商城商品Id")
+    private Integer mallProductId;
 }
 }

+ 20 - 0
src/main/java/com/caimei365/commodity/model/dto/Sku.java

@@ -15,6 +15,10 @@ import java.util.List;
 public class Sku {
 public class Sku {
 
 
     private Integer productId;
     private Integer productId;
+    /**
+     * 组织Id
+     */
+    private Integer organizeId;
 
 
     @ApiModelProperty("svipPriceTag")
     @ApiModelProperty("svipPriceTag")
     private String svipPriceTag;
     private String svipPriceTag;
@@ -103,4 +107,20 @@ public class Sku {
      */
      */
     @ApiModelProperty("阶梯价格")
     @ApiModelProperty("阶梯价格")
     private List<LadderPriceVo> ladderPriceList;
     private List<LadderPriceVo> ladderPriceList;
+
+    /**
+     * 分账组织佣金比例
+     */
+    @ApiModelProperty("分账组织佣金比例")
+    private Double organizePercent;
+    /**
+     * 分账供应商成本比例
+     */
+    @ApiModelProperty("分账供应商成本比例")
+    private Double shopPercent;
+    /**
+     * 分账采美佣金比例
+     */
+    @ApiModelProperty("分账采美佣金比例")
+    private Double cmPercent;
 }
 }

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

@@ -19,5 +19,10 @@ public class SoldOutDto implements Serializable {
      */
      */
     @ApiModelProperty("商品id集合,以','隔开")
     @ApiModelProperty("商品id集合,以','隔开")
     private String productIds;
     private String productIds;
+    /**
+     * 上架平台类型 0 全部 1采美 2 联合丽格
+     */
+    @ApiModelProperty("上架平台类型")
+    private Integer groundMallType;
 }
 }
 
 

+ 4 - 0
src/main/java/com/caimei365/commodity/model/po/ProductPo.java

@@ -22,6 +22,10 @@ public class ProductPo implements Serializable {
      * 商品productID
      * 商品productID
      */
      */
     private Integer productId;
     private Integer productId;
+    /**
+     * 上架商城
+     */
+    private String groundMall;
     /**
     /**
      * 品牌Id
      * 品牌Id
      */
      */

+ 20 - 1
src/main/java/com/caimei365/commodity/model/vo/MallOrganizeProductVo.java

@@ -1,7 +1,9 @@
 package com.caimei365.commodity.model.vo;
 package com.caimei365.commodity.model.vo;
 
 
+import com.caimei365.commodity.model.dto.Sku;
 import lombok.Data;
 import lombok.Data;
 
 
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -12,6 +14,11 @@ import java.util.List;
  */
  */
 @Data
 @Data
 public class MallOrganizeProductVo {
 public class MallOrganizeProductVo {
+    private Integer id;
+    /**
+     * 组织Id
+     */
+    private Integer organizeId;
     /**
     /**
      * 活动Id
      * 活动Id
      */
      */
@@ -84,8 +91,20 @@ public class MallOrganizeProductVo {
      * 商品状态,1已上架,2已下架
      * 商品状态,1已上架,2已下架
      */
      */
     private String validFlag;
     private String validFlag;
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+    /**
+     * 修改时间
+     */
+    private Date updateTime;
+    /**
+     * 删除标记 0 有效  其它无效
+     */
+    private Integer delFlag;
     /**
     /**
      * sku信息
      * sku信息
      */
      */
-    private List<MallProductSkuVo> sku;
+    private List<Sku> sku;
 }
 }

+ 10 - 4
src/main/java/com/caimei365/commodity/model/vo/MallProductSkuVo.java

@@ -33,8 +33,14 @@ public class MallProductSkuVo {
      * 外部商城起订量
      * 外部商城起订量
      */
      */
     private Integer minBuyNumber;
     private Integer minBuyNumber;
-
+    /**
+     * 库存
+     */
     private Integer stock;
     private Integer stock;
+    /**
+     * 市场价
+     */
+    private Double normalPrice;
     /**
     /**
      * 外部商城售价
      * 外部商城售价
      */
      */
@@ -70,13 +76,13 @@ public class MallProductSkuVo {
     /**
     /**
      * 分账组织佣金比例
      * 分账组织佣金比例
      */
      */
-    private Integer organizePercent;
+    private Double organizePercent;
     /**
     /**
      * 分账供应商成本比例
      * 分账供应商成本比例
      */
      */
-    private Integer shopPercent;
+    private Double shopPercent;
     /**
     /**
      * 分账采美佣金比例
      * 分账采美佣金比例
      */
      */
-    private Integer cmPercent;
+    private Double cmPercent;
 }
 }

+ 20 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductFormVo.java

@@ -27,6 +27,14 @@ public class ProductFormVo implements Serializable {
      * 商品productID
      * 商品productID
      */
      */
     private Integer productId;
     private Integer productId;
+    /**
+     * 外部商城ProductId
+     */
+    private Integer mallProductId;
+    /**
+     * 上架平台
+     */
+    private String groundMall;
     /**
     /**
      * 所属供应商Id
      * 所属供应商Id
      */
      */
@@ -115,6 +123,10 @@ public class ProductFormVo implements Serializable {
      * 商品状态, 0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
      * 商品状态, 0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
      */
      */
     private Integer validFlag;
     private Integer validFlag;
+    /**
+     * 外部商城 商品状态, 1待审核 2已上架 3已下架
+     */
+    private Integer mallValidFlag;
     /**
     /**
      * 是否使用活动角标:1是,空或0不是[与actType搭配使用,仅用于标识非真正活动]
      * 是否使用活动角标:1是,空或0不是[与actType搭配使用,仅用于标识非真正活动]
      */
      */
@@ -293,5 +305,13 @@ public class ProductFormVo implements Serializable {
      */
      */
     public String qualificationLink;
     public String qualificationLink;
 
 
+    /**
+     * 采美商城sku
+     */
     public List<Sku> skus;
     public List<Sku> skus;
+
+    /**
+     * 外部商城Sku
+     */
+    public List<Sku> mallSkus;
 }
 }

+ 12 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java

@@ -128,6 +128,10 @@ public class ProductItemVo implements Serializable {
      * 商品上架状态:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已冻结
      * 商品上架状态:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已冻结
      */
      */
     private Integer validFlag;
     private Integer validFlag;
+    /**
+     * 联合丽格商品状态
+     */
+    private Integer mallValidFlag;
     /**
     /**
      * 活动状态:1有效,0失效
      * 活动状态:1有效,0失效
      */
      */
@@ -263,6 +267,14 @@ public class ProductItemVo implements Serializable {
      * 新品参与状态1.参与2.未参与
      * 新品参与状态1.参与2.未参与
      */
      */
     private Integer newProductType;
     private Integer newProductType;
+    /**
+     * 上架平台
+     */
+    private String groundMall;
+    /**
+     * 上架平台集合
+     */
+    private List<String> organizeNames;
 
 
     private String BrandName;
     private String BrandName;
 
 

+ 4 - 2
src/main/java/com/caimei365/commodity/service/ShopService.java

@@ -41,11 +41,12 @@ public interface ShopService {
      * @param bigTypeId     一级分类Id
      * @param bigTypeId     一级分类Id
      * @param smallTypeId   二级分类Id
      * @param smallTypeId   二级分类Id
      * @param tinyTypeId    三级级分类Id
      * @param tinyTypeId    三级级分类Id
+     * @param groundMall    上架平台
      * @param pageNum       页码
      * @param pageNum       页码
      * @param pageSize      每页数量
      * @param pageSize      每页数量
      * @return PageInfo<ProductShopVO>
      * @return PageInfo<ProductShopVO>
      */
      */
-    ResponseJson<Map<String, Object>> getShopProducts(Integer showFlag,Integer shopId, String name, String productCode, Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId,Integer newvalidFlag, int pageNum, int pageSize);
+    ResponseJson<Map<String, Object>> getShopProducts(Integer showFlag,Integer shopId, String name, String productCode, Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer groundMall, Integer newvalidFlag, int pageNum, int pageSize);
 
 
     /**
     /**
      * 供应商-发布商品
      * 供应商-发布商品
@@ -146,6 +147,7 @@ public interface ShopService {
      * 供应商-批量下架商品
      * 供应商-批量下架商品
      *
      *
      * @param  productIds 商品id集合,以','隔开
      * @param  productIds 商品id集合,以','隔开
+     * @param  groundMallType 上架平台类型
      */
      */
-    ResponseJson soldOutProducts(String productIds);
+    ResponseJson soldOutProducts(String productIds, Integer groundMallType);
 }
 }

+ 2 - 1
src/main/java/com/caimei365/commodity/service/impl/MallProductServiceImpl.java

@@ -4,6 +4,7 @@ import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.mapper.MallProductMapper;
 import com.caimei365.commodity.mapper.MallProductMapper;
 import com.caimei365.commodity.mapper.PageMapper;
 import com.caimei365.commodity.mapper.PageMapper;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.vo.MallOrganizeProductVo;
 import com.caimei365.commodity.model.vo.MallOrganizeProductVo;
 import com.caimei365.commodity.model.vo.MallProductSkuVo;
 import com.caimei365.commodity.model.vo.MallProductSkuVo;
 import com.caimei365.commodity.model.vo.ProductDetailVo;
 import com.caimei365.commodity.model.vo.ProductDetailVo;
@@ -40,7 +41,7 @@ public class MallProductServiceImpl implements MallProductService {
         if (null != product) {
         if (null != product) {
             // 商品sku
             // 商品sku
             if (null != product.getMallProductId()) {
             if (null != product.getMallProductId()) {
-                List<MallProductSkuVo> mallSkus = productMapper.getMallSkus(product.getMallProductId());
+                List<Sku> mallSkus = productMapper.getMallSkus(product.getMallProductId());
                 if (null != mallSkus) {
                 if (null != mallSkus) {
                     mallSkus.forEach(s -> {
                     mallSkus.forEach(s -> {
                         s.setPriceGrade(priceUtilService.getPriceGrade(s.getPrice()));
                         s.setPriceGrade(priceUtilService.getPriceGrade(s.getPrice()));

+ 4 - 37
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -673,17 +673,9 @@ public class PageServiceImpl implements PageService {
     public ResponseJson<ProductDetailVo> getProductOrganizeDetails(Integer productId, Integer userId) {
     public ResponseJson<ProductDetailVo> getProductOrganizeDetails(Integer productId, Integer userId) {
         // 商品详情页
         // 商品详情页
         ProductDetailVo product = pageMapper.getProductOrganizeDetails(productId);
         ProductDetailVo product = pageMapper.getProductOrganizeDetails(productId);
-        //当该商品的“能否退货”字段的值是“不能”时,新增特殊商品退货须知提示
-        /*if (product == null) {
-            //商品不存在
-            product = new ProductDetailVo();
-            product.setValidFlag(0);
-        } else {
-            if (null != product.getReturnGoodsStutas() && 2 == product.getReturnGoodsStutas()) {
-                String helpContent = pageMapper.getHelpContent(1040);
-                product.setHelpContent(helpContent);
-            }
-        }*/
+        if (product == null) {
+            return ResponseJson.error(-1, "商品不存在", null);
+        }
         String[] split = null;
         String[] split = null;
         // 品牌名称
         // 品牌名称
         String brandName = shopMapper.getBrandNameById(product.getBrandId());
         String brandName = shopMapper.getBrandNameById(product.getBrandId());
@@ -724,14 +716,6 @@ public class PageServiceImpl implements PageService {
         product.setBigTypeName(list.size() > 0 ? list.get(0) : null);
         product.setBigTypeName(list.size() > 0 ? list.get(0) : null);
         product.setSmallTypeName(list.size() > 1 ? list.get(1) : null);
         product.setSmallTypeName(list.size() > 1 ? list.get(1) : null);
         product.setTinyTypeName(list.size() > 2 ? list.get(2) : null);
         product.setTinyTypeName(list.size() > 2 ? list.get(2) : null);
-        // 商品云上美博会活动状态
-        /*Integer pcBeautyStatus = shopMapper.getPcBeautyStatusById(product.getProductId());
-        Integer appletsBeautyStatus = shopMapper.getAppletsBeautyStatusById(product.getProductId());
-        product.setPcActType(null != pcBeautyStatus ? 1 : 0);
-        product.setAppletsActType(null != appletsBeautyStatus ? 1 : 0);*/
-        // 商品资料id
-        /*Integer archiveId = pageMapper.getArchiveIdById(product.getProductId());
-        product.setArchiveId(null != archiveId ? archiveId : 0);*/
         //供应商信息
         //供应商信息
         ShopVo shop = shopMapper.getProductShopById(product.getShopId());
         ShopVo shop = shopMapper.getProductShopById(product.getShopId());
         if (null != shop) {
         if (null != shop) {
@@ -747,10 +731,6 @@ public class PageServiceImpl implements PageService {
         }
         }
         // 商品不处于已删除/待审核/审核未通过的状态
         // 商品不处于已删除/待审核/审核未通过的状态
         if (0 != product.getValidFlag()) {
         if (0 != product.getValidFlag()) {
-            // 数据库获取基本价格信息
-//            PriceVo price = priceMapper.getDetailPrice(productId);
-            // 根据用户id设置详细价格
-//            priceUtilService.setPriceByUserId(price, userId, 0);
             List<MallProductSkuVo> organizeSkus = priceMapper.findOrganizeSkus(productId);
             List<MallProductSkuVo> organizeSkus = priceMapper.findOrganizeSkus(productId);
             // 设置价格
             // 设置价格
             if (null != organizeSkus) {
             if (null != organizeSkus) {
@@ -759,12 +739,7 @@ public class PageServiceImpl implements PageService {
                 product.setUnit(organizeSkus.get(0).getUnit());
                 product.setUnit(organizeSkus.get(0).getUnit());
                 product.setStock(organizeSkus.get(0).getStock());
                 product.setStock(organizeSkus.get(0).getStock());
                 product.setOrganizeSkus(organizeSkus);
                 product.setOrganizeSkus(organizeSkus);
-                product.setSkuId(organizeSkus.get(0).getSkuId());
-                /*product.setActStatus(price.getActStatus());
-                product.setPromotions(price.getPromotions());
-                product.setUserIdentity(price.getUserIdentity());
-                product.setSvipProductFlag(price.getSvipProductFlag());
-                product.setSvipPriceTag(price.getSvipPriceTag());*/
+                product.setSkuId(organizeSkus.get(0).getId());
                 //设置展示的价格等级
                 //设置展示的价格等级
                 product.setPriceGrade(priceUtilService.getPriceGrade(product.getPrice()));
                 product.setPriceGrade(priceUtilService.getPriceGrade(product.getPrice()));
                 //查询商品收藏情况,1未收藏,0未收藏,未收藏过该商品用户是null
                 //查询商品收藏情况,1未收藏,0未收藏,未收藏过该商品用户是null
@@ -776,14 +751,6 @@ public class PageServiceImpl implements PageService {
                 o.setPriceGrade(priceUtilService.getPriceGrade(o.getPrice()));
                 o.setPriceGrade(priceUtilService.getPriceGrade(o.getPrice()));
             });
             });
         }
         }
-        // 设置售罄标记
-        /*Integer flag = priceMapper.getSaleOutFlag(product.getProductId()) > 0 ? 0 : 1;
-        product.setSaleOutFlag(flag);*/
-        // 关联标签库字符串
-        /*if (StringUtils.isNotBlank(product.getRelatedLabels())) {
-            String replaceAll = product.getRelatedLabels().replaceAll("##", ",");
-            product.setRelatedLabels(replaceAll);
-        }*/
 
 
         return ResponseJson.success(product);
         return ResponseJson.success(product);
     }
     }

+ 89 - 14
src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java

@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * Description
  * Description
@@ -100,26 +101,38 @@ public class ShopServiceImpl implements ShopService {
      * @param bigTypeId     一级分类Id
      * @param bigTypeId     一级分类Id
      * @param smallTypeId   二级分类Id
      * @param smallTypeId   二级分类Id
      * @param tinyTypeId    三级级分类Id
      * @param tinyTypeId    三级级分类Id
+     * @param groundMall    上架平台
      * @param pageNum       页码
      * @param pageNum       页码
      * @param pageSize      每页数量
      * @param pageSize      每页数量
      * @return Map<String, Object>
      * @return Map<String, Object>
      */
      */
     @Override
     @Override
-    public ResponseJson<Map<String, Object>> getShopProducts(Integer showFlag, Integer shopId, String name, String productCode, Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer newvalidFlag, int pageNum, int pageSize) {
+    public ResponseJson<Map<String, Object>> getShopProducts(Integer showFlag, Integer shopId, String name, String productCode, Integer validFlag, Integer featuredFlag, Integer commodityType, Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer groundMall, Integer newvalidFlag, int pageNum, int pageSize) {
         if (null == shopId) {
         if (null == shopId) {
             return ResponseJson.error("参数异常:缺少供应商Id", null);
             return ResponseJson.error("参数异常:缺少供应商Id", null);
         }
         }
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         PageHelper.startPage(pageNum, pageSize);
         PageHelper.startPage(pageNum, pageSize);
-        List<ProductItemVo> productList = shopMapper.getShopProductsSelect(showFlag, newvalidFlag, shopId, name, productCode, validFlag, featuredFlag, commodityType, bigTypeId, smallTypeId, tinyTypeId);
+        // 上架平台
+        List<String> organizeNames = new ArrayList<>();
+        List<ProductItemVo> productList = shopMapper.getShopProductsSelect(showFlag, newvalidFlag, shopId, name, productCode, validFlag, featuredFlag, commodityType, bigTypeId, smallTypeId, tinyTypeId, groundMall);
         if (null != productList && productList.size() > 0) {
         if (null != productList && productList.size() > 0) {
             for (ProductItemVo product : productList) {
             for (ProductItemVo product : productList) {
                 String typeName = shopMapper.getTypeName(product.getBigTypeId(), product.getSmallTypeId(), product.getTinyTypeId());
                 String typeName = shopMapper.getTypeName(product.getBigTypeId(), product.getSmallTypeId(), product.getTinyTypeId());
                 product.setTypeName(typeName);
                 product.setTypeName(typeName);
                 product.setIsChecked(false);
                 product.setIsChecked(false);
                 // 设置商品主图及价格
                 // 设置商品主图及价格
-                Integer userId = shopMapper.getUserIdByshopId(shopId);
-                priceUtilService.setProductDetails(userId, product, 0);
+                // Integer userId = shopMapper.getUserIdByshopId(shopId);
+                priceUtilService.setShopProductDetails(product);
+                // 上架平台
+                if (product.getGroundMall().contains("0")) {
+                    organizeNames.add("【采美】平台");
+                }
+                if (product.getGroundMall().contains("4")) {
+                    organizeNames.add( "【丽格集采联盟】平台");
+                }
+                product.setOrganizeNames(organizeNames);
+                organizeNames.clear();
             }
             }
         }
         }
         PaginationVo<ProductItemVo> productPage = new PaginationVo<>(productList);
         PaginationVo<ProductItemVo> productPage = new PaginationVo<>(productList);
@@ -217,13 +230,18 @@ public class ShopServiceImpl implements ShopService {
         }
         }
         List<Sku> skus = JSON.parseArray(productDto.getSkus(), Sku.class);
         List<Sku> skus = JSON.parseArray(productDto.getSkus(), Sku.class);
         skus.forEach(s -> {
         skus.forEach(s -> {
-            Assert.notNull(s.getCostPrice(), "结算价不能为空!");
             Assert.notNull(s.getNormalPrice(), "市场价不能为空!");
             Assert.notNull(s.getNormalPrice(), "市场价不能为空!");
             Assert.notNull(s.getPrice(), "售价不能为空!");
             Assert.notNull(s.getPrice(), "售价不能为空!");
             Assert.notNull(s.getUnit(), "规格不能为空!");
             Assert.notNull(s.getUnit(), "规格不能为空!");
             Assert.notNull(s.getMinBuyNumber(), "起订量不能为空!");
             Assert.notNull(s.getMinBuyNumber(), "起订量不能为空!");
         });
         });
-
+        List<Sku> mallSkus = JSON.parseArray(productDto.getMallSkus(), Sku.class);
+        mallSkus.forEach(s -> {
+            Assert.notNull(s.getNormalPrice(), "市场价不能为空!");
+            Assert.notNull(s.getPrice(), "售价不能为空!");
+            Assert.notNull(s.getUnit(), "规格不能为空!");
+            Assert.notNull(s.getMinBuyNumber(), "起订量不能为空!");
+        });
 
 
         JSONObject parseObject = JSON.parseObject(productDto.getParams());
         JSONObject parseObject = JSON.parseObject(productDto.getParams());
         //图片
         //图片
@@ -260,6 +278,9 @@ public class ShopServiceImpl implements ShopService {
         }
         }
         product.setPriceFlag(priceFlag);
         product.setPriceFlag(priceFlag);
         product.setCommodityDetailsFlag(commodityDetailsFlag);
         product.setCommodityDetailsFlag(commodityDetailsFlag);
+        // 上架商城
+        String groundMall = productDto.getGroundMall().replaceAll(",","##");
+        product.setGroundMall(groundMall);
         //设置主图
         //设置主图
         for (Map<String, String> map : imageList) {
         for (Map<String, String> map : imageList) {
             String mainFlag = map.get("mainFlag");
             String mainFlag = map.get("mainFlag");
@@ -280,8 +301,16 @@ public class ShopServiceImpl implements ShopService {
             product.setLadderPriceFlag(0);
             product.setLadderPriceFlag(0);
             log.info("---------------------------------->" + product);
             log.info("---------------------------------->" + product);
             shopMapper.insertProduct(product);
             shopMapper.insertProduct(product);
+            // 采美商城商品状态
+            shopMapper.insertVaildFlag(0,product.getProductId(), product.getValidFlag());
             //插入sku
             //插入sku
             addSkus(skus, product.getProductId());
             addSkus(skus, product.getProductId());
+            if (null != mallSkus && mallSkus.size() > 0) {
+                // 外部商城商品状态
+                shopMapper.insertVaildFlag(4,product.getProductId(), product.getValidFlag());
+                // 外部商城sku
+                saveMallSku(mallSkus, product.getProductId());
+            }
             if (StringUtils.isBlank(productDto.getProductCode())) {
             if (StringUtils.isBlank(productDto.getProductCode())) {
                 String productCode = shopMapper.getCodeByTypeId(productDto.getBigTypeId(), productDto.getSmallTypeId(), productDto.getTinyTypeId());
                 String productCode = shopMapper.getCodeByTypeId(productDto.getBigTypeId(), productDto.getSmallTypeId(), productDto.getTinyTypeId());
                 productCode = productCode + product.getProductId();
                 productCode = productCode + product.getProductId();
@@ -291,8 +320,16 @@ public class ShopServiceImpl implements ShopService {
         } else {
         } else {
             log.info("---------------------------------->" + product);
             log.info("---------------------------------->" + product);
             shopMapper.updateProduct(product);
             shopMapper.updateProduct(product);
+            // 采美商城商品状态
+            shopMapper.updateVaildFlag(0,product.getProductId(),product.getValidFlag());
             //修改sku
             //修改sku
             updateSkus(skus, product.getProductId());
             updateSkus(skus, product.getProductId());
+            if (null != mallSkus && mallSkus.size() > 0) {
+                // 外部商城商品状态
+                shopMapper.updateVaildFlag(4,product.getProductId(),product.getValidFlag());
+                // 外部商城sku
+                saveMallSku(mallSkus, product.getProductId());
+            }
         }
         }
         //保存或修改商品图片
         //保存或修改商品图片
         List<ProductImagePo> productImageList = shopMapper.getImageByProductId(product.getProductId());
         List<ProductImagePo> productImageList = shopMapper.getImageByProductId(product.getProductId());
@@ -355,6 +392,7 @@ public class ShopServiceImpl implements ShopService {
         if (null != skus && skus.size() > 0) {
         if (null != skus && skus.size() > 0) {
             skus.forEach(s -> {
             skus.forEach(s -> {
                 s.setProductId(productId);
                 s.setProductId(productId);
+                s.setOrganizeId(0);
                 shopMapper.insertSku(s);
                 shopMapper.insertSku(s);
             });
             });
         }
         }
@@ -363,6 +401,7 @@ public class ShopServiceImpl implements ShopService {
     public void updateSkus(List<Sku> skus, Integer productId) {
     public void updateSkus(List<Sku> skus, Integer productId) {
         skus.forEach(s -> {
         skus.forEach(s -> {
             s.setProductId(productId);
             s.setProductId(productId);
+            s.setOrganizeId(0);
             if (null != s.getSkuId()) {
             if (null != s.getSkuId()) {
                 shopMapper.updateSku(s);
                 shopMapper.updateSku(s);
             } else {
             } else {
@@ -371,6 +410,28 @@ public class ShopServiceImpl implements ShopService {
         });
         });
     }
     }
 
 
+    /**
+     * 外部商城sku信息保存
+     * @param skus
+     * @param productId
+     */
+    public void saveMallSku(List<Sku> skus, Integer productId) {
+        skus.forEach(s -> {
+            s.setProductId(productId);
+            s.setOrganizeId(4);
+            // 默认比例
+            s.setOrganizePercent(17d);
+            s.setShopPercent(80d);
+            s.setCmPercent(3d);
+            s.setOrganizeId(s.getOrganizeId());
+            if (null == s.getSkuId()) {
+                shopMapper.insertSku(s);
+            } else {
+                shopMapper.updateSku(s);
+            }
+        });
+    }
+
     /**
     /**
      * 供应商-商品编辑回显
      * 供应商-商品编辑回显
      *
      *
@@ -381,12 +442,20 @@ public class ShopServiceImpl implements ShopService {
         if (null == productId) {
         if (null == productId) {
             return ResponseJson.error("参数异常:商品Id不能为空!", null);
             return ResponseJson.error("参数异常:商品Id不能为空!", null);
         }
         }
+        // 采美sku
         List<Sku> skus = priceMapper.findSkus(productId);
         List<Sku> skus = priceMapper.findSkus(productId);
         ProductFormVo product = shopMapper.getProductForm(productId);
         ProductFormVo product = shopMapper.getProductForm(productId);
-        product.setSkus(skus);
         if (null == product) {
         if (null == product) {
             return ResponseJson.error("商品信息异常,productId:" + productId, null);
             return ResponseJson.error("商品信息异常,productId:" + productId, null);
         }
         }
+        product.setSkus(skus);
+        // 外部商城sku
+        List<Sku> organizeSkus = priceMapper.findOrganizeProductSkus(productId);
+        if (null != organizeSkus) {
+            product.setMallSkus(organizeSkus);
+        }
+        // 上架平台
+        product.setGroundMall(product.getGroundMall().replaceAll("##",","));
         if (StringUtils.isNotBlank(product.getTags())) {
         if (StringUtils.isNotBlank(product.getTags())) {
             String[] tags = product.getTags().split(",");
             String[] tags = product.getTags().split(",");
             product.setTagsList(tags);
             product.setTagsList(tags);
@@ -556,18 +625,24 @@ public class ShopServiceImpl implements ShopService {
      * 供应商-批量下架商品
      * 供应商-批量下架商品
      *
      *
      * @param productIds 商品id集合,以','隔开
      * @param productIds 商品id集合,以','隔开
+     * @param groundMallType 上架平台类型
      */
      */
     @Override
     @Override
-    public ResponseJson soldOutProducts(String productIds) {
-        if (StringUtils.isBlank(productIds)) {
-            return ResponseJson.error("参数异常:请传入商品Id!");
-        }
+    public ResponseJson soldOutProducts(String productIds, Integer groundMallType) {
+
         String[] split = productIds.split(",");
         String[] split = productIds.split(",");
         for (String productId : split) {
         for (String productId : split) {
             if (StringUtils.isNotBlank(productId)) {
             if (StringUtils.isNotBlank(productId)) {
                 ProductFormVo product = shopMapper.getProductForm(Integer.valueOf(productId));
                 ProductFormVo product = shopMapper.getProductForm(Integer.valueOf(productId));
-                if (2 != product.getValidFlag()) {
-                    return ResponseJson.error("只能下架已上架的商品");
+                if (0 == groundMallType || 1 == groundMallType) {
+                    if (2 != product.getValidFlag()) {
+                        return ResponseJson.error("只能下架已上架的商品");
+                    }
+                }
+                if (0 == groundMallType || 2 == groundMallType) {
+                    if (2 != product.getMallValidFlag()) {
+                        return ResponseJson.error("只能下架已上架的商品");
+                    }
                 }
                 }
                 PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(product.getProductId());
                 PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(product.getProductId());
                 if (null != promotions) {
                 if (null != promotions) {
@@ -601,7 +676,7 @@ public class ShopServiceImpl implements ShopService {
                     return ResponseJson.error("此商品是正在进行的" + message + "促销活动的赠品,活动期间不能下架,如需强行下架,请联系客服:0755-22907771");
                     return ResponseJson.error("此商品是正在进行的" + message + "促销活动的赠品,活动期间不能下架,如需强行下架,请联系客服:0755-22907771");
                 }
                 }
                 product.setValidFlag(3);
                 product.setValidFlag(3);
-                shopMapper.updateProductValidFlag(product.getProductId(), product.getValidFlag());
+                shopMapper.updateProductValidFlag(product.getProductId(), product.getValidFlag(),groundMallType);
             }
             }
         }
         }
         return ResponseJson.success();
         return ResponseJson.success();

+ 7 - 7
src/main/resources/mapper/CouponMapper.xml

@@ -69,17 +69,17 @@
         p.name,
         p.name,
         p.aliasName,
         p.aliasName,
         p.mainImage AS image,
         p.mainImage AS image,
-        (select unit from cm_sku where productId=p.productID order by price asc limit 1)as unit,
+        (select unit from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as unit,
         p.productCode AS CODE,
         p.productCode AS CODE,
         p.priceFlag,
         p.priceFlag,
-        (select price from cm_sku where productId=p.productID order by price asc limit 1)as price,
-        (select costPrice from cm_sku where productId=p.productID order by price asc limit 1)as costPrice,
-        (select costCheckFlag from cm_sku where productId=p.productID order by price asc limit 1)as costCheckFlag,
+        (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as price,
+        (select costPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as costPrice,
+        (select costCheckFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as costCheckFlag,
         p.shopID AS shopId,
         p.shopID AS shopId,
         p.searchKey AS keyword,
         p.searchKey AS keyword,
-        (select minBuyNumber from cm_sku where productId=p.productID order by price asc limit 1) AS minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productId=p.productID order by price asc limit 1)as ladderPriceFlag,
-        (select normalPrice from cm_sku where productId=p.productID order by price asc limit 1)as normalPrice,
+        (select minBuyNumber from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) AS minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as ladderPriceFlag,
+        (select normalPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
         p.step,
         p.step,
         p.shopID AS shopId,
         p.shopID AS shopId,
         p.taxPoint AS taxRate,
         p.taxPoint AS taxRate,

+ 5 - 5
src/main/resources/mapper/HeheMapper.xml

@@ -19,7 +19,7 @@
         chp.clubTaxPoint,
         chp.clubTaxPoint,
         p.name,
         p.name,
         (select unit from cm_sku cs left join cm_hehe_sku chs on cs.skuId=chs.skuId where chs.productId=chp.productId
         (select unit from cm_sku cs left join cm_hehe_sku chs on cs.skuId=chs.skuId where chs.productId=chp.productId
-        order by chs.price asc limit 1) as unit,
+        and cs.organizeId = 0 order by chs.price asc limit 1) as unit,
         p.mainImage
         p.mainImage
         FROM cm_hehe_product chp
         FROM cm_hehe_product chp
         LEFT JOIN product p ON chp.productId = p.productID
         LEFT JOIN product p ON chp.productId = p.productID
@@ -85,13 +85,13 @@
                (select unit
                (select unit
                 from cm_sku cs
                 from cm_sku cs
                          left join cm_hehe_sku chs on cs.skuId = chs.skuId
                          left join cm_hehe_sku chs on cs.skuId = chs.skuId
-                where cs.productId = chp.productId
+                where cs.productId = chp.productId  and cs.organizeId = 0
                 order by chs.price asc
                 order by chs.price asc
                 limit 1)                                                                                  as unit,
                 limit 1)                                                                                  as unit,
                (select stock
                (select stock
                 from cm_sku cs
                 from cm_sku cs
                          left join cm_hehe_sku chs on cs.skuId = chs.skuId
                          left join cm_hehe_sku chs on cs.skuId = chs.skuId
-                where cs.productId = chp.productId
+                where cs.productId = chp.productId  and cs.organizeId = 0
                 order by chs.price asc
                 order by chs.price asc
                 limit 1)                                                                                  as stock,
                 limit 1)                                                                                  as stock,
                chp.includedTax,
                chp.includedTax,
@@ -348,13 +348,13 @@
                cs.productId,
                cs.productId,
                cs.costCheckFlag,
                cs.costCheckFlag,
                cs.costPrice,
                cs.costPrice,
-               cs.costProportional,
+               cs.shopPercent as costProportional,
                cs.stock,
                cs.stock,
                chs.price,
                chs.price,
                chs.price as normalPrice
                chs.price as normalPrice
         from cm_hehe_sku chs
         from cm_hehe_sku chs
                  left join cm_sku cs on cs.skuId = chs.skuId
                  left join cm_sku cs on cs.skuId = chs.skuId
-        where chs.productId = #{productId}
+        where chs.productId = #{productId}  and cs.organizeId = 0
         order by chs.price asc
         order by chs.price asc
     </select>
     </select>
     <select id="getActivityLadderListBySkuId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
     <select id="getActivityLadderListBySkuId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">

+ 73 - 92
src/main/resources/mapper/MallOrganizeMapper.xml

@@ -49,21 +49,19 @@
     <select id="getFloorProducts" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getFloorProducts" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT
         SELECT
         cmfp.floorId,
         cmfp.floorId,
-        cmop.productID AS productId,
-        (select price from cm_mall_product_sku where productID=p.productID order by price asc limit 1) as price,
-        cmop.normalPrice,
-        cmop.costPrice,
-        cmop.ladderPriceFlag,
-        cmop.retailPrice,
-        cmop.minBuyNumber,
-        cmop.validFlag,
+        p.productID AS productId,
+        (select price from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as price,
+        p.normalPrice,
+        p.costPrice,
+        p.ladderPriceFlag,
+        (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+        p.validFlag,
         p.name,
         p.name,
         p.mainImage
         p.mainImage
         FROM cm_mall_floor_product cmfp
         FROM cm_mall_floor_product cmfp
-        LEFT JOIN cm_mall_organize_products cmop ON cmfp.productId = cmop.id
-        LEFT JOIN product p ON p.productId = cmop.productId
+        LEFT JOIN product p ON p.productId = cmfp.productId
         <where>
         <where>
-            cmop.delFlag = 0 AND cmop.validFlag = 1
+            p.validFlag = 2
             <if test="floorIds.size() > 0">
             <if test="floorIds.size() > 0">
                 and cmfp.floorId in
                 and cmfp.floorId in
                 <foreach collection="floorIds" item="floorId" open="(" separator="," close=")">
                 <foreach collection="floorIds" item="floorId" open="(" separator="," close=")">
@@ -84,20 +82,17 @@
     </select>
     </select>
     <select id="getMallProducts" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getMallProducts" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT
         SELECT
-        cmop.productID as productId,
-        cmop.normalPrice,
-        cmop.costPrice,
-        cmop.ladderPriceFlag,
-        cmop.retailPrice,
-        cmop.minBuyNumber,
-        cmop.validFlag,
+        p.productID as productId,
+        p.normalPrice,
+        p.costPrice,
+        p.ladderPriceFlag,
+        (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+        p.validFlag,
         p.name,
         p.name,
         p.mainImage
         p.mainImage
-        FROM cm_mall_active_product cmap
-        LEFT JOIN cm_mall_organize_products cmop ON cmap.productId = cmop.productID
-        LEFT JOIN product p ON p.productID = cmap.productId
+        FROM product p
         <where>
         <where>
-            cmop.delFlag = 0 AND cmop.validFlag = 1
+            p.validFlag = 2
             <if test="activeIds.size() > 0">
             <if test="activeIds.size() > 0">
                 and cmap.activeId in
                 and cmap.activeId in
                 <foreach collection="activeIds" item="activeId" open="(" separator="," close=")">
                 <foreach collection="activeIds" item="activeId" open="(" separator="," close=")">
@@ -113,20 +108,18 @@
     </select>
     </select>
     <select id="getMenuProductList" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getMenuProductList" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT
         SELECT
-            cmop.productID as productId,
-            cmop.normalPrice,
-            cmop.costPrice,
-            cmop.ladderPriceFlag,
-            cmop.retailPrice,
-            cmop.minBuyNumber,
-            cmop.validFlag,
+            p.productID as productId,
+            p.normalPrice,
+            p.costPrice,
+            p.ladderPriceFlag,
+            (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+            p.validFlag,
             p.name,
             p.name,
             p.mainImage
             p.mainImage
         FROM cm_mall_mainmenu cmm
         FROM cm_mall_mainmenu cmm
-                 LEFT JOIN cm_mall_organize_products cmop ON cmop.productID = cmm.jumpProductId
-                 LEFT JOIN product p ON p.productId = cmop.productID
+                 LEFT JOIN product p ON p.productId = cmm.jumpProductId
         WHERE cmm.organizeId = #{organizeId} and cmm.id = #{id}
         WHERE cmm.organizeId = #{organizeId} and cmm.id = #{id}
-          and cmm.enabledStatus = 1 and cmop.delFlag = 0
+          and cmm.enabledStatus = 1
     </select>
     </select>
     <select id="getActiveById" resultType="com.caimei365.commodity.model.vo.MallActiveVo">
     <select id="getActiveById" resultType="com.caimei365.commodity.model.vo.MallActiveVo">
         SELECT id, organizeId, topic, enabledStatus, activeType
         SELECT id, organizeId, topic, enabledStatus, activeType
@@ -143,22 +136,19 @@
     </select>
     </select>
     <select id="getActiveProduct" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getActiveProduct" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT
         SELECT
-            cmop.id,
+            p.productID as productId,
             cmap.imageId AS imageId,
             cmap.imageId AS imageId,
-            cmop.productID AS productId,
-            cmop.normalPrice,
-            cmop.costPrice,
-            (SELECT price FROM cm_mall_product_sku WHERE productID=p.productID ORDER BY price ASC LIMIT 1) AS price,
-            cmop.ladderPriceFlag,
-            cmop.retailPrice,
-            cmop.minBuyNumber,
-            cmop.validFlag,
+            p.normalPrice,
+            p.costPrice,
+            (SELECT price FROM cm_sku WHERE productID=p.productID and organizeId = 4 ORDER BY price ASC LIMIT 1) AS price,
+            p.ladderPriceFlag,
+            (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+            p.validFlag,
             p.name,
             p.name,
             p.mainImage
             p.mainImage
-        FROM  cm_mall_organize_products cmop
-                  LEFT JOIN product p ON cmop.productId = p.productId
-                  LEFT JOIN cm_mall_active_product cmap ON cmop.id = cmap.productId
-        WHERE cmap.activeId = #{activeId} and cmop.validFlag = 1
+        FROM  product p
+                  LEFT JOIN cm_mall_active_product cmap ON p.productId = cmap.productId
+        WHERE cmap.activeId = #{activeId}
         order by cmap.sort
         order by cmap.sort
     </select>
     </select>
     <select id="getActiveImageById" resultType="com.caimei365.commodity.model.vo.MallActiveImageVo">
     <select id="getActiveImageById" resultType="com.caimei365.commodity.model.vo.MallActiveImageVo">
@@ -169,22 +159,20 @@
     <select id="getMenuActiveList" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getMenuActiveList" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT
         SELECT
             cmap.imageId as imageId,
             cmap.imageId as imageId,
-            cmop.productID as productId,
-            cmop.normalPrice,
-            cmop.costPrice,
-            (select price from cm_mall_product_sku where productID=p.productID order by price asc limit 1) as price,
-            cmop.ladderPriceFlag,
-            cmop.retailPrice,
-            cmop.minBuyNumber,
-            cmop.validFlag,
+            p.productID as productId,
+            p.normalPrice,
+            p.costPrice,
+            (select price from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as price,
+            p.ladderPriceFlag,
+            (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+            IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 4), 999) AS validFlag,
             p.name,
             p.name,
             p.mainImage
             p.mainImage
         FROM cm_mall_active cma
         FROM cm_mall_active cma
          LEFT JOIN cm_mall_active_product cmap ON cmap.activeId = cma.id
          LEFT JOIN cm_mall_active_product cmap ON cmap.activeId = cma.id
-         LEFT JOIN cm_mall_organize_products cmop ON cmop.id = cmap.productId
-         LEFT JOIN product p ON p.productId = cmop.productId
+         LEFT JOIN product p ON p.productId = cmap.productId
         where  cma.id = #{activeId}
         where  cma.id = #{activeId}
-          and cma.enabledStatus = 1 and cmop.delFlag = 0
+          and cma.enabledStatus = 1
     </select>
     </select>
     <select id="getActiveInfo" resultType="com.caimei365.commodity.model.vo.MallActiveVo">
     <select id="getActiveInfo" resultType="com.caimei365.commodity.model.vo.MallActiveVo">
         SELECT
         SELECT
@@ -197,39 +185,34 @@
         SELECT
         SELECT
             cmap.imageId AS imageId,
             cmap.imageId AS imageId,
             (SELECT topic FROM cm_mall_active_image WHERE id = #{imageId} limit 1) AS topic,
             (SELECT topic FROM cm_mall_active_image WHERE id = #{imageId} limit 1) AS topic,
-            cmop.productID AS productId,
-            cmop.normalPrice,
-            cmop.costPrice,
-            (SELECT price FROM cm_mall_product_sku WHERE productID=p.productID ORDER BY price ASC LIMIT 1) AS price,
-            cmop.ladderPriceFlag,
-            cmop.retailPrice,
-            cmop.minBuyNumber,
-            cmop.validFlag,
+            p.productID AS productId,
+            p.normalPrice,
+            p.costPrice,
+            (SELECT price FROM cm_sku WHERE productID=p.productID and organizeId = 4 ORDER BY price ASC LIMIT 1) AS price,
+            p.ladderPriceFlag,
+            (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+            IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 4), 999) AS validFlag,
             p.name,
             p.name,
             p.mainImage
             p.mainImage
-        FROM cm_mall_organize_products cmop
-                 LEFT JOIN cm_mall_active_product cmap ON cmop.id = cmap.productId
-                 LEFT JOIN product p ON cmop.productId = p.productId
-            where cmap.imageId = #{imageId} and cmop.validFlag = 1
+        FROM product p
+                 LEFT JOIN cm_mall_active_product cmap ON p.productId = cmap.productId
+            where cmap.imageId = #{imageId}
             order by cmap.sort
             order by cmap.sort
     </select>
     </select>
     <select id="getOrganizeProducts" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getOrganizeProducts" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT
         SELECT
             cmfp.floorId,
             cmfp.floorId,
-            cmop.productID AS productId,
-            cmop.normalPrice,
-            cmop.costPrice,
-            (SELECT price FROM cm_mall_product_sku WHERE productID=p.productID ORDER BY price ASC LIMIT 1) AS price,
-            cmop.ladderPriceFlag,
-            cmop.retailPrice,
-            cmop.minBuyNumber,
-            cmop.validFlag,
+            p.productID AS productId,
+            p.normalPrice,
+            p.costPrice,
+            (SELECT price FROM cm_sku WHERE productID=p.productID and organizeId = 4 ORDER BY price ASC LIMIT 1) AS price,
+            p.ladderPriceFlag,
+            (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+            IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 4), 999) AS validFlag,
             p.name,
             p.name,
-            p.mainImage,
-            cmop.organizeId
-        FROM cm_mall_organize_products cmop
-                 LEFT JOIN product p ON p.productId = cmop.productId
-                 LEFT JOIN cm_mall_floor_product cmfp ON cmfp.productId = cmop.id
+            p.mainImage
+        FROM product p
+                 LEFT JOIN cm_mall_floor_product cmfp ON cmfp.productId = p.productId
         WHERE cmfp.floorId = #{floorId}
         WHERE cmfp.floorId = #{floorId}
     </select>
     </select>
     <select id="getThemeInfo" resultType="com.caimei365.commodity.model.vo.MallThemeVo">
     <select id="getThemeInfo" resultType="com.caimei365.commodity.model.vo.MallThemeVo">
@@ -239,18 +222,16 @@
     </select>
     </select>
     <select id="getThemeProduct" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getThemeProduct" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT
         SELECT
-            cmop.productID as productId,
-            cmop.normalPrice,
-            cmop.costPrice,
-            (select price from cm_mall_product_sku where productID=p.productID order by price asc limit 1) as price,
-            cmop.ladderPriceFlag,
-            cmop.retailPrice,
-            cmop.minBuyNumber,
-            cmop.validFlag,
+            p.productID as productId,
+            p.normalPrice,
+            p.costPrice,
+            (select price from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as price,
+            p.ladderPriceFlag,
+            (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as minBuyNumber,
+            p.validFlag,
             p.name,
             p.name,
             p.mainImage
             p.mainImage
-        FROM  cm_mall_organize_products cmop
-                 LEFT JOIN product p ON p.productId = cmop.productID
-        WHERE cmop.organizeId = #{organizeId} and cmop.id = #{id} and cmop.delFlag = 0
+        FROM  product p
+        WHERE p.productId = #{id}
     </select>
     </select>
 </mapper>
 </mapper>

+ 19 - 28
src/main/resources/mapper/MallProductMapper.xml

@@ -4,39 +4,30 @@
     <select id="getOrganizeProductDetails" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
     <select id="getOrganizeProductDetails" resultType="com.caimei365.commodity.model.vo.MallOrganizeProductVo">
         SELECT p.productID                                                                                     AS productId,
         SELECT p.productID                                                                                     AS productId,
                p.shopID                                                                                        AS shopId,
                p.shopID                                                                                        AS shopId,
-               cmop.normalPrice AS normalPrice,
-               (select price from cm_mall_product_sku where productID=p.productID order by price asc limit 1) as price,
-               IFNULL((SELECT stock FROM cm_sku WHERE productId = #{productId} ORDER BY price ASC LIMIT 1), 0) AS stock,
-               cmop.minBuyNumber AS minBuyNumber,
-               (SELECT unit FROM cm_sku WHERE productId = #{productId} ORDER BY price ASC LIMIT 1)             AS unit,
-               cmop.validFlag,
+               p.normalPrice AS normalPrice,
+               (select price from cm_sku where productID=p.productID and organizeId = 4 order by price asc limit 1) as price,
+               IFNULL((SELECT stock FROM cm_sku WHERE productId = #{productId} and organizeId = 4 ORDER BY price ASC LIMIT 1), 0) AS stock,
+               p.minBuyNumber AS minBuyNumber,
+               (SELECT unit FROM cm_sku WHERE productId = #{productId} and organizeId = 4 ORDER BY price ASC LIMIT 1)             AS unit,
+               p.validFlag,
                p.name,
                p.name,
                s.name as shopName
                s.name as shopName
-        FROM cm_mall_organize_products cmop
-                 LEFT JOIN product p ON p.productId = cmop.productId
+        FROM  product p
                  LEFT JOIN shop s ON s.shopId = p.shopId
                  LEFT JOIN shop s ON s.shopId = p.shopId
         WHERE p.productID = #{productId}
         WHERE p.productID = #{productId}
     </select>
     </select>
-    <select id="getMallSkus" resultType="com.caimei365.commodity.model.vo.MallProductSkuVo">
+    <select id="getMallSkus" resultType="com.caimei365.commodity.model.dto.Sku">
         SELECT
         SELECT
-            cmps.id,
-            cmps.productId,
-            cmps.mallProductId,
-            cmps.id,
-            cmps.skuId,
-            cmps.minBuyNumber,
-            cmps.price,
-            cs.unit,
-            cs.price as clubPrice,
-            cs.costCheckFlag as costCheckFlag,
-            cs.costPrice as costPrice,
-            cs.costProportional as costProportional,
-            cs.minBuyNumber AS cmMinBuyNumber,
-            cmps.organizePercent,
-            cmps.shopPercent,
-            cmps.cmPercent
-        FROM cm_mall_product_sku cmps
-                 LEFT JOIN cm_sku cs ON cmps.skuId = cs.skuId
-        where cmps.mallProductId = #{mallProductId}
+            skuId,
+            productId,
+            minBuyNumber,
+            price,
+            unit,
+            stock,
+            organizePercent,
+            shopPercent,
+            cmPercent
+        FROM cm_sku
+        where productId = #{mallProductId} and organizeId = 4
     </select>
     </select>
 </mapper>
 </mapper>

+ 72 - 61
src/main/resources/mapper/PageMapper.xml

@@ -164,28 +164,28 @@
                p.mainImage                                                                          as image,
                p.mainImage                                                                          as image,
                p.productCode                                                                        as code,
                p.productCode                                                                        as code,
                p.priceFlag,
                p.priceFlag,
-               (select unit from cm_sku where productID = #{productId} order by price asc LIMIT 1)  as unit,
-               (select price from cm_sku where productID = #{productId} order by price asc LIMIT 1) as price,
+               (select unit from cm_sku where productID = #{productId} and organizeId = 0 order by price asc LIMIT 1)  as unit,
+               (select price from cm_sku where productID = #{productId} and organizeId = 0 order by price asc LIMIT 1) as price,
                (select price
                (select price
                 from cm_sku
                 from cm_sku
-                where productID = #{productId}
+                where productID = #{productId} and organizeId = 0
                 order by price asc
                 order by price asc
                 LIMIT 1)                                                                            as originalPrice,
                 LIMIT 1)                                                                            as originalPrice,
                p.shopID                                                                             as shopId,
                p.shopID                                                                             as shopId,
                p.searchKey                                                                          as keyword,
                p.searchKey                                                                          as keyword,
                (select minBuyNumber
                (select minBuyNumber
                 from cm_sku
                 from cm_sku
-                where productID = #{productId}
+                where productID = #{productId} and organizeId = 0
                 order by price asc
                 order by price asc
                 LIMIT 1)                                                                            as minBuyNumber,
                 LIMIT 1)                                                                            as minBuyNumber,
                (select ladderPriceFlag
                (select ladderPriceFlag
                 from cm_sku
                 from cm_sku
-                where productID = #{productId}
+                where productID = #{productId} and organizeId = 0
                 order by price asc
                 order by price asc
                 LIMIT 1)                                                                            as ladderPriceFlag,
                 LIMIT 1)                                                                            as ladderPriceFlag,
                (select normalPrice
                (select normalPrice
                 from cm_sku
                 from cm_sku
-                where productID = #{productId}
+                where productID = #{productId} and organizeId = 0
                 order by price asc
                 order by price asc
                 LIMIT 1)                                                                            as normalPrice,
                 LIMIT 1)                                                                            as normalPrice,
                p.step,
                p.step,
@@ -194,7 +194,7 @@
                p.includedTax,
                p.includedTax,
                p.invoiceType,
                p.invoiceType,
                p.productCategory                                                                    as productCategory,
                p.productCategory                                                                    as productCategory,
-               p.validFlag,
+               copi.validFlag,
                p.featuredFlag,
                p.featuredFlag,
                p.commodityType,
                p.commodityType,
                p.bigTypeID                                                                          as bigTypeId,
                p.bigTypeID                                                                          as bigTypeId,
@@ -205,8 +205,10 @@
                p.productType
                p.productType
         from product p
         from product p
                  left join cm_second_hand_detail cshd on p.productID = cshd.productID
                  left join cm_second_hand_detail cshd on p.productID = cshd.productID
+                 left join cm_organize_product_info copi on copi.productId = p.productId
         where p.productID = #{productId}
         where p.productID = #{productId}
-          and p.validFlag = 2
+          and copi.organizeId = 0
+          and copi.validFlag = 2
     </select>
     </select>
     <select id="getSupplierFloorImage" resultType="com.caimei365.commodity.model.vo.ShopFloorVo">
     <select id="getSupplierFloorImage" resultType="com.caimei365.commodity.model.vo.ShopFloorVo">
         select id, crmImage, wwwImage, wwwLink
         select id, crmImage, wwwImage, wwwLink
@@ -237,16 +239,16 @@
                p.shopID                                                                                        as shopId,
                p.shopID                                                                                        as shopId,
                (select normalPrice
                (select normalPrice
                 from cm_sku
                 from cm_sku
-                where productId = #{productId}
+                where productId = #{productId} and organizeId = 0
                 order by price asc
                 order by price asc
                 limit 1)                                                                                       as normalPrice,
                 limit 1)                                                                                       as normalPrice,
-               ifnull((select stock from cm_sku where productId = #{productId} order by price asc limit 1), 0) as stock,
+               ifnull((select stock from cm_sku where productId = #{productId} and organizeId = 0 order by price asc limit 1), 0) as stock,
                (select minBuyNumber
                (select minBuyNumber
                 from cm_sku
                 from cm_sku
-                where productId = #{productId}
+                where productId = #{productId} and organizeId = 0
                 order by price asc
                 order by price asc
                 limit 1)                                                                                       as minBuyNumber,
                 limit 1)                                                                                       as minBuyNumber,
-               (select unit from cm_sku where productId = #{productId} order by price asc limit 1)             as unit,
+               (select unit from cm_sku where productId = #{productId} and organizeId = 0 order by price asc limit 1)             as unit,
                p.name,
                p.name,
                p.aliasName,
                p.aliasName,
                p.commodityType,
                p.commodityType,
@@ -277,7 +279,7 @@
                p.machineType,
                p.machineType,
                p.productCode,
                p.productCode,
                p.updateTime,
                p.updateTime,
-               p.validFlag,
+               IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
                p.searchKey,
                p.searchKey,
                p.allAreaFlag,
                p.allAreaFlag,
                p.step,
                p.step,
@@ -302,20 +304,13 @@
     <select id="getProductOrganizeDetails" resultType="com.caimei365.commodity.model.vo.ProductDetailVo">
     <select id="getProductOrganizeDetails" resultType="com.caimei365.commodity.model.vo.ProductDetailVo">
         select p.productID                                                                                     as productId,
         select p.productID                                                                                     as productId,
                p.shopID                                                                                        as shopId,
                p.shopID                                                                                        as shopId,
-               (select normalPrice
-                from cm_sku
-                where productId = #{productId}
-                order by price asc
-                limit 1)                                                                                       as normalPrice,
-               ifnull((select stock from cm_sku where productId = #{productId} order by price asc limit 1), 0) as stock,
                (select minBuyNumber
                (select minBuyNumber
-                from cm_mall_product_sku
-                where productId = #{productId} or mallProductId = #{productId}
+                from cm_sku
+                where productId = #{productId} and organizeId = 4
                 order by price asc
                 order by price asc
                 limit 1)                                                                                       as minBuyNumber,
                 limit 1)                                                                                       as minBuyNumber,
-               (select cs.unit from cm_sku cs
-                   left join cm_mall_product_sku cmps on cs.skuId = cmps.skuId
-               where cmps.productId = #{productId} or cmps.mallProductId = #{productId} order by cs.price asc limit 1)             as unit,
+               (select unit from cm_sku
+               where productId = #{productId} and organizeId = 4 order by price asc limit 1)             as unit,
                p.name,
                p.name,
                p.aliasName,
                p.aliasName,
                p.commodityType,
                p.commodityType,
@@ -346,7 +341,7 @@
                p.machineType,
                p.machineType,
                p.productCode,
                p.productCode,
                p.updateTime,
                p.updateTime,
-               cmop.validFlag,
+               IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 4), 999) AS validFlag,
                p.searchKey,
                p.searchKey,
                p.allAreaFlag,
                p.allAreaFlag,
                p.step,
                p.step,
@@ -365,9 +360,8 @@
                p.returnGoodsStutas,
                p.returnGoodsStutas,
                P.relatedLabels
                P.relatedLabels
         from product p
         from product p
-            left join cm_mall_organize_products cmop on p.productId = cmop.productId
                  left join shop s on s.shopId = p.shopId
                  left join shop s on s.shopId = p.shopId
-        where (p.productID = #{productId} OR cmop.id = #{productId}) AND cmop.delFlag = 0
+        where p.productID = #{productId}
     </select>
     </select>
     <select id="getBuyAgainProducts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
     <select id="getBuyAgainProducts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         select p.productID                 as productId,
         select p.productID                 as productId,
@@ -392,7 +386,7 @@
                p.includedTax,
                p.includedTax,
                p.invoiceType,
                p.invoiceType,
                p.productCategory           as productCategory,
                p.productCategory           as productCategory,
-               p.validFlag,
+               copi.validFlag,
                p.featuredFlag,
                p.featuredFlag,
                p.commodityType,
                p.commodityType,
                p.bigTypeID                 as bigTypeId,
                p.bigTypeID                 as bigTypeId,
@@ -403,9 +397,12 @@
         from repeat_purchase_price rpp
         from repeat_purchase_price rpp
                  left join product p on rpp.productId = p.productID
                  left join product p on rpp.productId = p.productID
                  left join cm_sku cs on rpp.skuId = cs.skuId
                  left join cm_sku cs on rpp.skuId = cs.skuId
+                 left join cm_organize_product_info copi on copi.productId = rpp.productId
         where rpp.delFlag = '0'
         where rpp.delFlag = '0'
-          and p.validFlag = '2'
+          and copi.validFlag = 2
+          and copi.organizeId = 0
           and rpp.userId = #{userId}
           and rpp.userId = #{userId}
+          and cs.organizeId = 0
         order by rpp.createTime desc
         order by rpp.createTime desc
     </select>
     </select>
     <select id="getPageDetails" resultType="com.caimei365.commodity.model.vo.PageDetailVo">
     <select id="getPageDetails" resultType="com.caimei365.commodity.model.vo.PageDetailVo">
@@ -454,8 +451,10 @@
                p.productType
                p.productType
         from product as p
         from product as p
                  left join cm_product_recommend as pr on pr.recommendProductID = p.productID
                  left join cm_product_recommend as pr on pr.recommendProductID = p.productID
+                 left join cm_organize_product_info copi on copi.productId = p.productId
         where pr.productID = #{productId}
         where pr.productID = #{productId}
-          and p.validFlag = 2
+          and copi.organizeId = 0
+          and copi.validFlag = 2
         order by pr.sort desc
         order by pr.sort desc
     </select>
     </select>
     <select id="getAutoProductRecommends" resultType="com.caimei365.commodity.model.search.ProductListVo">
     <select id="getAutoProductRecommends" resultType="com.caimei365.commodity.model.search.ProductListVo">
@@ -466,7 +465,9 @@
                IFNULL(p.visibility, 3) as visibility,
                IFNULL(p.visibility, 3) as visibility,
                p.productType
                p.productType
         from product as p
         from product as p
-        where p.validFlag = 2
+                 left join cm_organize_product_info copi on copi.productId = p.productId
+        where copi.validFlag = 2
+          and copi.organizeId = 0
           and p.commodityType = (select commodityType from product as p1 where p1.productID = #{productId})
           and p.commodityType = (select commodityType from product as p1 where p1.productID = #{productId})
           and p.smallTypeID = (select smallTypeID from product as p2 where p2.productID = #{productId})
           and p.smallTypeID = (select smallTypeID from product as p2 where p2.productID = #{productId})
         order by p.sellNumber desc
         order by p.sellNumber desc
@@ -753,25 +754,25 @@
                p.name,
                p.name,
                p.aliasName,
                p.aliasName,
                p.mainImage                                                                           as image,
                p.mainImage                                                                           as image,
-               (select unit from cm_sku where productId = csp.productId order by price asc limit 1)  as unit,
+               (select unit from cm_sku where productId = csp.productId and organizeId = 0 order by price asc limit 1)  as unit,
                p.productCode                                                                         as code,
                p.productCode                                                                         as code,
                p.priceFlag,
                p.priceFlag,
-               (select price from cm_sku where productId = csp.productId order by price asc limit 1) as price,
+               (select price from cm_sku where productId = csp.productId and organizeId = 0 order by price asc limit 1) as price,
                p.shopID                                                                              as shopId,
                p.shopID                                                                              as shopId,
                p.searchKey                                                                           as keyword,
                p.searchKey                                                                           as keyword,
                (select minBuyNumber
                (select minBuyNumber
                 from cm_sku
                 from cm_sku
-                where productId = csp.productId
+                where productId = csp.productId and organizeId = 0
                 order by price asc
                 order by price asc
                 limit 1)                                                                             as minBuyNumber,
                 limit 1)                                                                             as minBuyNumber,
                (select ladderPriceFlag
                (select ladderPriceFlag
                 from cm_sku
                 from cm_sku
-                where productId = csp.productId
+                where productId = csp.productId and organizeId = 0
                 order by price asc
                 order by price asc
                 limit 1)                                                                             as ladderPriceFlag,
                 limit 1)                                                                             as ladderPriceFlag,
                (select normalPrice
                (select normalPrice
                 from cm_sku
                 from cm_sku
-                where productId = csp.productId
+                where productId = csp.productId and organizeId = 0
                 order by price asc
                 order by price asc
                 limit 1)                                                                             as normalPrice,
                 limit 1)                                                                             as normalPrice,
                p.step,
                p.step,
@@ -780,7 +781,7 @@
                p.includedTax,
                p.includedTax,
                p.invoiceType,
                p.invoiceType,
                p.productCategory                                                                     as productCategory,
                p.productCategory                                                                     as productCategory,
-               p.validFlag,
+               copi.validFlag,
                p.featuredFlag,
                p.featuredFlag,
                p.commodityType,
                p.commodityType,
                p.bigTypeID                                                                           as bigTypeId,
                p.bigTypeID                                                                           as bigTypeId,
@@ -789,7 +790,9 @@
                p.visibility                                                                          as visibility
                p.visibility                                                                          as visibility
         from cm_svip_product csp
         from cm_svip_product csp
                  left join product p on p.productID = csp.productId
                  left join product p on p.productID = csp.productId
-        where p.validFlag = 2
+                 left join cm_organize_product_info copi on copi.productId = csp.productId
+        where copi.validFlag = 2
+          and copi.organizeId = 0
         order by -csp.sort desc, csp.addTime desc
         order by -csp.sort desc, csp.addTime desc
     </select>
     </select>
 
 
@@ -1053,20 +1056,20 @@
         p.aliasName,
         p.aliasName,
         p.visibility,
         p.visibility,
         p.mainImage,
         p.mainImage,
-        (select unit from cm_sku where productId=p.productID order by price asc limit 1)as unit,
+        (select unit from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as unit,
         p.productCode as code,
         p.productCode as code,
         p.priceFlag,
         p.priceFlag,
         p.shopID as shopId,
         p.shopID as shopId,
         p.searchKey as keyword,
         p.searchKey as keyword,
-        (select minBuyNumber from cm_sku where productId=p.productID order by price asc limit 1)as minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productId=p.productID order by price asc limit 1)as ladderPriceFlag,
-        (select normalPrice from cm_sku where productId=p.productID order by price asc limit 1)as normalPrice,
+        (select minBuyNumber from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as ladderPriceFlag,
+        (select normalPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
         p.step,
         p.step,
         p.taxPoint as taxRate,
         p.taxPoint as taxRate,
         p.includedTax,
         p.includedTax,
         p.invoiceType,
         p.invoiceType,
         p.productCategory as productCategory,
         p.productCategory as productCategory,
-        p.validFlag,
+        copi.validFlag,
         p.featuredFlag,
         p.featuredFlag,
         p.commodityType,
         p.commodityType,
         p.bigTypeID as bigTypeId,
         p.bigTypeID as bigTypeId,
@@ -1074,13 +1077,15 @@
         p.tinyTypeID as tinyTypeId,
         p.tinyTypeID as tinyTypeId,
         p.productType,
         p.productType,
         p.brandID,
         p.brandID,
-        (select price from cm_sku where productId=p.productID order by price asc limit 1)as price
+        (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as price
         from product p
         from product p
+        left join cm_organize_product_info copi on copi.productId = p.productId
         <where>
         <where>
             and p.showFlag!=5
             and p.showFlag!=5
             and p.newvalidFlag = 1
             and p.newvalidFlag = 1
             and p.newProductType=1
             and p.newProductType=1
-            and p.validFlag = 2
+            and copi.validFlag = 2
+            and copi.organizeId = 0
             and p.showFlag!=2
             and p.showFlag!=2
             and p.recommend=1
             and p.recommend=1
         </where>
         </where>
@@ -1090,11 +1095,11 @@
 
 
     <select id="getNewFloorList" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
     <select id="getNewFloorList" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         SELECT DISTINCT
         SELECT DISTINCT
-        (select price from cm_sku where productID=p.productID order by price asc limit 1)as price,
-        (select unit from cm_sku where productID=p.productID order by price asc limit 1)as unit,
-        (select normalPrice from cm_sku where productID=p.productID order by price asc limit 1)as normalPrice,
-        (select minBuyNumber from cm_sku where productID=p.productID order by price asc limit 1)as minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productID=p.productID order by price asc limit 1)as ladderPriceFlag,
+        (select price from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as price,
+        (select unit from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as unit,
+        (select normalPrice from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
+        (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as ladderPriceFlag,
         p.productID,
         p.productID,
         p.actStatus,
         p.actStatus,
         p.name,
         p.name,
@@ -1110,7 +1115,7 @@
         p.includedTax,
         p.includedTax,
         p.invoiceType,
         p.invoiceType,
         p.productCategory as productCategory,
         p.productCategory as productCategory,
-        p.validFlag,
+        copi.validFlag,
         p.featuredFlag,
         p.featuredFlag,
         p.commodityType,
         p.commodityType,
         p.bigTypeID as bigTypeId,
         p.bigTypeID as bigTypeId,
@@ -1119,11 +1124,13 @@
         p.productType,
         p.productType,
         p.brandID
         p.brandID
         from product p
         from product p
+        left join cm_organize_product_info copi on copi.productId = p.productId
         <where>
         <where>
             and p.showFlag!=5
             and p.showFlag!=5
             and p.newvalidFlag = 1
             and p.newvalidFlag = 1
             and p.newProductType=1
             and p.newProductType=1
-            and p.validFlag = 2
+            and copi.organizeId = 0
+            and copi.validFlag = 2
             and p.showFlag!=2
             and p.showFlag!=2
             <if test="brandID != null and brandID.size > 0">
             <if test="brandID != null and brandID.size > 0">
                 and
                 and
@@ -1146,21 +1153,21 @@
         p.aliasName,
         p.aliasName,
         p.visibility,
         p.visibility,
         p.mainImage as image,
         p.mainImage as image,
-        (select unit from cm_sku where productId=p.productID order by price asc limit 1)as unit,
+        (select unit from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as unit,
         p.productCode as code,
         p.productCode as code,
         p.priceFlag,
         p.priceFlag,
-        (select price from cm_sku where productId=p.productID order by price asc limit 1)as price,
+        (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as price,
         p.shopID as shopId,
         p.shopID as shopId,
         p.searchKey as keyword,
         p.searchKey as keyword,
-        (select minBuyNumber from cm_sku where productId=p.productID order by price asc limit 1)as minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productId=p.productID order by price asc limit 1)as ladderPriceFlag,
-        (select normalPrice from cm_sku where productId=p.productID order by price asc limit 1)as normalPrice,
+        (select minBuyNumber from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as ladderPriceFlag,
+        (select normalPrice from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
         p.step,
         p.step,
         p.taxPoint as taxRate,
         p.taxPoint as taxRate,
         p.includedTax,
         p.includedTax,
         p.invoiceType,
         p.invoiceType,
         p.productCategory as productCategory,
         p.productCategory as productCategory,
-        p.validFlag,
+        copi.validFlag,
         p.featuredFlag,
         p.featuredFlag,
         p.commodityType,
         p.commodityType,
         p.bigTypeID as bigTypeId,
         p.bigTypeID as bigTypeId,
@@ -1168,8 +1175,9 @@
         p.tinyTypeID as tinyTypeId,
         p.tinyTypeID as tinyTypeId,
         p.productType,
         p.productType,
         p.brandID,
         p.brandID,
-        (select price from cm_sku where productId=p.productID order by price asc limit 1)as price
+        (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1)as price
         from product p
         from product p
+        left join cm_organize_product_info copi on copi.productId = p.productId
         <where>
         <where>
 
 
             <if test="productID != null and productID!=''">
             <if test="productID != null and productID!=''">
@@ -1177,7 +1185,8 @@
             </if>
             </if>
             and p.newvalidFlag = 1
             and p.newvalidFlag = 1
             and p.newProductType=1
             and p.newProductType=1
-            and p.validFlag = 2
+            and copi.organizeId = 0
+            and copi.validFlag = 2
         </where>
         </where>
 
 
         # order by p.combinationSort != 0 desc, p.combinationSort asc
         # order by p.combinationSort != 0 desc, p.combinationSort asc
@@ -1195,9 +1204,11 @@
         SELECT DISTINCT s.`id`, s.`name`
         SELECT DISTINCT s.`id`, s.`name`
         FROM product a
         FROM product a
                  LEFT JOIN `cm_brand` s ON s.id = a.brandID
                  LEFT JOIN `cm_brand` s ON s.id = a.brandID
+                 left join cm_organize_product_info copi on copi.productId = a.productId
         WHERE a.newvalidFlag = 1
         WHERE a.newvalidFlag = 1
           AND a.newProductType = 1
           AND a.newProductType = 1
-          AND a.validFlag = 2
+          AND copi.organizeId = 0
+          AND copi.validFlag = 2
           AND a.showFlag != 2
           AND a.showFlag != 2
           AND s.id IS NOT NULL
           AND s.id IS NOT NULL
           AND s.name IS NOT NULL
           AND s.name IS NOT NULL

+ 50 - 51
src/main/resources/mapper/PriceMapper.xml

@@ -11,7 +11,7 @@
                p.actStatus,
                p.actStatus,
                (select normalPrice
                (select normalPrice
                 from cm_sku
                 from cm_sku
-                where productId = #{productId}
+                where productId = #{productId} and organizeId = 0
                 order by price asc
                 order by price asc
                 limit 1)                    as normalPrice,
                 limit 1)                    as normalPrice,
                p.priceFlag,
                p.priceFlag,
@@ -30,15 +30,24 @@
         left join (select priceType,discount,discountPrice,csps.productId
         left join (select priceType,discount,discountPrice,csps.productId
                 from cm_svip_product_sku csps
                 from cm_svip_product_sku csps
                 left join cm_sku cs on csps.skuId=cs.skuId
                 left join cm_sku cs on csps.skuId=cs.skuId
-                where csps.productId=#{productId}
+                where csps.productId=#{productId} and cs.organizeId = 0
                 order by cs.price asc limit 1) ccs on ccs.productId=p.productId
                 order by cs.price asc limit 1) ccs on ccs.productId=p.productId
         where p.productID = #{productId}
         where p.productID = #{productId}
     </select>
     </select>
-    <select id="getDetailOrganizePrice" resultType="com.caimei365.commodity.model.dto.Sku">
-        SELECT skuId, minBuyNumber, price
-        FROM cm_mall_product_sku
-        WHERE productId = #{productId}
-        ORDER BY price ASC
+    <select id="getMinPrice" resultType="com.caimei365.commodity.model.vo.PriceVo">
+        select normalPrice, price
+        from cm_sku
+        where productId = #{productId} and organizeId = 0
+        order by price asc
+        limit 1
+    </select>
+    <select id="getOrganizeMinPrice" resultType="com.caimei365.commodity.model.vo.PriceVo">
+        select normalPrice, price
+        from cm_sku
+        where productId = #{productId}
+            and organizeId = 4
+        order by price asc
+        limit 1
     </select>
     </select>
     <select id="getListPriceByProductIds" resultType="com.caimei365.commodity.model.vo.PriceVo">
     <select id="getListPriceByProductIds" resultType="com.caimei365.commodity.model.vo.PriceVo">
         select
         select
@@ -53,15 +62,15 @@
         if(csp.id is not null and csp.status=0,1,0) as svipProductFlag,
         if(csp.id is not null and csp.status=0,1,0) as svipProductFlag,
         (select priceType from cm_svip_product_sku csps
         (select priceType from cm_svip_product_sku csps
         left join cm_sku cs on csps.skuId=cs.skuId
         left join cm_sku cs on csps.skuId=cs.skuId
-        where csps.productId=p.productID
+        where csps.productId=p.productID and cs.organizeId = 0
         order by cs.price asc limit 1) as svipPriceType,
         order by cs.price asc limit 1) as svipPriceType,
         (select discount from cm_svip_product_sku csps
         (select discount from cm_svip_product_sku csps
         left join cm_sku cs on csps.skuId=cs.skuId
         left join cm_sku cs on csps.skuId=cs.skuId
-        where csps.productId=p.productID
+        where csps.productId=p.productID and cs.organizeId = 0
         order by cs.price asc limit 1) as svipDiscount,
         order by cs.price asc limit 1) as svipDiscount,
         (select discountPrice from cm_svip_product_sku csps
         (select discountPrice from cm_svip_product_sku csps
         left join cm_sku cs on csps.skuId=cs.skuId
         left join cm_sku cs on csps.skuId=cs.skuId
-        where csps.productId=p.productID
+        where csps.productId=p.productID and cs.organizeId = 0
         order by cs.price asc limit 1) as svipDiscountPrice,
         order by cs.price asc limit 1) as svipDiscountPrice,
         p.productType,
         p.productType,
         p.newvalidFlag
         p.newvalidFlag
@@ -82,6 +91,7 @@
         from product_ladder_price plp
         from product_ladder_price plp
                  left join cm_sku cs on plp.skuId = cs.skuId
                  left join cm_sku cs on plp.skuId = cs.skuId
         where plp.skuId = #{skuId}
         where plp.skuId = #{skuId}
+          and cs.organizeId = 0
           and userType = 3
           and userType = 3
           and delFlag = 0
           and delFlag = 0
         order by buynum asc
         order by buynum asc
@@ -112,6 +122,7 @@
         from product_ladder_price plp
         from product_ladder_price plp
                  left join cm_sku cs on cs.skuId = plp.skuId
                  left join cm_sku cs on cs.skuId = plp.skuId
         where plp.skuId = #{skuId}
         where plp.skuId = #{skuId}
+          and cs.organizeId = 0
           and userType = 3
           and userType = 3
           and delFlag = 0
           and delFlag = 0
         order by buyprice desc
         order by buyprice desc
@@ -124,6 +135,7 @@
                  left join product p on p.productID = r.productId
                  left join product p on p.productID = r.productId
                  left join cm_sku cs on r.skuId = cs.skuId
                  left join cm_sku cs on r.skuId = cs.skuId
         where r.skuId = #{skuId}
         where r.skuId = #{skuId}
+          and cs.organizeId = 0
           and userId = #{userId}
           and userId = #{userId}
           and ((cs.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> cs.costPrice) or cs.costCheckFlag = 2)
           and ((cs.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> cs.costPrice) or cs.costCheckFlag = 2)
           and cs.price <![CDATA[ >= ]]> r.currentPrice
           and cs.price <![CDATA[ >= ]]> r.currentPrice
@@ -199,7 +211,7 @@
                costPrice,
                costPrice,
                ifnull(ladderPriceFlag, 0)                                                                           as ladderPriceFlag,
                ifnull(ladderPriceFlag, 0)                                                                           as ladderPriceFlag,
                costCheckFlag,
                costCheckFlag,
-               costProportional,
+               shopPercent as costProportional,
                ifnull(stock, 0)                                                                                     as stock,
                ifnull(stock, 0)                                                                                     as stock,
                unit,
                unit,
                ifnull(minBuyNumber, (SELECT buyNum
                ifnull(minBuyNumber, (SELECT buyNum
@@ -212,51 +224,38 @@
                csps.discount
                csps.discount
         from cm_sku cs
         from cm_sku cs
         left join cm_svip_product_sku csps on cs.skuId = csps.skuId
         left join cm_svip_product_sku csps on cs.skuId = csps.skuId
-        where cs.productId = #{productId}
+        where cs.productId = #{productId} and cs.organizeId = 0
         ORDER BY cs.price ASC
         ORDER BY cs.price ASC
     </select>
     </select>
     <select id="findOrganizeProductSkus" resultType="com.caimei365.commodity.model.dto.Sku">
     <select id="findOrganizeProductSkus" resultType="com.caimei365.commodity.model.dto.Sku">
-        SELECT cs.skuId,
-               cmps.price,
-               cs.normalPrice,
-               cs.costPrice,
-               IFNULL(cs.ladderPriceFlag, 0)                                                                           AS ladderPriceFlag,
-               cs.costCheckFlag,
-               cs.costProportional,
-               IFNULL(cs.stock, 0)                                                                                     AS stock,
-               cs.unit,
-               cmps.minBuyNumber AS minBuyNumber
-
-        FROM cm_sku cs
-                 LEFT JOIN cm_mall_product_sku cmps ON cs.skuId = cmps.skuId
-        WHERE cs.productId = #{productId} OR cmps.mallProductId = #{productId}
-        ORDER BY cs.price ASC
+        SELECT skuId,
+               price,
+               unit,
+               stock,
+               costPrice,
+               normalPrice,
+               minBuyNumber AS minBuyNumber
+        FROM cm_sku
+        WHERE  productId = #{productId} and organizeId = 4
+        ORDER BY price ASC
     </select>
     </select>
     <select id="findOrganizeSkus" resultType="com.caimei365.commodity.model.vo.MallProductSkuVo">
     <select id="findOrganizeSkus" resultType="com.caimei365.commodity.model.vo.MallProductSkuVo">
-        SELECT cmps.id,
-               cs.skuId,
-               cs.normalPrice,
-               cs.costPrice,
-               IFNULL(cs.ladderPriceFlag, 0) AS ladderPriceFlag,
-               cs.costCheckFlag,
-               cs.costProportional,
-               IFNULL(cs.stock, 0) AS stock,
-               cs.unit,
-               cmps.minBuyNumber,
-               cmps.price,
-               cmps.organizePercent,
-               cmps.shopPercent,
-               cmps.cmPercent
-        FROM cm_sku cs
-                 LEFT JOIN cm_mall_product_sku cmps ON cs.skuId = cmps.skuId
-        WHERE  cmps.productId = #{productId} OR cmps.mallProductId = #{productId}
-        ORDER BY cmps.price ASC
+        SELECT id,
+               unit,
+               minBuyNumber,
+               price,
+               organizePercent,
+               shopPercent,
+               cmPercent
+        FROM cm_sku
+        WHERE  productId = #{productId} and organizeId = 4
+        ORDER BY price ASC
     </select>
     </select>
     <select id="findLowPrice" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
     <select id="findLowPrice" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         select plp.buyPrice as price, cs.unit as unit, plp.buyNum as minBuyNumber, cs.skuId as skuId, cs.stock
         select plp.buyPrice as price, cs.unit as unit, plp.buyNum as minBuyNumber, cs.skuId as skuId, cs.stock
         from product_ladder_price plp
         from product_ladder_price plp
                  left join cm_sku cs on plp.skuId = cs.skuId
                  left join cm_sku cs on plp.skuId = cs.skuId
-        where plp.productId = #{productId}
+        where plp.productId = #{productId} and cs.organizeId = 0
         order by buynum asc
         order by buynum asc
         limit 1
         limit 1
     </select>
     </select>
@@ -264,13 +263,13 @@
         SELECT COUNT(*)
         SELECT COUNT(*)
         FROM cm_sku
         FROM cm_sku
         WHERE stock > 0
         WHERE stock > 0
-          AND productId = #{productId}
+          AND productId = #{productId} and organizeId = 0
     </select>
     </select>
     <select id="findSkusOutOfPrice" resultType="com.caimei365.commodity.model.dto.Sku">
     <select id="findSkusOutOfPrice" resultType="com.caimei365.commodity.model.dto.Sku">
         select skuId,
         select skuId,
                ifnull(ladderPriceFlag, 0)                                                                           as ladderPriceFlag,
                ifnull(ladderPriceFlag, 0)                                                                           as ladderPriceFlag,
                costCheckFlag,
                costCheckFlag,
-               costProportional,
+               shopPercent as costProportional,
                ifnull(stock, 0)                                                                                     as stock,
                ifnull(stock, 0)                                                                                     as stock,
                unit,
                unit,
                ifnull(minBuyNumber, (SELECT buyNum
                ifnull(minBuyNumber, (SELECT buyNum
@@ -279,14 +278,14 @@
                                      ORDER BY buyNum asc
                                      ORDER BY buyNum asc
                                      LIMIT 1))                                                                      AS minBuyNumber
                                      LIMIT 1))                                                                      AS minBuyNumber
         from cm_sku cs
         from cm_sku cs
-        where productId = #{productId}
+        where productId = #{productId} and organizeId = 0
         ORDER BY price ASC
         ORDER BY price ASC
     </select>
     </select>
     <select id="findLowPriceOfAll" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
     <select id="findLowPriceOfAll" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         select plp.buyPrice as price, cs.unit as unit, plp.buyNum as minBuyNumber, cs.skuId as skuId, cs.stock
         select plp.buyPrice as price, cs.unit as unit, plp.buyNum as minBuyNumber, cs.skuId as skuId, cs.stock
         from product_ladder_price plp
         from product_ladder_price plp
                  left join cm_sku cs on plp.skuId = cs.skuId
                  left join cm_sku cs on plp.skuId = cs.skuId
-        where plp.productId = #{productId}
+        where plp.productId = #{productId} and cs.organizeId = 0
         GROUP BY plp.skuId
         GROUP BY plp.skuId
         order by plp.buyPrice asc
         order by plp.buyPrice asc
         limit 1
         limit 1
@@ -295,7 +294,7 @@
         SELECT price, unit, skuId, stock,
         SELECT price, unit, skuId, stock,
         ifnull(minBuyNumber, (SELECT buyNum FROM product_ladder_price WHERE skuId = cm_sku.skuId ORDER BY buyNum asc LIMIT 1)) AS minBuyNumber
         ifnull(minBuyNumber, (SELECT buyNum FROM product_ladder_price WHERE skuId = cm_sku.skuId ORDER BY buyNum asc LIMIT 1)) AS minBuyNumber
         FROM cm_sku
         FROM cm_sku
-        WHERE productId = #{productId}
+        WHERE productId = #{productId} and organizeId = 0
         ORDER BY price ASC
         ORDER BY price ASC
         LIMIT 1
         LIMIT 1
     </select>
     </select>

+ 3 - 3
src/main/resources/mapper/PromotionsMapper.xml

@@ -87,7 +87,7 @@
         from product p
         from product p
                  left join cm_promotions_gift cpg on cpg.productId = p.productID
                  left join cm_promotions_gift cpg on cpg.productId = p.productID
         left join cm_sku cs on cpg.skuId=cs.skuId
         left join cm_sku cs on cpg.skuId=cs.skuId
-        where cpg.promotionsId = #{promotionsId}
+        where cpg.promotionsId = #{promotionsId} and cs.organizeId = 0
         order by cpg.addTime desc
         order by cpg.addTime desc
     </select>
     </select>
     <select id="getPromotionsList" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
     <select id="getPromotionsList" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
@@ -126,8 +126,8 @@
         p.productID as productId,
         p.productID as productId,
         p.`name` as `name`,
         p.`name` as `name`,
         p.mainImage as image,
         p.mainImage as image,
-        (select price from cm_sku where productID=p.productID order by price asc limit 1)as price,
-        (select unit from cm_sku where productID=p.productID order by price asc limit 1)as unit,
+        (select price from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as price,
+        (select unit from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as unit,
         p.priceFlag,
         p.priceFlag,
         IFNULL(p.visibility,3) as visibility,
         IFNULL(p.visibility,3) as visibility,
         p.productType
         p.productType

+ 23 - 24
src/main/resources/mapper/SearchMapper.xml

@@ -21,15 +21,15 @@
         t.name as p_category3_name,
         t.name as p_category3_name,
         p.preferredFlag as p_preferred,
         p.preferredFlag as p_preferred,
         p.productCategory as p_type,
         p.productCategory as p_type,
-        p.validFlag as p_valid,
+        IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 0), 999) as p_valid,
         br.weights as p_sort,
         br.weights as p_sort,
         DATE_FORMAT(p.ADDTIME,'%Y%m%d') as p_time,
         DATE_FORMAT(p.ADDTIME,'%Y%m%d') as p_time,
         IFNULL(p.visibility,3) as p_visibility,
         IFNULL(p.visibility,3) as p_visibility,
         ifnull(p.newvalidflag,0) as p_newvalidflag,
         ifnull(p.newvalidflag,0) as p_newvalidflag,
         p.productType as p_product_type,
         p.productType as p_product_type,
         p.relatedLabels as p_labels,
         p.relatedLabels as p_labels,
-        (select unit from cm_sku where productID=#{productId} order by price asc LIMIT 1) as p_unit,
-        (select price from cm_sku where productID=#{productId} order by price asc LIMIT 1) as p_price
+        (select unit from cm_sku where productID=#{productId} and organizeId = 0 order by price asc LIMIT 1) as p_unit,
+        (select price from cm_sku where productID=#{productId} and organizeId = 0 order by price asc LIMIT 1) as p_price
     </sql>
     </sql>
     <sql id="Product_Joins">
     <sql id="Product_Joins">
         left join tinytype as t on p.tinyTypeID = t.tinyTypeID
         left join tinytype as t on p.tinyTypeID = t.tinyTypeID
@@ -43,40 +43,39 @@
         <include refid="Search_Product_List"/>
         <include refid="Search_Product_List"/>
         from product p
         from product p
         <include refid="Product_Joins"/>
         <include refid="Product_Joins"/>
-        where p.validFlag in (2,3,9) and p.productCategory = 1
+        left join cm_organize_product_info copi on copi.productId = p.productId
+        where copi.validFlag in (2,3,9) and p.productCategory = 1 and copi.organizeId = 0
         and p.productID = #{productId}
         and p.productID = #{productId}
     </select>
     </select>
     <select id="findProductCount" resultType="java.lang.Integer">
     <select id="findProductCount" resultType="java.lang.Integer">
         select count(*)
         select count(*)
-        from product
-        where validFlag in (2, 3, 9)
-          and productCategory = 1
+        from product p
+                 left join cm_organize_product_info copi on copi.productId = p.productId
+        where copi.validFlag in (2, 3, 9) and copi.organizeId = 0
+          and p.productCategory = 1
     </select>
     </select>
     <select id="findProductInvalidCount" resultType="java.lang.Integer">
     <select id="findProductInvalidCount" resultType="java.lang.Integer">
         select count(*)
         select count(*)
-        from product
-        where validFlag not in (2, 3, 9)
-           or productCategory != 1
+        from product p
+                 left join cm_organize_product_info copi on copi.productId = p.productId
+        where copi.validFlag not in (2, 3, 9) and copi.organizeId = 0
+           or p.productCategory != 1
     </select>
     </select>
     <select id="findProductInvalidIds" resultType="java.lang.Integer">
     <select id="findProductInvalidIds" resultType="java.lang.Integer">
-        select productID
-        from product
-        where validFlag not in (2, 3, 9)
-           or productCategory != 1
+        select p.productID
+        from product p
+                 left join cm_organize_product_info copi on copi.productId = p.productId
+        where copi.validFlag not in (2, 3, 9) and copi.organizeId = 0
+           or p.productCategory != 1
     </select>
     </select>
     <select id="searchProductList" resultType="com.caimei365.commodity.model.search.ProductDO">
     <select id="searchProductList" resultType="com.caimei365.commodity.model.search.ProductDO">
         select
         select
         <include refid="Search_Product_List"/>
         <include refid="Search_Product_List"/>
         from product p
         from product p
         <include refid="Product_Joins"/>
         <include refid="Product_Joins"/>
-        where p.validFlag in (2,3,9) and productCategory = 1
-        order by productID desc
-    </select>
-    <select id="countMallProduct" resultType="java.lang.Integer">
-        select COUNT(*)
-        from cm_mall_organize_products
-        where productID = #{productId}
-          and organizeID = 1
+        left join cm_organize_product_info copi on copi.productId = p.productId
+        where copi.validFlag in (2,3,9) and p.productCategory = 1 and copi.organizeId = 0
+        order by p.productID desc
     </select>
     </select>
     <select id="searchMallProductByProductId" resultType="com.caimei365.commodity.model.search.MallProductDO">
     <select id="searchMallProductByProductId" resultType="com.caimei365.commodity.model.search.MallProductDO">
         select m.id           as m_id,
         select m.id           as m_id,
@@ -298,10 +297,10 @@
         p.`name` as name,
         p.`name` as name,
         p.mainImage as image,
         p.mainImage as image,
         br.name as brandName,
         br.name as brandName,
-        (select unit from cm_sku where productID=p.productID order by price asc limit 1) as unit,
+        (select unit from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1) as unit,
         p.productCode as code,
         p.productCode as code,
         p.priceFlag,
         p.priceFlag,
-        (select price from cm_sku where productID=p.productID order by price asc limit 1)as price,
+        (select price from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as price,
         p.shopID as shopId,
         p.shopID as shopId,
         p.productType,
         p.productType,
         p.searchKey as keyword
         p.searchKey as keyword

+ 5 - 3
src/main/resources/mapper/SecondHandMapper.xml

@@ -78,7 +78,7 @@
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_brand cb on cb.id = p.brandID
         left join cm_brand cb on cb.id = p.brandID
         where
         where
-        p.productCategory = 2 and p.validFlag = 2
+        p.productCategory = 2 and p.validFlag = 2 and cs.organizeId = 0
         <if test="secondHandType != null and secondHandType != ''">
         <if test="secondHandType != null and secondHandType != ''">
             and cshd.secondHandType = #{secondHandType}
             and cshd.secondHandType = #{secondHandType}
         </if>
         </if>
@@ -135,6 +135,7 @@
                  left join cm_brand cb on cb.id = p.brandID
                  left join cm_brand cb on cb.id = p.brandID
         where p.productCategory = 2
         where p.productCategory = 2
           and p.productID = #{productId}
           and p.productID = #{productId}
+          and cs.organizeId = 0
     </select>
     </select>
     <select id="getImageByProductId" resultType="java.lang.String">
     <select id="getImageByProductId" resultType="java.lang.String">
         select image
         select image
@@ -171,7 +172,7 @@
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_brand cb on cb.id = p.brandID
         left join cm_brand cb on cb.id = p.brandID
         where
         where
-        p.productCategory = 2 and p.validFlag = 2
+        p.productCategory = 2 and p.validFlag = 2 and cs.organizeId = 0
         <if test="secondHandType != null and secondHandType != ''">
         <if test="secondHandType != null and secondHandType != ''">
             and cshd.secondHandType = #{secondHandType}
             and cshd.secondHandType = #{secondHandType}
         </if>
         </if>
@@ -202,7 +203,7 @@
         left join cm_sku cs on p.productID=cs.productId
         left join cm_sku cs on p.productID=cs.productId
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_brand cb on cb.id = p.brandID
         left join cm_brand cb on cb.id = p.brandID
-        where p.productCategory = 2 and p.validFlag = 2
+        where p.productCategory = 2 and p.validFlag = 2 and cs.organizeId = 0
         <if test="secondHandType != null and secondHandType != ''">
         <if test="secondHandType != null and secondHandType != ''">
             and cshd.secondHandType = #{secondHandType}
             and cshd.secondHandType = #{secondHandType}
         </if>
         </if>
@@ -232,6 +233,7 @@
                  left join cm_second_hand_recommend cshr on p.productID = cshr.recommendProductID
                  left join cm_second_hand_recommend cshr on p.productID = cshr.recommendProductID
                  left join cm_brand cb on cb.id = p.brandID
                  left join cm_brand cb on cb.id = p.brandID
         where p.validFlag = 2
         where p.validFlag = 2
+          and cs.organizeId = 0
           and cshr.delFlag = 0
           and cshr.delFlag = 0
           and cshr.secondHandProductID = #{productId}
           and cshr.secondHandProductID = #{productId}
         order by cshr.sort desc
         order by cshr.sort desc

+ 5 - 5
src/main/resources/mapper/SellerMapper.xml

@@ -7,15 +7,15 @@
                p.name,
                p.name,
                p.aliasName,
                p.aliasName,
                p.mainImage       as image,
                p.mainImage       as image,
-               (select unit from cm_sku where productID=p.productID order by price asc limit 1)as unit,
+               (select unit from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as unit,
                p.productCode     as code,
                p.productCode     as code,
                p.priceFlag,
                p.priceFlag,
-               (select price from cm_sku where productID=p.productID order by price asc limit 1)as price,
+               (select price from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as price,
                p.shopID          as shopId,
                p.shopID          as shopId,
                p.searchKey       as keyword,
                p.searchKey       as keyword,
-               (select minBuyNumber from cm_sku where productID=p.productID order by price asc limit 1) as minBuyNumber,
-               (select ladderPriceFlag from cm_sku where productID=p.productID order by price asc limit 1) as ladderPriceFlag,
-               (select normalPrice from cm_sku where productID=p.productID order by price asc limit 1)as normalPrice,
+               (select minBuyNumber from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1) as minBuyNumber,
+               (select ladderPriceFlag from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1) as ladderPriceFlag,
+               (select normalPrice from cm_sku where productID=p.productID and organizeId = 0 order by price asc limit 1)as normalPrice,
                p.step,
                p.step,
                p.shopID          as shopId,
                p.shopID          as shopId,
                p.taxPoint        as taxRate,
                p.taxPoint        as taxRate,

+ 67 - 30
src/main/resources/mapper/ShopMapper.xml

@@ -4,7 +4,7 @@
     <insert id="insertProduct" keyColumn="productID" keyProperty="productId"
     <insert id="insertProduct" keyColumn="productID" keyProperty="productId"
             parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
             parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
         insert into product (
         insert into product (
-        shopID, name, aliasName, commodityType, bigTypeID, smallTypeID, tinyTypeID, mainImage,
+        groundMall, shopID, name, aliasName, commodityType, bigTypeID, smallTypeID, tinyTypeID, mainImage,
         brandID, productType, tags, includedTax,
         brandID, productType, tags, includedTax,
         <if test="productCategory != null and  productCategory != '' ">
         <if test="productCategory != null and  productCategory != '' ">
             productCategory,
             productCategory,
@@ -80,7 +80,7 @@
         </if>
         </if>
         updateTime,validFlag,newProductType,showFlag,newvalidFlag
         updateTime,validFlag,newProductType,showFlag,newvalidFlag
         ) values (
         ) values (
-        #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
+        #{groundMall}, #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
         #{brandId}, #{productType}, #{tags}, #{includedTax},
         #{brandId}, #{productType}, #{tags}, #{includedTax},
         <if test="productCategory != null and  productCategory != '' ">
         <if test="productCategory != null and  productCategory != '' ">
             #{productCategory},
             #{productCategory},
@@ -159,7 +159,7 @@
     </insert>
     </insert>
     <update id="updateProduct">
     <update id="updateProduct">
         update product set
         update product set
-        shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
+        groundMall = #{groundMall}, shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
         bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
         bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
         brandId = #{brandId}, productType = #{productType}, tags = #{tags}, includedTax = #{includedTax},newProductType=#{newProductType},
         brandId = #{brandId}, productType = #{productType}, tags = #{tags}, includedTax = #{includedTax},newProductType=#{newProductType},
         <if test="qualificationNo !=null and qualificationNo != ''">
         <if test="qualificationNo !=null and qualificationNo != ''">
@@ -245,6 +245,15 @@
         showFlag=#{showFlag}
         showFlag=#{showFlag}
         where productID = #{productId}
         where productID = #{productId}
     </update>
     </update>
+    <insert id="insertVaildFlag">
+        insert into cm_organize_product_info (organizeId, productId, validFlag)
+        values (#{organizeId},#{productId},#{validFlag})
+    </insert>
+    <update id="updateVaildFlag">
+        update cm_organize_product_info
+        set validFlag = #{validFlag}
+        where productId = #{productId} and organizeId = #{organizeId}
+    </update>
     <insert id="insertProductImage">
     <insert id="insertProductImage">
         insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
         insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
         values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
         values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
@@ -270,6 +279,7 @@
     <insert id="insertSku">
     <insert id="insertSku">
         insert into cm_sku
         insert into cm_sku
         (productId,
         (productId,
+         organizeId,
          normalPrice,
          normalPrice,
          price,
          price,
          costCheckFlag,
          costCheckFlag,
@@ -277,8 +287,12 @@
          stock,
          stock,
          minBuyNumber,
          minBuyNumber,
          unit,
          unit,
-         ladderPriceFlag)
+         ladderPriceFlag,
+         shopPercent,
+         organizePercent,
+         cmPercent)
         values (#{productId},
         values (#{productId},
+                #{organizeId},
                 #{normalPrice},
                 #{normalPrice},
                 #{price},
                 #{price},
                 ifnull(#{costCheckFlag}, 1),
                 ifnull(#{costCheckFlag}, 1),
@@ -286,7 +300,14 @@
                 #{stock},
                 #{stock},
                 #{minBuyNumber},
                 #{minBuyNumber},
                 #{unit},
                 #{unit},
-                ifnull(#{ladderPriceFlag}, 0))
+                ifnull(#{ladderPriceFlag}, 0),
+                #{shopPercent},
+                #{organizePercent},
+                #{cmPercent})
+    </insert>
+    <insert id="insertProductInfo">
+        insert into cm_organize_product_info (organizeId, productId, validFlag)
+        values (#{organizeId}, #{productId}, #{validFlag})
     </insert>
     </insert>
     <update id="updateBrand">
     <update id="updateBrand">
         update cm_brand
         update cm_brand
@@ -348,9 +369,17 @@
           and shopID = #{shopId}
           and shopID = #{shopId}
     </update>
     </update>
     <update id="updateProductValidFlag">
     <update id="updateProductValidFlag">
-        update product
+        update cm_organize_product_info
         set validFlag = #{validFlag}
         set validFlag = #{validFlag}
-        where productID = #{productId}
+        where productId = #{productId}
+        <if test="organizeId != 0">
+            <if test="organizeId == 1">
+                and organizeId = 0
+            </if>
+            <if test="organizeId == 2">
+                and organizeId = 4
+            </if>
+        </if>
     </update>
     </update>
     <update id="updateProductCode">
     <update id="updateProductCode">
         update product
         update product
@@ -384,8 +413,8 @@
         p.shopID as shopId,
         p.shopID as shopId,
         p.`name` as `name`,
         p.`name` as `name`,
         p.mainImage as image,
         p.mainImage as image,
-        (select price from cm_sku where productId=p.productID order by price asc limit 1) as price,
-        (select unit from cm_sku where productId=p.productID order by price asc limit 1) as unit,
+        (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as price,
+        (select unit from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as unit,
         p.priceFlag as priceFlag,
         p.priceFlag as priceFlag,
         IFNULL(p.visibility,3) as visibility,
         IFNULL(p.visibility,3) as visibility,
         p.productType
         p.productType
@@ -405,36 +434,39 @@
         p.name,
         p.name,
         p.aliasName,
         p.aliasName,
         p.mainImage as image,
         p.mainImage as image,
-        (select unit from cm_sku where productId=p.productId order by price asc LIMIT 1) as unit,
+        (select unit from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as unit,
         p.productCode as code,
         p.productCode as code,
         p.priceFlag,
         p.priceFlag,
-        (select price from cm_sku where productId=p.productId order by price asc LIMIT 1) as price,
-        (select normalPrice from cm_sku where productId=p.productId order by price asc LIMIT 1) as normalPrice,
+        (select price from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as price,
+        (select normalPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as normalPrice,
         p.searchKey as keyword,
         p.searchKey as keyword,
-        (select minBuyNumber from cm_sku where productId=p.productId order by price asc LIMIT 1) as minBuyNumber,
-        (select ladderPriceFlag from cm_sku where productId=p.productId order by price asc LIMIT 1) as ladderPriceFlag,
+        (select minBuyNumber from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as minBuyNumber,
+        (select ladderPriceFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as ladderPriceFlag,
         p.step,
         p.step,
         p.shopID as shopId,
         p.shopID as shopId,
         p.taxPoint as taxRate,
         p.taxPoint as taxRate,
         p.includedTax,
         p.includedTax,
         p.invoiceType,
         p.invoiceType,
         p.productCategory as productCategory,
         p.productCategory as productCategory,
-        p.validFlag,
+        IFNULL((SELECT validFlag FROM cm_organize_product_info	WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
+        IFNULL((SELECT validFlag FROM cm_organize_product_info	WHERE productId = p.productID AND organizeId = 4), 999) AS mallValidFlag,
         p.featuredFlag,
         p.featuredFlag,
         p.commodityType,
         p.commodityType,
         p.bigTypeID as bigTypeId,
         p.bigTypeID as bigTypeId,
         p.smallTypeID as smallTypeId,
         p.smallTypeID as smallTypeId,
         p.tinyTypeID as tinyTypeId,
         p.tinyTypeID as tinyTypeId,
         ifnull(p.newvalidFlag,3) as newvalidFlag,
         ifnull(p.newvalidFlag,3) as newvalidFlag,
-        ifnull(p.showFlag,0) as showFlag
+        ifnull(p.showFlag,0) as showFlag,
+        p.groundMall AS groundMall
         from product p
         from product p
+        LEFT JOIN cm_organize_product_info copi ON copi.productId = p.productID
         <where>
         <where>
             p.shopID = #{shopId}
             p.shopID = #{shopId}
             <if test="productCode != null and productCode != ''">
             <if test="productCode != null and productCode != ''">
                 and p.productCode = #{productCode}
                 and p.productCode = #{productCode}
             </if>
             </if>
             <if test="validFlag != null and validFlag != ''">
             <if test="validFlag != null and validFlag != ''">
-                and p.validFlag = #{validFlag}
+                and copi.validFlag = #{validFlag}
             </if>
             </if>
             <if test="featuredFlag != null and featuredFlag != ''">
             <if test="featuredFlag != null and featuredFlag != ''">
                 and p.featuredFlag = #{featuredFlag}
                 and p.featuredFlag = #{featuredFlag}
@@ -454,6 +486,9 @@
             <if test="name != null and name != ''">
             <if test="name != null and name != ''">
                 and p.name like CONCAT("%",#{name},"%")
                 and p.name like CONCAT("%",#{name},"%")
             </if>
             </if>
+            <if test="groundMall != null and groundMall != ''">
+                and p.groundMall like concat('%',#{groundMall},'%')
+            </if>
             <if test="newvalidFlag !=null and newvalidFlag!=''">
             <if test="newvalidFlag !=null and newvalidFlag!=''">
                 and newvalidFlag =#{newvalidFlag}
                 and newvalidFlag =#{newvalidFlag}
             </if>
             </if>
@@ -509,12 +544,13 @@
     </select>
     </select>
     <select id="getProductForm" resultType="com.caimei365.commodity.model.vo.ProductFormVo">
     <select id="getProductForm" resultType="com.caimei365.commodity.model.vo.ProductFormVo">
         select productID                 as productId,
         select productID                 as productId,
+               groundMall,
                shopID                    as shopId,
                shopID                    as shopId,
                name,
                name,
                aliasName,
                aliasName,
                commodityType,
                commodityType,
                mainImage,
                mainImage,
-               (select stock from cm_sku where productId=p.productId order by price asc LIMIT 1) as stock,
+               (select stock from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as stock,
                invoiceType,
                invoiceType,
                bigTypeID                 as bigTypeId,
                bigTypeID                 as bigTypeId,
                smallTypeID               as smallTypeId,
                smallTypeID               as smallTypeId,
@@ -524,32 +560,33 @@
                brandID                   as brandId,
                brandID                   as brandId,
                productType,
                productType,
                tags,
                tags,
-               (select unit from cm_sku where productId=p.productId order by price asc LIMIT 1)as unit,
-               (select normalPrice from cm_sku where productId=p.productId order by price asc LIMIT 1)as normalPrice,
-               (select price from cm_sku where productId=p.productId order by price asc LIMIT 1)as price,
+               (select unit from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as unit,
+               (select normalPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as normalPrice,
+               (select price from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as price,
                includedTax,
                includedTax,
-               (select minBuyNumber from cm_sku where productId=p.productId order by price asc LIMIT 1)as minBuyNumber,
+               (select minBuyNumber from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as minBuyNumber,
                productCategory,
                productCategory,
                serviceNumber,
                serviceNumber,
                supplierTaxPoint,
                supplierTaxPoint,
                priceFlag,
                priceFlag,
                actFlag,
                actFlag,
-               (select ladderPriceFlag from cm_sku where productId=p.productId order by price asc LIMIT 1) as ladderPriceFlag,
+               (select ladderPriceFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as ladderPriceFlag,
                addTime,
                addTime,
                hasSkuFlag,
                hasSkuFlag,
                sellNumber,
                sellNumber,
                sortIndex,
                sortIndex,
                featuredFlag,
                featuredFlag,
-               (select costCheckFlag from cm_sku where productId=p.productId order by price asc LIMIT 1)as costCheckFlag,
+               (select costCheckFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costCheckFlag,
                recommendType,
                recommendType,
                machineType,
                machineType,
                productCode,
                productCode,
                updateTime,
                updateTime,
-               validFlag,
+               IFNULL((SELECT validFlag FROM cm_organize_product_info	WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
+               IFNULL((SELECT validFlag FROM cm_organize_product_info	WHERE productId = p.productID AND organizeId = 4), 999) AS mallValidFlag,
                searchKey,
                searchKey,
                allAreaFlag,
                allAreaFlag,
                step,
                step,
-               (select costPrice from cm_sku where productId=p.productId order by price asc LIMIT 1)as costPrice,
+               (select costPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costPrice,
                provinceIds,
                provinceIds,
                qualificationImg,
                qualificationImg,
                trainingMethod,
                trainingMethod,
@@ -581,8 +618,8 @@
         UNION
         UNION
         SELECT p.productImageID AS id, p.productID AS productId, p.shopId, p.ADDTIME, p.image, p.mainFlag, p.sortIndex
         SELECT p.productImageID AS id, p.productID AS productId, p.shopId, p.ADDTIME, p.image, p.mainFlag, p.sortIndex
         FROM productimage p
         FROM productimage p
-        LEFT JOIN cm_mall_organize_products cmop ON p.productId = cmop.productId
-        WHERE cmop.id = #{productId}
+        LEFT JOIN product pt ON p.productId = pt.productId
+        WHERE pt.productId = #{productId}
         order by mainFlag desc
         order by mainFlag desc
     </select>
     </select>
     <select id="getProductDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
     <select id="getProductDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
@@ -615,8 +652,8 @@
                          p.seoKeyword,
                          p.seoKeyword,
                          p.seoDes
                          p.seoDes
         FROM productdetailinfo p
         FROM productdetailinfo p
-                 LEFT JOIN cm_mall_organize_products cmop ON cmop.productId = p.productId
-        WHERE p.productId = #{product} OR cmop.id = #{product}
+                 LEFT JOIN product pt ON pt.productId = p.productId
+        WHERE p.productId = #{productId}
     </select>
     </select>
     <select id="getProductShopById" resultType="com.caimei365.commodity.model.vo.ShopVo">
     <select id="getProductShopById" resultType="com.caimei365.commodity.model.vo.ShopVo">
         select userID                     as userId,
         select userID                     as userId,

+ 4 - 2
src/main/resources/mapper/UserLikeMapper.xml

@@ -47,7 +47,7 @@
                p.includedTax,
                p.includedTax,
                p.invoiceType,
                p.invoiceType,
                p.productCategory AS productCategory,
                p.productCategory AS productCategory,
-               p.validFlag,
+               copi.validFlag,
                p.featuredFlag,
                p.featuredFlag,
                p.commodityType,
                p.commodityType,
                p.bigTypeID       AS bigTypeId,
                p.bigTypeID       AS bigTypeId,
@@ -57,7 +57,9 @@
                p.productType
                p.productType
         FROM product p
         FROM product p
         LEFT JOIN cm_product_userlike cpu ON p.productID = cpu.productID
         LEFT JOIN cm_product_userlike cpu ON p.productID = cpu.productID
-        WHERE p.validFlag = '2'
+        left join cm_organize_product_info copi on copi.productId = p.productId
+        WHERE copi.validFlag = '2'
+          and copi.organizeId = 0
           AND cpu.userLike = '1'
           AND cpu.userLike = '1'
           AND cpu.userID = #{userId}
           AND cpu.userID = #{userId}
         ORDER BY cpu.likeTime DESC
         ORDER BY cpu.likeTime DESC