Browse Source

sku相关

zhijiezhao 2 years ago
parent
commit
f3f9e18200
25 changed files with 843 additions and 886 deletions
  1. 116 94
      src/main/java/com/caimei365/commodity/components/PriceUtilService.java
  2. 36 32
      src/main/java/com/caimei365/commodity/controller/ProductShopApi.java
  3. 20 10
      src/main/java/com/caimei365/commodity/mapper/PriceMapper.java
  4. 4 0
      src/main/java/com/caimei365/commodity/mapper/ShopMapper.java
  5. 6 31
      src/main/java/com/caimei365/commodity/model/dto/ProductDto.java
  6. 91 0
      src/main/java/com/caimei365/commodity/model/dto/Sku.java
  7. 7 24
      src/main/java/com/caimei365/commodity/model/po/ProductPo.java
  8. 3 0
      src/main/java/com/caimei365/commodity/model/vo/LadderPriceVo.java
  9. 4 40
      src/main/java/com/caimei365/commodity/model/vo/PriceVo.java
  10. 14 29
      src/main/java/com/caimei365/commodity/model/vo/ProductDetailVo.java
  11. 14 6
      src/main/java/com/caimei365/commodity/model/vo/ProductFormVo.java
  12. 33 116
      src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java
  13. 10 0
      src/main/java/com/caimei365/commodity/model/vo/UserLikeProductVo.java
  14. 26 63
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  15. 0 10
      src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java
  16. 15 8
      src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java
  17. 72 101
      src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java
  18. 9 15
      src/main/resources/mapper/PageMapper.xml
  19. 115 83
      src/main/resources/mapper/PriceMapper.xml
  20. 1 0
      src/main/resources/mapper/PromotionsMapper.xml
  21. 30 17
      src/main/resources/mapper/SearchMapper.xml
  22. 158 140
      src/main/resources/mapper/SecondHandMapper.xml
  23. 0 11
      src/main/resources/mapper/SellerMapper.xml
  24. 58 50
      src/main/resources/mapper/ShopMapper.xml
  25. 1 6
      src/main/resources/mapper/UserLikeMapper.xml

+ 116 - 94
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -3,6 +3,7 @@ package com.caimei365.commodity.components;
 
 import com.caimei365.commodity.mapper.PriceMapper;
 import com.caimei365.commodity.mapper.PromotionsMapper;
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.utils.ImageUtils;
 import com.caimei365.commodity.utils.MathUtil;
@@ -13,7 +14,10 @@ import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.util.Comparator;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
 /**
@@ -88,14 +92,18 @@ public class PriceUtilService {
     public void setPriceByUserId(PriceVo price, Integer userId) {
         // 根据用户Id查询用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构
         Integer identity = priceMapper.getIdentityByUserId(userId);
-        if (null == identity) {identity = 0;}
+        if (null == identity) {
+            identity = 0;
+        }
         // priceFlag: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
         Integer priceFlag = null != price.getPriceFlag() ? price.getPriceFlag() : 0;
         // 会员机构类型:1医美,2生美
         Integer clubType = 0;
         if (identity == 2) {
             clubType = priceMapper.getClubTypeById(userId);
-            if (null == clubType) {clubType = 0;}
+            if (null == clubType) {
+                clubType = 0;
+            }
         }
         // 根据用户Id查询超级会员id
         Integer svipUserId = priceMapper.getSvipUserIdByUserId(userId);
@@ -103,102 +111,105 @@ public class PriceUtilService {
         boolean isSuperVip = null != svipUserId;
         // 根据商品id,用户身份 查询商品活动
         PromotionsVo promotions = promotionsMapper.getPricePromotions(price.getProductId(), identity);
-        price.setRepurchaseFlag(0);
         price.setActStatus(0);
         // 用户身份: 2-会员机构, 4-普通机构
         price.setUserIdentity(identity);
         //是否是供应商自己的商品
         boolean isShopOwn = false;
-        if (identity == 3){
+        if (identity == 3) {
             // 根据用户Id查询供应商Id
             Integer shopId = priceMapper.getShopIdByUserId(userId);
-            if (null != shopId && shopId.equals(price.getShopId())){
+            if (null != shopId && shopId.equals(price.getShopId())) {
                 isShopOwn = true;
             }
         }
         // 设置价格标志(协销|价格公开|仅对医美机构公开|仅对会员机构公开|供应商自己的商品)
         boolean setFlag = identity == 1 || priceFlag == 0 || (priceFlag == 3 && clubType == 1) || (priceFlag == 2 && (identity == 2 || isSuperVip)) || isShopOwn;
         if (setFlag) {
-            // 设置划线价
-            price.setOriginalPrice(price.getPrice());
-            //税费标志
-            boolean taxFlag = "0".equals(price.getIncludedTax()) && ("1".equals(price.getInvoiceType()) || "2".equals(price.getInvoiceType()));
-            if (1 == price.getSvipProductFlag()) {
-                // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
-                price.setLadderPriceFlag(0);
-                // 超级会员优惠价
-                BigDecimal svipDiscountPrice = price.getSvipDiscountPrice();
-                if (1 == price.getSvipPriceType()) {
-                    // 折扣价
-                    price.setSvipPriceTag(MathUtil.div(price.getSvipDiscount(), 10, 1) + "折");
-                    if (isSuperVip) {
-                        // 超级会员用户设置优惠价
-                        svipDiscountPrice = MathUtil.div(MathUtil.mul(price.getPrice(), price.getSvipDiscount()), 100, 2);
-                        price.setPrice(svipDiscountPrice.doubleValue());
+            List<Sku> skus = price.getSkus();
+            if (null == skus || skus.size() < 1) {
+                List<Sku> skuList = priceMapper.findSkus(price.getProductId());
+                price.setSkus(skuList);
+                skus = skuList;
+            }
+            skus.forEach(s -> {
+                // 设置划线价
+                s.setOriginalPrice(s.getPrice());
+                //税费标志
+                boolean taxFlag = "0".equals(price.getIncludedTax()) && ("1".equals(price.getInvoiceType()) || "2".equals(price.getInvoiceType()));
+                if (1 == price.getSvipProductFlag()) {
+                    // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
+                    s.setLadderPriceFlag(0);
+                    // 超级会员优惠价
+                    BigDecimal svipDiscountPrice = price.getSvipDiscountPrice();
+                    if (1 == price.getSvipPriceType()) {
+                        // 折扣价
+                        price.setSvipPriceTag(MathUtil.div(price.getSvipDiscount(), 10, 1) + "折");
+                        if (isSuperVip) {
+                            // 超级会员用户设置优惠价
+                            svipDiscountPrice = MathUtil.div(MathUtil.mul(s.getPrice(), price.getSvipDiscount()), 100, 2);
+                            s.setPrice(svipDiscountPrice.doubleValue());
+                        }
+                    } else if (2 == price.getSvipPriceType()) {
+                        // 直接优惠价
+                        if (isSuperVip) {
+                            // 超级会员用户设置优惠价
+                            s.setPrice(svipDiscountPrice.doubleValue());
+                        }
+                        if (taxFlag) {
+                            //添加税费
+                            BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(svipDiscountPrice, price.getTaxRate()), 100, 2);
+                            svipDiscountPrice = MathUtil.add(svipDiscountPrice, thisTaxFee);
+                        }
+                        price.setSvipPriceTag("¥" + svipDiscountPrice);
                     }
-                } else if (2 == price.getSvipPriceType()) {
-                    // 直接优惠价
-                    if (isSuperVip) {
-                        // 超级会员用户设置优惠价
-                        price.setPrice(svipDiscountPrice.doubleValue());
+                } else if (null != promotions) {
+                    // 促销活动
+                    price.setActStatus(1);
+                    s.setLadderPriceFlag(0);
+                    if (promotions.getMode() == 3) {
+                        // 获取赠品
+                        List<ProductItemVo> giftList = promotionsMapper.getPromotionGifts(promotions.getId());
+                        promotions.setGiftList(giftList);
                     }
-                    if (taxFlag) {
-                        //添加税费
-                        BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(svipDiscountPrice, price.getTaxRate()), 100, 2);
-                        svipDiscountPrice = MathUtil.add(svipDiscountPrice, thisTaxFee);
+                    if (promotions.getType() == 1 && promotions.getMode() == 1 && null != promotions.getTouchPrice()) {
+                        s.setPrice(promotions.getTouchPrice());
                     }
-                    price.setSvipPriceTag("¥" + svipDiscountPrice);
-                }
-            } else if (null != promotions) {
-                // 促销活动
-                price.setActStatus(1);
-                price.setLadderPriceFlag(0);
-                if (promotions.getMode() == 3) {
-                    // 获取赠品
-                    List<ProductItemVo> giftList = promotionsMapper.getPromotionGifts(promotions.getId());
-                    promotions.setGiftList(giftList);
-                }
-                if (promotions.getType() == 1 && promotions.getMode() == 1 && null != promotions.getTouchPrice()) {
-                    price.setPrice(promotions.getTouchPrice());
-                }
-                price.setPromotions(promotions);
-            } else {
-                if (null != userId) {
-                    if (1 == price.getLadderPriceFlag()) {
-                        // 阶梯价
-                        LadderPriceVo lowerPrice = priceMapper.findLowerLadderPrice(price.getProductId());
-                        LadderPriceVo lowerBuyNum = priceMapper.findMaxLadderPrice(price.getProductId());
-                        if (null != lowerPrice) {
-                            price.setMaxBuyNumber(lowerPrice.getBuyNum());
-                            if (null != lowerBuyNum) {
-                                price.setMinBuyNumber(lowerBuyNum.getBuyNum());
-                                price.setPrice(lowerBuyNum.getBuyPrice());
+                    price.setPromotions(promotions);
+                } else {
+                    if (null != userId) {
+                        if (1 == s.getLadderPriceFlag()) {
+                            // 阶梯价
+                            LadderPriceVo lowerPrice = priceMapper.findLowerLadderPrice(s.getSkuId());
+                            LadderPriceVo lowerBuyNum = priceMapper.findMaxLadderPrice(s.getSkuId());
+                            if (null != lowerPrice) {
+                                if (null != lowerBuyNum) {
+                                    s.setMinBuyNumber(lowerBuyNum.getBuyNum());
+                                    s.setPrice(lowerBuyNum.getBuyPrice());
+                                }
+                            } else {
+                                s.setLadderPriceFlag(0);
                             }
                         } else {
-                            price.setLadderPriceFlag(0);
-                        }
-                    } else {
-                        // 复购价
-                        Double repurchase = priceMapper.getRepurchasePrice(price.getProductId(), userId);
-                        if (null != repurchase && repurchase > 0) {
-                            price.setPrice(repurchase);
-                            price.setRepurchaseFlag(1);
-                            price.setLadderPriceFlag(0);
+                            // 复购价
+                            Double repurchase = priceMapper.getRepurchasePrice(s.getSkuId(), userId);
+                            if (null != repurchase && repurchase > 0) {
+                                s.setPrice(repurchase);
+                                s.setRepurchaseFlag(1);
+                                s.setLadderPriceFlag(0);
+                            }
                         }
                     }
                 }
-            }
-            //添加税费
-            if (taxFlag) {
-                BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(price.getPrice(), price.getTaxRate()), 100, 2);
-                price.setPrice(MathUtil.add(price.getPrice(), thisTaxFee).doubleValue());
-                BigDecimal originalTaxFee = MathUtil.div(MathUtil.mul(price.getOriginalPrice(), price.getTaxRate()), 100, 2);
-                price.setOriginalPrice(MathUtil.add(price.getOriginalPrice(), originalTaxFee).doubleValue());
-            }
+                //添加税费
+                if (taxFlag) {
+                    BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(s.getPrice(), price.getTaxRate()), 100, 2);
+                    s.setPrice(MathUtil.add(s.getPrice(), thisTaxFee).doubleValue());
+                    BigDecimal originalTaxFee = MathUtil.div(MathUtil.mul(s.getOriginalPrice(), price.getTaxRate()), 100, 2);
+                    s.setOriginalPrice(MathUtil.add(s.getOriginalPrice(), originalTaxFee).doubleValue());
+                }
+            });
         } else {
-            price.setPrice(0d);
-            price.setOriginalPrice(0d);
-            price.setNormalPrice(0d);
             price.setUserIdentity(0);
             if (null != promotions) {
                 price.setActStatus(1);
@@ -210,9 +221,6 @@ public class PriceUtilService {
                 price.setActStatus(0);
             }
         }
-        // 屏蔽成本价
-        price.setCostProportional(0d);
-        price.setCostPrice(0d);
     }
 
     /**
@@ -224,31 +232,45 @@ public class PriceUtilService {
     public void setProductDetails(Integer userId, ProductItemVo product) {
         // 设置图片
         product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
-        // 设置价格等级
-        product.setPriceGrade(getPriceGrade(product.getPrice()));
+        // 设置sku
+        List<Sku> skus = priceMapper.findSkus(product.getProductId());
+        AtomicBoolean lowPrice = new AtomicBoolean(false);
+        skus.forEach(s -> {
+            // 设置价格等级
+            s.setPriceGrade(getPriceGrade(s.getPrice()));
+            s.setOriginalPrice(s.getPrice());
+            if (1 == s.getLadderPriceFlag()) {
+                List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(s.getSkuId());
+                TaxVo tax = priceMapper.getTaxByProductId(product.getProductId());
+                if (!CollectionUtils.isEmpty(ladderPrices)) {
+                    setLadderPriceList(ladderPrices, tax);
+                }
+                s.setLadderPriceList(ladderPrices);
+                lowPrice.set(true);
+            }
+        });
+        //设置展示的默认最低价和展示最低价的规格
+        if (lowPrice.get()) {
+            ProductItemVo showProduct = priceMapper.findLowPrice(product.getProductId());
+            product.setPrice(showProduct.getPrice());
+            product.setUnit(showProduct.getUnit());
+        } else {
+            List<Sku> collect = skus.stream().sorted(Comparator.comparing(Sku::getPrice)).collect(Collectors.toList());
+            product.setPrice(collect.get(0).getPrice());
+            product.setUnit(collect.get(0).getUnit());
+        }
+        product.setSkus(skus);
         // 数据库获取基本价格信息
         PriceVo price = priceMapper.getDetailPrice(product.getProductId());
+        price.setSkus(skus);
         // 根据用户id设置详细价格
         setPriceByUserId(price, userId);
         // 设置价格
         product.setActStatus(price.getActStatus());
-        product.setPrice(price.getPrice());
-        product.setOriginalPrice(price.getOriginalPrice());
-        product.setNormalPrice(price.getNormalPrice());
-        product.setLadderPriceFlag(price.getLadderPriceFlag());
         product.setPromotions(price.getPromotions());
-        product.setMinBuyNumber(price.getMinBuyNumber());
         product.setUserIdentity(price.getUserIdentity());
-        product.setRepurchaseFlag(price.getRepurchaseFlag());
-        product.setMaxBuyNumber(price.getMaxBuyNumber());
         product.setSvipProductFlag(price.getSvipProductFlag());
         product.setSvipPriceTag(price.getSvipPriceTag());
-        List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(product.getProductId());
-        TaxVo tax = priceMapper.getTaxByProductId(product.getProductId());
-        if (!CollectionUtils.isEmpty(ladderPrices)) {
-            setLadderPriceList(ladderPrices, tax);
-        }
-        product.setLadderPrices(ladderPrices);
     }
 
 }

+ 36 - 32
src/main/java/com/caimei365/commodity/controller/ProductShopApi.java

@@ -24,7 +24,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/4/16
  */
-@Api(tags="供应商商品API")
+@Api(tags = "供应商商品API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity/shop")
@@ -36,8 +36,8 @@ public class ProductShopApi {
      */
     @ApiOperation("供应商-主推商品(旧:/supplier/home/products)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id(旧:supplierId)"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份:1协销,2会员机构,3供应商,4普通机构,5医美机构")
+            @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id(旧:supplierId)"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份:1协销,2会员机构,3供应商,4普通机构,5医美机构")
     })
     @GetMapping("/product/main")
     public ResponseJson<List<ProductListVo>> getSupplierMainProducts(Integer shopId, @RequestParam(value = "identity", defaultValue = "0") Integer identity) {
@@ -49,25 +49,25 @@ public class ProductShopApi {
      */
     @ApiOperation("供应商-我的商品(旧:/supplier/myProduct)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id"),
-        @ApiImplicitParam(required = false, name = "name", value = "商品名称"),
+            @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id"),
+            @ApiImplicitParam(required = false, name = "name", value = "商品名称"),
             @ApiImplicitParam(required = false, name = "newvalidFlag", value = "新品商品状态  0.参与 , 1.审核通过, 2.未参与 ,3.审核未通过,4.时间过期"),
-        @ApiImplicitParam(required = false, name = "productCode", value = "货号"),
-        @ApiImplicitParam(required = false, name = "validFlag", value = "状态:0逻辑删除,1待审核,2已上架,3已下架,8审核未通过,9已隐身,10已冻结"),
-        @ApiImplicitParam(required = false, name = "featuredFlag", value = "是否主推:0否,1是"),
-        @ApiImplicitParam(required = false, name = "commodityType", value = "商品属性:1产品,2仪器"),
-        @ApiImplicitParam(required = false, name = "bigTypeId", value = "一级分类Id"),
-        @ApiImplicitParam(required = false, name = "smallTypeId", value = "二级分类Id"),
-        @ApiImplicitParam(required = false, name = "tinyTypeId", value = "三级级分类Id"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "productCode", value = "货号"),
+            @ApiImplicitParam(required = false, name = "validFlag", value = "状态:0逻辑删除,1待审核,2已上架,3已下架,8审核未通过,9已隐身,10已冻结"),
+            @ApiImplicitParam(required = false, name = "featuredFlag", value = "是否主推:0否,1是"),
+            @ApiImplicitParam(required = false, name = "commodityType", value = "商品属性:1产品,2仪器"),
+            @ApiImplicitParam(required = false, name = "bigTypeId", value = "一级分类Id"),
+            @ApiImplicitParam(required = false, name = "smallTypeId", value = "二级分类Id"),
+            @ApiImplicitParam(required = false, name = "tinyTypeId", value = "三级级分类Id"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/product/list")
-    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,
+    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,
                                                              @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                              @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, newvalidFlag, pageNum, pageSize);
     }
 
     /**
@@ -80,16 +80,12 @@ public class ProductShopApi {
      *                   brandId	    品牌id
      *                   brandName	    品牌名称
      *                   commodityType	商品属性:1产品,2仪器
-     *                   costPrice	    成本价
      *                   detailInfo	    商品详情信息
      *                   includedTax	是否含税:0不含税,1含税,2未知
      *                   invoiceType	发票类型
      *                   machineType	械字号类型
-     *                   minBuyNumber	最小购买量
      *                   name	        商品名称
-     *                   normalPrice	市场价
      *                   orderInfo	    订购方案
-     *                   price	        机构价格
      *                   productCode	商品货号
      *                   productType	商品类型:0其它,1妆字号,2械字号
      *                   provinceIds	指定的销售区域
@@ -99,16 +95,24 @@ public class ProductShopApi {
      *                   shopId	         供应商id
      *                   smallTypeId	 二级分类id
      *                   step	         购买数量
-     *                   stock	         库存
      *                   tags	         商品标签,逗号隔开
      *                   taxPoint	     开票税点
      *                   tinyTypeId	     三级分类id
-     *                   unit	         包装规格
+     *
+     *                   skus[
+     *                     {id              skuId
+     *                      minBuyNumber	最小购买量
+     *                      costPrice	    成本价
+     *                      stock	        库存
+     *                      price	        机构价格
+     *                      normalPrice	    市场价
+     *                      unit            包装规格},{sku}
+     *                      ]
      *                   }
      */
     @ApiOperation("供应商-发布商品(旧:/supplier/releaseProduct)")
     @PostMapping("/product/release")
-    public ResponseJson releaseProduct(ProductDto productDto){
+    public ResponseJson releaseProduct(ProductDto productDto) {
         return shopService.releaseProduct(productDto);
     }
 
@@ -129,8 +133,8 @@ public class ProductShopApi {
      */
     @ApiOperation("供应商-商品编辑-品牌联想(旧:/supplier/brandAssociation)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
-        @ApiImplicitParam(required = true, name = "name", value = "关键词")
+            @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = true, name = "name", value = "关键词")
     })
     @GetMapping("/brand/select")
     public ResponseJson<List<BrandVo>> brandAssociation(Integer userId, String name) {
@@ -156,7 +160,7 @@ public class ProductShopApi {
      *                 userId      添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
      *                 logo        品牌logo
      *                 description 品牌描述
-     * }
+     *                 }
      */
     @ApiOperation("供应商-提交新品牌(旧:/supplier/addBrand)")
     @PostMapping("/brand/add")
@@ -169,11 +173,11 @@ public class ProductShopApi {
      */
     @ApiOperation("供应商-品牌管理(旧:/supplier/brandManagement)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "name", value = "品牌名称"),
-        @ApiImplicitParam(required = false, name = "status", value = "品牌状态 0:待审核,1:审核通过,2:审核失败"),
-        @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "name", value = "品牌名称"),
+            @ApiImplicitParam(required = false, name = "status", value = "品牌状态 0:待审核,1:审核通过,2:审核失败"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/brand/list")
     public ResponseJson<PaginationVo<BrandVo>> brandManagement(String name, Integer status, Integer userId,

+ 20 - 10
src/main/java/com/caimei365/commodity/mapper/PriceMapper.java

@@ -1,9 +1,7 @@
 package com.caimei365.commodity.mapper;
 
-import com.caimei365.commodity.model.vo.ProductSalesVo;
-import com.caimei365.commodity.model.vo.LadderPriceVo;
-import com.caimei365.commodity.model.vo.PriceVo;
-import com.caimei365.commodity.model.vo.TaxVo;
+import com.caimei365.commodity.model.dto.Sku;
+import com.caimei365.commodity.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -30,21 +28,21 @@ public interface PriceMapper {
      */
     List<PriceVo> getListPriceByProductIds(@Param("productIds") List<Integer> productIds);
     /**
-     * 根据商品ID查询阶梯价列表
+     * 根据skuId查询阶梯价列表
      */
-    List<LadderPriceVo> getLadderPricesByProductId(Integer productId);
+    List<LadderPriceVo> getLadderPricesByProductId(Integer skuId);
     /**
      * 获取最低阶梯价(价格最低,阶梯数最大)
      */
-    LadderPriceVo findLowerLadderPrice(Integer productId);
+    LadderPriceVo findLowerLadderPrice(Integer skuId);
     /**
      * 获取最高阶梯价(价格最高,阶梯数最小)
      */
-    LadderPriceVo findMaxLadderPrice(Integer productId);
+    LadderPriceVo findMaxLadderPrice(Integer skuId);
     /**
      * 根据商品ID和用户ID 查询复购价
      */
-    Double getRepurchasePrice(@Param("productId") Integer productId, @Param("userId") Integer userId);
+    Double getRepurchasePrice(@Param("skuId") Integer skuId, @Param("userId") Integer userId);
     /**
      * 根据商品ID含税和发票信息
      */
@@ -76,5 +74,17 @@ public interface PriceMapper {
      */
     void insertProductSalesRecord(Integer productId, Integer sales);
 
-    void newFlag();
+    /**
+     * skus
+     * @param productId
+     * @return
+     */
+    List<Sku> findSkus(Integer productId);
+
+    /**
+     * 查找所有阶梯价中最低价
+     * @param productId
+     * @return
+     */
+    ProductItemVo findLowPrice(Integer productId);
 }

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

@@ -1,5 +1,6 @@
 package com.caimei365.commodity.mapper;
 
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.BrandVo;
@@ -206,4 +207,7 @@ public interface ShopMapper {
      */
     String getShopNameByShopId(Integer shopId);
 
+    void insertSku(Sku s);
+
+    void updateSku(Sku s);
 }

+ 6 - 31
src/main/java/com/caimei365/commodity/model/dto/ProductDto.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * Description
@@ -73,36 +74,11 @@ public class ProductDto implements Serializable {
      */
     @ApiModelProperty("商品标签,逗号隔开")
     private String tags;
-    /**
-     * 包装规格
-     */
-    @ApiModelProperty("包装规格")
-    private String unit;
-    /**
-     * 机构价格
-     */
-    @ApiModelProperty("机构价格")
-    private Double price;
-    /**
-     * 市场价
-     */
-    @ApiModelProperty("市场价")
-    private Double normalPrice;
     /**
      * 是否含税:0不含税,1含税,2未知
      */
     @ApiModelProperty("是否含税:0不含税,1含税,2未知")
     private Integer includedTax;
-    /**
-     * 最小购买量
-     */
-    @ApiModelProperty("最小购买量")
-    private Integer minBuyNumber;
-    /**
-     * 库存
-     */
-    @ApiModelProperty("库存")
-    private Integer stock;
     /**
      * 品牌名称
      */
@@ -133,11 +109,6 @@ public class ProductDto implements Serializable {
      */
     @ApiModelProperty("械字号资质证书图")
     private String qualificationImg;
-    /**
-     * 成本价
-     */
-    @ApiModelProperty("成本价")
-    private Double costPrice;
     /**
      * 发票类型(基于是否含税基础)   1增值税票,2普通票, 3不能开票
      */
@@ -230,5 +201,9 @@ public class ProductDto implements Serializable {
     @ApiModelProperty("证书有效链接")
     public String qualificationLink;
 
-
+    /**
+     * 库存skus
+     */
+    @ApiModelProperty("sku参数json")
+    public String skus;
 }

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

@@ -0,0 +1,91 @@
+package com.caimei365.commodity.model.dto;
+
+import com.caimei365.commodity.model.vo.LadderPriceVo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author zzj
+ */
+@ApiModel("商品sku")
+@Data
+public class Sku {
+
+    private Integer productId;
+    /**
+     * 划线价格
+     */
+    @ApiModelProperty("划线价格")
+    private Double originalPrice;
+    /**
+     * 最大购买量
+     */
+    @ApiModelProperty("最大购买量")
+    private Integer maxBuyNumber;
+    /**
+     * 计算后价格等级
+     */
+    @ApiModelProperty("计算后价格等级")
+    private Integer priceGrade;
+    /**
+     * 是否复购 0否 1是
+     */
+    @ApiModelProperty("是否复购")
+    private Integer repurchaseFlag;
+    /**
+     * 启用阶梯价格标识 0否 1是
+     */
+    @ApiModelProperty("阶梯价标志")
+    private Integer ladderPriceFlag;
+    /**
+     * 比例成本百分比
+     */
+    @ApiModelProperty("比例成本百分比")
+    private Double costProportional;
+    /**
+     * 成本价选中标志:1固定成本 2比例成
+     */
+    @ApiModelProperty("成本价选中标志")
+    private Integer costCheckFlag;
+
+    @ApiModelProperty("skuId")
+    private Integer skuId;
+    /**
+     * 起订量
+     */
+    @ApiModelProperty("最小购买量")
+    private Integer minBuyNumber;
+    /**
+     * 成本价
+     */
+    @ApiModelProperty("成本价")
+    private Double costPrice;
+    /**
+     * 库存
+     */
+    @ApiModelProperty("库存")
+    private Integer stock;
+    /**
+     * 机构价格
+     */
+    @ApiModelProperty("机构价格")
+    private Double price;
+    /**
+     * 市场价
+     */
+    @ApiModelProperty("市场价")
+    private Double normalPrice;
+    /**
+     * 包装规格
+     */
+    @ApiModelProperty("包装规格")
+    private String unit;
+    /**
+     * 阶梯价格
+     */
+    @ApiModelProperty("阶梯价格")
+    private List<LadderPriceVo> ladderPriceList;
+}

+ 7 - 24
src/main/java/com/caimei365/commodity/model/po/ProductPo.java

@@ -1,10 +1,13 @@
 package com.caimei365.commodity.model.po;
 
+import com.caimei365.commodity.model.dto.Sku;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * Description
@@ -27,10 +30,6 @@ public class ProductPo implements Serializable {
      * 商品名称
      */
     private String name;
-    /**
-     * 商品价格
-     */
-    private Double price;
     /**
      * 价格可见度:0公开价格 1不公开价格 2仅对会员机构公开 price1TextFlag
      */
@@ -39,10 +38,6 @@ public class ProductPo implements Serializable {
      * 商品货号
      */
     private String productCode;
-    /**
-     * 库存
-     */
-    private Integer stock;
     /**
      * 内部商品名称
      */
@@ -59,10 +54,6 @@ public class ProductPo implements Serializable {
      * 指定的销售区域
      */
     private String provinceIds;
-    /**
-     * 市场价
-     */
-    private Double normalPrice;
     /**
      * 主图
      */
@@ -99,10 +90,6 @@ public class ProductPo implements Serializable {
      * 销量
      */
     private Integer sellNumber;
-    /**
-     * 成本价
-     */
-    private Double costPrice;
     /**
      * 成本价选中标志:1固定成本 2比例成
      */
@@ -175,14 +162,6 @@ public class ProductPo implements Serializable {
      * 商品标签用英文逗号隔开,中文逗号或其它一律不作切割
      */
     private String tags;
-    /**
-     * 包装规格
-     */
-    private String unit;
-    /**
-     * 最小购买量
-     */
-    private Integer minBuyNumber;
     /**
      * 服务起订量
      */
@@ -287,4 +266,8 @@ public class ProductPo implements Serializable {
      */
     public String qualificationLink;
 
+    /**
+     * 库存skus
+     */
+    public List<Sku> skus;
 }

+ 3 - 0
src/main/java/com/caimei365/commodity/model/vo/LadderPriceVo.java

@@ -13,7 +13,10 @@ import java.io.Serializable;
 @Data
 public class LadderPriceVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
     private Integer id;
+
+    private Integer skuId;
     /**
      * 商品id
      */

+ 4 - 40
src/main/java/com/caimei365/commodity/model/vo/PriceVo.java

@@ -1,9 +1,11 @@
 package com.caimei365.commodity.model.vo;
 
+import com.caimei365.commodity.model.dto.Sku;
 import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 商品价格
@@ -14,6 +16,8 @@ import java.math.BigDecimal;
 @Data
 public class PriceVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private List<Sku> skus;
     /**
      * 促销活动可见性 0所有人,1仅对机构
      */
@@ -26,50 +30,10 @@ public class PriceVo implements Serializable {
      * 供应商ID
      */
     private Integer shopId;
-    /**
-     * 价格(计算后)
-     */
-    private Double price;
-    /**
-     * 划线价格
-     */
-    private Double originalPrice;
-    /**
-     * 最小购买量
-     */
-    private Integer minBuyNumber;
-    /**
-     * 最大购买量
-     */
-    private Integer maxBuyNumber;
     /**
      * 是否公开机构价: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
      */
     private Integer priceFlag;
-    /**
-     * 是否复购 0否 1是
-     */
-    private Integer repurchaseFlag;
-    /**
-     * 阶梯价标志
-     */
-    private Integer ladderPriceFlag;
-    /**
-     * 市场价
-     */
-    private Double normalPrice;
-    /**
-     * 成本价
-     */
-    private Double costPrice;
-    /**
-     * 比例成本百分比
-     */
-    private Double costProportional;
-    /**
-     * 成本价选中标志:1固定成本 2比例成
-     */
-    private Integer costCheckFlag;
     /**
      * 用户身份: 2-会员机构, 4-普通机构
      */

+ 14 - 29
src/main/java/com/caimei365/commodity/model/vo/ProductDetailVo.java

@@ -1,5 +1,6 @@
 package com.caimei365.commodity.model.vo;
 
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.po.ProductDetailInfoPo;
 import com.caimei365.commodity.model.po.ProductImagePo;
 import com.caimei365.commodity.model.po.ProductParameterPo;
@@ -23,6 +24,18 @@ import java.util.List;
 public class ProductDetailVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    /**
+     * skus
+     */
+    private List<Sku> skus;
+    /**
+     * 展示的最低价的规格
+     */
+    private String unit;
+    /**
+     * 默认显示的最低价
+     */
+    private Double price;
     /**
      * 用户收藏标记(1收藏,0未收藏)
      */
@@ -87,18 +100,6 @@ public class ProductDetailVo implements Serializable {
      * 商品货号
      */
     private String productCode;
-    /**
-     * 包装规格
-     */
-    private String unit;
-    /**
-     * 市场价
-     */
-    private Double normalPrice;
-    /**
-     * 商品价格
-     */
-    private Double price;
     /**
      * 价格可见度:0公开价格 1不公开价格 2仅对会员机构公开 price1TextFlag
      */
@@ -111,10 +112,6 @@ public class ProductDetailVo implements Serializable {
      * 阶梯价格列表
      */
     private List<LadderPriceVo> ladderPriceList;
-    /**
-     * 成本价
-     */
-    private Double costPrice;
     /**
      * 商品可见度:(3:所有人可见,2:普通机构可见,1:会员机构可见)
      */
@@ -139,18 +136,10 @@ public class ProductDetailVo implements Serializable {
      * 供应商税率:增值专用发票默认13%,增值税普通发票6%取值范围[0-100]
      */
     private Double supplierTaxPoint;
-    /**
-     * 最小购买量
-     */
-    private Integer minBuyNumber;
     /**
      * 服务起订量
      */
     private Integer serviceNumber;
-    /**
-     * 库存
-     */
-    private Integer stock;
     /**
      * 商品的类别:1正常商品(默认),2二手商品
      */
@@ -289,10 +278,6 @@ public class ProductDetailVo implements Serializable {
      * 用户身份: 2-会员机构, 4-普通机构
      */
     private Integer userIdentity;
-    /**
-     * 最大购买量
-     */
-    private Integer maxBuyNumber;
     /**
      * 是否复购 0否 1是
      */
@@ -347,7 +332,7 @@ public class ProductDetailVo implements Serializable {
      *产品名称
      */
     public String productName;
-    /*
+    /**
      *证书有效日期
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")

+ 14 - 6
src/main/java/com/caimei365/commodity/model/vo/ProductFormVo.java

@@ -1,5 +1,6 @@
 package com.caimei365.commodity.model.vo;
 
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.po.ProductDetailInfoPo;
 import com.caimei365.commodity.model.po.ProductImagePo;
 import com.caimei365.commodity.model.po.ProductParameterPo;
@@ -261,29 +262,36 @@ public class ProductFormVo implements Serializable {
      */
     private BigDecimal trainingFee;
 
-    //新品参与状态1.参与2.未参与
+    /**
+     * 新品参与状态1.参与2.未参与
+     */
     private Integer newProductType;
 
-//新品审核状态 1,审核通过2,审核未通过3,待审核
+    /**
+     * 新品审核状态 1,审核通过2,审核未通过3,待审核
+     */
     private Integer newvalidFlag;
     /**
      * 证书编号
+     *
      * @return
      */
     public String qualificationNo;
 
     /**
-     *产品名称
+     * 产品名称
      */
     public String productName;
-    /*
-     *证书有效日期
+    /**
+     * 证书有效日期
      */
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     public Date qualificationTime;
 
     /**
-     *证书有效链接
+     * 证书有效链接
      */
     public String qualificationLink;
+
+    public List<Sku> skus;
 }

+ 33 - 116
src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java

@@ -1,5 +1,6 @@
 package com.caimei365.commodity.model.vo;
 
+import com.caimei365.commodity.model.dto.Sku;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -15,10 +16,42 @@ import java.util.List;
 @Data
 public class ProductItemVo implements Serializable {
     private static final long serialVersionUID = 1L;
+    /**
+     * 再次购买的skuId
+     */
+    private Integer skuId;
+    /**
+     * skus
+     */
+    private List<Sku> skus;
+    /**
+     * 赠品skuId
+     */
+    private Integer giftSkuId;
+    /**
+     * 再次购买中的成本
+     */
+    private Double costPrice;
+    /**
+     * 再次购买中的成本标记
+     */
+    private Integer costCheckFlag;
     /**
      * itemId
      */
     private Integer id;
+    /**
+     * 展示的最低价的规格(再次购买的unit)
+     */
+    private String unit;
+    /**
+     * 默认的最低价(再次购买的价格)
+     */
+    private Double price;
+    /**
+     * 默认的最低市场价(列表显示)
+     */
+    private Double normalPrice;
     /**
      * 商品productID
      */
@@ -37,26 +70,14 @@ public class ProductItemVo implements Serializable {
      * 品牌
      */
     private String brandName;
-    /**
-     * 包装规格
-     */
-    private String unit;
     /**
      * 商品货号
      */
     private String code;
-    /**
-     * 机构价
-     */
-    private Double price;
     /**
      * 是否公开机构价 0公开价格 1不公开价格
      */
     private Integer priceFlag;
-    /**
-     * 计算后价格等级
-     */
-    private Integer priceGrade;
     /**
      * 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
      */
@@ -77,15 +98,6 @@ public class ProductItemVo implements Serializable {
      * 商品原价
      */
     private Double originalPrice;
-    /**
-     * 成本价选中标志:1固定成本 2比例成
-     */
-    private Integer costCheckFlag;
-
-    /**
-     * 固定成本价
-     */
-    private Double costPrice;
     /**
      * 购买数量
      */
@@ -98,10 +110,6 @@ public class ProductItemVo implements Serializable {
      * 增量
      */
     private Integer step;
-    /**
-     * 起订量
-     */
-    private Integer minBuyNumber;
     /**
      * 最大购买量
      */
@@ -114,22 +122,10 @@ public class ProductItemVo implements Serializable {
      * 活动状态:1有效,0失效
      */
     private Integer actStatus;
-    /**
-     * 启用阶梯价格标识:1是,0否
-     */
-    private Integer ladderPriceFlag;
-    /**
-     * 库存
-     */
-    private Integer stock;
     /**
      * 购物车失效状态:0有效,1后台删除的,2冻结的,3下架,4售罄 >7库存不足,5价格仅会员可见,6未公开价格
      */
     private Integer status;
-    /**
-     * 阶梯价
-     */
-    List<LadderPriceVo> ladderPrices;
     /**
      * 促销活动
      */
@@ -174,10 +170,6 @@ public class ProductItemVo implements Serializable {
      * 内部商品名称
      */
     private String aliasName;
-    /**
-     * 市场价
-     */
-    private Double normalPrice;
     /**
      * 所在分类名称
      */
@@ -214,10 +206,6 @@ public class ProductItemVo implements Serializable {
      * 再次购买价格
      */
     private Double discountPrice;
-    /**
-     * 是否复购 0否 1是
-     */
-    private Integer repurchaseFlag;
     /**
      * 判断是否勾选(前端使用)
      */
@@ -280,75 +268,4 @@ public class ProductItemVo implements Serializable {
      * 楼层相关商品图片3
      */
     private List<FloorImageVo> floorImageList3;
-
-    @Override
-    public String toString() {
-        return "ProductItemVo{" +
-                "id=" + id +
-                ", productId=" + productId +
-                ", brandID=" + brandID +
-                ", name='" + name + '\'' +
-                ", image='" + image + '\'' +
-                ", brandName='" + brandName + '\'' +
-                ", unit='" + unit + '\'' +
-                ", code='" + code + '\'' +
-                ", price=" + price +
-                ", priceFlag=" + priceFlag +
-                ", priceGrade=" + priceGrade +
-                ", visibility='" + visibility + '\'' +
-                ", shopId=" + shopId +
-                ", keyword='" + keyword + '\'' +
-                ", originalPrice=" + originalPrice +
-                ", costCheckFlag=" + costCheckFlag +
-                ", costPrice=" + costPrice +
-                ", number=" + number +
-                ", productType=" + productType +
-                ", step=" + step +
-                ", minBuyNumber=" + minBuyNumber +
-                ", maxBuyNumber=" + maxBuyNumber +
-                ", validFlag=" + validFlag +
-                ", actStatus=" + actStatus +
-                ", ladderPriceFlag=" + ladderPriceFlag +
-                ", stock=" + stock +
-                ", status=" + status +
-                ", ladderPrices=" + ladderPrices +
-                ", promotions=" + promotions +
-                ", productCategory=" + productCategory +
-                ", productCode='" + productCode + '\'' +
-                ", productsChecked=" + productsChecked +
-                ", repurchasePriceState=" + repurchasePriceState +
-                ", includedTax='" + includedTax + '\'' +
-                ", invoiceType='" + invoiceType + '\'' +
-                ", taxRate=" + taxRate +
-                ", userIdentity=" + userIdentity +
-                ", detailTalkFlag=" + detailTalkFlag +
-                ", aliasName='" + aliasName + '\'' +
-                ", normalPrice=" + normalPrice +
-                ", typeName='" + typeName + '\'' +
-                ", featuredFlag=" + featuredFlag +
-                ", commodityType=" + commodityType +
-                ", bigTypeId=" + bigTypeId +
-                ", smallTypeId=" + smallTypeId +
-                ", tinyTypeId=" + tinyTypeId +
-                ", initProductNum=" + initProductNum +
-                ", totalPrice=" + totalPrice +
-                ", discountPrice=" + discountPrice +
-                ", repurchaseFlag=" + repurchaseFlag +
-                ", isChecked=" + isChecked +
-                ", couponsLogo=" + couponsLogo +
-                ", svipProductFlag=" + svipProductFlag +
-                ", svipPriceTag='" + svipPriceTag + '\'' +
-                ", announType=" + announType +
-                ", newvalidFlag=" + newvalidFlag +
-                ", showFlag=" + showFlag +
-                ", showTime='" + showTime + '\'' +
-                ", recommend=" + recommend +
-                ", newshowTime='" + newshowTime + '\'' +
-                ", newProductType=" + newProductType +
-                ", BrandName='" + BrandName + '\'' +
-                ", floorImageList=" + floorImageList +
-                ", floorImageList2=" + floorImageList2 +
-                ", floorImageList3=" + floorImageList3 +
-                '}';
-    }
 }

+ 10 - 0
src/main/java/com/caimei365/commodity/model/vo/UserLikeProductVo.java

@@ -0,0 +1,10 @@
+package com.caimei365.commodity.model.vo;
+
+import java.io.Serializable;
+
+/**
+ * @author zzj
+ */
+public class UserLikeProductVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+}

+ 26 - 63
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -5,6 +5,7 @@ import com.aliyun.oss.OSSClientBuilder;
 import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.mapper.*;
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.*;
@@ -24,6 +25,7 @@ import javax.annotation.Resource;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
 /**
@@ -125,7 +127,7 @@ public class PageServiceImpl implements PageService {
             floor.setFloorImageList(floorImageList);
         }
         map.put("typeSort", typeSort);
-        log.info("仪器页面数据userId================================》"+userId+"====="+contentLabel);
+        log.info("仪器页面数据userId================================》" + userId + "=====" + contentLabel);
         map.put("contentLabel", contentLabel);
         map.put("hotSearchList", hotSearchList);
         map.put("floorList", floorList);
@@ -547,18 +549,11 @@ public class PageServiceImpl implements PageService {
     @Override
     public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId) {
         ProductDetailVo product = pageMapper.getProductDetails(productId);
-        // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
-        Integer identity = shopMapper.getUserIdentityById(userId);
         if (product == null) {
             //商品不存在
             product = new ProductDetailVo();
             product.setValidFlag(0);
         }
-        boolean validFlag = 2 != product.getProductCategory() && 2 == product.getValidFlag() && (product.getStock() == null || product.getStock() == 0);
-        if (validFlag) {
-            //已上架但库存为0的正常商品,设置为已售罄商品
-            product.setValidFlag(4);
-        }
         String[] split = null;
         // 品牌名称
         String brandName = shopMapper.getBrandNameById(product.getBrandId());
@@ -588,18 +583,6 @@ public class PageServiceImpl implements PageService {
         product.setImageList(imageList);
         // 商品详情
         ProductDetailInfoPo productDetail = shopMapper.getProductDetailInfo(productId);
-        //非资质机构商品详情展示普通机构商品详情,游客和普通机构要进判断
-//        if (null == identity || 4 == identity) {
-//            String chose = product.getProductDetailChose();
-//            log.info("身份identity===================>"+identity+"ProductDetail===================》"+chose);
-//            if (StringUtils.isNotEmpty(chose) && "2".equals(chose)) {
-//                //将商品详情展示为普通机构商品详情
-//                String info = null == productDetail.getDetailInfo2() ? "若要查看更多产品信息,请注册机构会员,如有疑问请联系客服。" : productDetail.getDetailInfo2();
-//                log.info("DetailInfo2参数================================》"+info);
-//                productDetail.setDetailInfo(info);
-//            }
-//        }
-//        log.info("-------------------》productDetail参数"+productDetail.toString());
         product.setProductDetail(productDetail);
         // 相关参数
         List<ProductParameterPo> parametersList = shopMapper.getProductParameters(productId);
@@ -611,8 +594,6 @@ public class PageServiceImpl implements PageService {
         product.setBigTypeName(list.size() > 0 ? list.get(0) : null);
         product.setSmallTypeName(list.size() > 1 ? list.get(1) : null);
         product.setTinyTypeName(list.size() > 2 ? list.get(2) : null);
-        //价格等级
-        product.setPriceGrade(priceUtilService.getPriceGrade(product.getPrice()));
         // 商品云上美博会活动状态
         Integer pcBeautyStatus = shopMapper.getPcBeautyStatusById(product.getProductId());
         Integer appletsBeautyStatus = shopMapper.getAppletsBeautyStatusById(product.getProductId());
@@ -634,60 +615,43 @@ public class PageServiceImpl implements PageService {
             shop.setBusinessLicense(ImageUtils.getImageURL("shopLogo", shop.getBusinessLicense(), 0, domain));
             product.setShop(shop);
         }
-        // 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
-        /*Integer visibility = product.getVisibility();
-        if (null != userId && userId > 0) {
-            // 会员机构类型:1医美,2生美
-            Integer clubType = 0;
-            if (null != identity && identity == 2) {
-                clubType = priceMapper.getClubTypeById(userId);
-            }
-            // 超级会员用户id
-            Integer superVipId = priceMapper.getSvipUserIdByUserId(userId);
-            // 所有人可见
-            boolean pass1 = visibility == 3;
-            // 协销
-            boolean pass2 = null != identity && identity == 1;
-            // 医美机构
-            boolean pass3 = visibility == 4 && (null != clubType && clubType == 1);
-            // 会员机构 | 超级会员
-            boolean pass4 = visibility == 1 && (null != superVipId || (null != identity && identity == 2));
-            // 普通机构
-            boolean pass5 = visibility == 2 && (null != identity && (identity == 4 || identity == 2));
-            // 没有权限查看该商品
-            if (!(pass1 || pass2 || pass3 || pass4 || pass5)) {
-                return ResponseJson.success(0, "没有权限查看该商品", product);
-            }
-        } else if (2 == visibility || 1 == visibility || 4 == visibility) {
-            return ResponseJson.success(0, "没有权限查看该商品,userId为空", product);
-        }*/
         // 商品不处于已删除/待审核/审核未通过的状态
         if (0 != product.getValidFlag()) {
             // 数据库获取基本价格信息
+            List<Sku> skus = priceMapper.findSkus(productId);
             PriceVo price = priceMapper.getDetailPrice(productId);
+            product.setSkus(skus);
+            price.setSkus(skus);
             // 根据用户id设置详细价格
             priceUtilService.setPriceByUserId(price, userId);
             // 设置价格
             product.setActStatus(price.getActStatus());
-            product.setPrice(price.getPrice());
-            product.setOriginalPrice(price.getOriginalPrice());
-            product.setNormalPrice(price.getNormalPrice());
-            product.setLadderPriceFlag(price.getLadderPriceFlag());
             product.setPromotions(price.getPromotions());
-            product.setMinBuyNumber(price.getMinBuyNumber());
             product.setUserIdentity(price.getUserIdentity());
-            product.setRepurchaseFlag(price.getRepurchaseFlag());
-            product.setMaxBuyNumber(price.getMaxBuyNumber());
             product.setSvipProductFlag(price.getSvipProductFlag());
             product.setSvipPriceTag(price.getSvipPriceTag());
+            AtomicBoolean lowPrice = new AtomicBoolean(false);
             // 设置阶梯价格详情
-            if (1 == price.getLadderPriceFlag()) {
-                List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(product.getProductId());
-                TaxVo tax = priceMapper.getTaxByProductId(product.getProductId());
-                if (!CollectionUtils.isEmpty(ladderPrices)) {
-                    priceUtilService.setLadderPriceList(ladderPrices, tax);
+            skus.forEach(s -> {
+                if (1 == s.getLadderPriceFlag()) {
+                    List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(s.getSkuId());
+                    TaxVo tax = priceMapper.getTaxByProductId(productId);
+                    if (!CollectionUtils.isEmpty(ladderPrices)) {
+                        priceUtilService.setLadderPriceList(ladderPrices, tax);
+                    }
+                    s.setLadderPriceList(ladderPrices);
+                    lowPrice.set(true);
                 }
-                product.setLadderPriceList(ladderPrices);
+            });
+            //设置展示的默认最低价
+            if (lowPrice.get()) {
+                ProductItemVo showProduct = priceMapper.findLowPrice(productId);
+                product.setPrice(showProduct.getPrice());
+                product.setUnit(showProduct.getUnit());
+            } else {
+                List<Sku> collect = skus.stream().sorted(Comparator.comparing(Sku::getPrice)).collect(Collectors.toList());
+                product.setPrice(collect.get(0).getPrice());
+                product.setUnit(collect.get(0).getUnit());
             }
             //查询商品收藏情况,1未收藏,0未收藏,未收藏过该商品用户是null
             Integer like = likeMapper.findLike(userId, productId);
@@ -1385,7 +1349,6 @@ public class PageServiceImpl implements PageService {
                     }
                 }
             }
-            product.setPriceGrade(priceUtilService.getPriceGrade(product.getPrice()));
             product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
         });
         PaginationVo<ProductItemVo> pageData = new PaginationVo(list);

+ 0 - 10
src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java

@@ -73,11 +73,6 @@ public class SearchProductServiceImpl implements SearchProductService {
         }
         List<String> filterList = new ArrayList<>();
         if (newFlag == 1) {
-//            Calendar c = Calendar.getInstance();
-//            c.setTime(new Date());
-//            c.add(Calendar.YEAR, -1);
-//            String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
-//            filterList.add("p_time > " + time);
             filterList.add("p_newvalidflag = 1");
         }
         if (promotionFlag == 1) {
@@ -256,11 +251,6 @@ public class SearchProductServiceImpl implements SearchProductService {
         }
         List<String> filterList = new ArrayList<>();
         if (newFlag == 1) {
-//            Calendar c = Calendar.getInstance();
-//            c.setTime(new Date());
-//            c.add(Calendar.YEAR, -1);
-//            String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
-//            filterList.add("p_time > " + time);
             filterList.add("p_newvalidflag = 1");
         }
         if (promotionFlag == 1) {

+ 15 - 8
src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java

@@ -3,8 +3,10 @@ package com.caimei365.commodity.service.impl;
 import com.caimei365.commodity.components.RedisService;
 import com.caimei365.commodity.mapper.PriceMapper;
 import com.caimei365.commodity.mapper.SecondHandMapper;
+import com.caimei365.commodity.mapper.ShopMapper;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.dto.SecondDto;
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.po.ProductImagePo;
 import com.caimei365.commodity.model.po.ProductPo;
 import com.caimei365.commodity.model.po.ProductSecondPo;
@@ -46,7 +48,8 @@ public class SecondHandServiceImpl implements SecondHandService {
     private PriceMapper priceMapper;
     @Value("${spring.cloud.config.profile}")
     private String profile;
-
+    @Resource
+    private ShopMapper shopMapper;
     /**
      * 二手商品列表
      *
@@ -427,10 +430,7 @@ public class SecondHandServiceImpl implements SecondHandService {
         ProductPo product = new ProductPo();
         product.setBrandId(secondDto.getBrandId());
         product.setName(secondDto.getName());
-        product.setPrice(secondDto.getPrice());
-        product.setStock(secondDto.getStock());
         product.setAliasName(secondDto.getName());
-        product.setNormalPrice(secondDto.getNormalPrice());
         product.setMainImage(images[0]);
         // 二手商品类型
         product.setProductCategory(2);
@@ -438,13 +438,9 @@ public class SecondHandServiceImpl implements SecondHandService {
         // 默认发布到二手供应商
         product.setShopId(shopId);
         product.setSellNumber(secondDto.getStock());
-        product.setCostPrice(0d);
-        product.setCostCheckFlag(2);
-        product.setCostProportional(95d);
         product.setHasSkuFlag(1);
         // 商品状态默认待审核
         product.setValidFlag(1);
-        product.setLadderPriceFlag(0);
         product.setSortIndex(1);
         product.setFeaturedFlag(0);
         product.setByFlag(0);
@@ -465,6 +461,17 @@ public class SecondHandServiceImpl implements SecondHandService {
         product.setAnnounType(secondDto.getAnnounType());
         /* 保存商品表 */
         secondHandMapper.insertProduct(product);
+        /*保存sku数据*/
+        Sku sku = new Sku();
+        sku.setPrice(secondDto.getPrice());
+        sku.setStock(secondDto.getStock());
+        sku.setNormalPrice(secondDto.getNormalPrice());
+        sku.setLadderPriceFlag(0);
+        sku.setCostPrice(0d);
+        sku.setCostCheckFlag(2);
+        sku.setCostProportional(95d);
+        sku.setProductId(product.getProductId());
+        shopMapper.insertSku(sku);
         /* 保存商品图片信息*/
         for (int i = 0; i < images.length; i++) {
             ProductImagePo imagePo = new ProductImagePo();

+ 72 - 101
src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java

@@ -1,6 +1,7 @@
 package com.caimei365.commodity.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.mapper.PriceMapper;
@@ -10,6 +11,7 @@ import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.dto.BrandDto;
 import com.caimei365.commodity.model.dto.FeaturedDto;
 import com.caimei365.commodity.model.dto.ProductDto;
+import com.caimei365.commodity.model.dto.Sku;
 import com.caimei365.commodity.model.po.*;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.*;
@@ -21,6 +23,8 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
@@ -63,13 +67,13 @@ public class ShopServiceImpl implements ShopService {
         List<Integer> visibilityList = new ArrayList<>();
         if (identity == 1 || identity == 5) {
             // 协销 | 医美机构 | 综合供应商
-            visibilityList.addAll(Arrays.asList(1,2,3,4));
+            visibilityList.addAll(Arrays.asList(1, 2, 3, 4));
         } else if (identity == 2) {
             // 会员机构
-            visibilityList.addAll(Arrays.asList(1,2,3));
+            visibilityList.addAll(Arrays.asList(1, 2, 3));
         } else if (identity == 4) {
             // 普通机构
-            visibilityList.addAll(Arrays.asList(2,3));
+            visibilityList.addAll(Arrays.asList(2, 3));
         } else {
             // 游客|所有人
             visibilityList.add(3);
@@ -101,13 +105,13 @@ public class ShopServiceImpl implements ShopService {
      * @return Map<String, Object>
      */
     @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 newvalidFlag, int pageNum, int pageSize) {
         if (null == shopId) {
             return ResponseJson.error("参数异常:缺少供应商Id", null);
         }
         Map<String, Object> map = new HashMap<>();
         PageHelper.startPage(pageNum, pageSize);
-        List<ProductItemVo> productList = shopMapper.getShopProductsSelect(showFlag,newvalidFlag,shopId, name, productCode, validFlag, featuredFlag, commodityType, bigTypeId, smallTypeId, tinyTypeId);
+        List<ProductItemVo> productList = shopMapper.getShopProductsSelect(showFlag, newvalidFlag, shopId, name, productCode, validFlag, featuredFlag, commodityType, bigTypeId, smallTypeId, tinyTypeId);
         if (null != productList && productList.size() > 0) {
             for (ProductItemVo product : productList) {
                 String typeName = shopMapper.getTypeName(product.getBigTypeId(), product.getSmallTypeId(), product.getTinyTypeId());
@@ -122,13 +126,13 @@ public class ShopServiceImpl implements ShopService {
         map.put("productPage", productPage);
         int featuredNum = shopMapper.getMainProductsCount(shopId);
         map.put("featuredNum", featuredNum);
-       Integer listingFeeCount= shopMapper.listingFee(shopId);
-        Integer listingfeeExpireCount= shopMapper.listingfeeExpire(shopId);
-        Integer receStatctCount=shopMapper.receStatct(shopId);
-        Integer listingFee=0;
-        if(listingFeeCount>0 && listingfeeExpireCount>0){
-                if(receStatctCount<=0){
-                listingFee=1;//1是有上架费或者过期并且没有免除上架费
+        Integer listingFeeCount = shopMapper.listingFee(shopId);
+        Integer listingfeeExpireCount = shopMapper.listingfeeExpire(shopId);
+        Integer receStatctCount = shopMapper.receStatct(shopId);
+        Integer listingFee = 0;
+        if (listingFeeCount > 0 && listingfeeExpireCount > 0) {
+            if (receStatctCount <= 0) {
+                listingFee = 1;//1是有上架费或者过期并且没有免除上架费
             }
         }
         map.put("listingFee", listingFee);
@@ -172,6 +176,7 @@ public class ShopServiceImpl implements ShopService {
      *                   }
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public ResponseJson releaseProduct(ProductDto productDto) {
         // 参数校验
         if (null == productDto.getShopId()) {
@@ -198,27 +203,26 @@ public class ShopServiceImpl implements ShopService {
         if (StringUtils.isBlank(productDto.getTags())) {
             return ResponseJson.error("参数异常:商品标签不能为空!", null);
         }
-        if (StringUtils.isBlank(productDto.getUnit())) {
-            return ResponseJson.error("参数异常:包装规格不能为空!", null);
-        }
-        if (null == productDto.getNormalPrice()) {
-            return ResponseJson.error("参数异常:市场价不能为空!", null);
-        }
-        if (null == productDto.getPrice()) {
-            return ResponseJson.error("参数异常:机构价格不能为空!", null);
-        }
         if (null == productDto.getIncludedTax()) {
             return ResponseJson.error("参数异常:是否含税不能为空!", null);
         }
-        if (null == productDto.getMinBuyNumber()) {
-            return ResponseJson.error("参数异常:最小购买量不能为空!", null);
-        }
-        if (null == productDto.getStock()) {
-            return ResponseJson.error("参数异常:库存不能为空!", null);
-        }
         if (StringUtils.isBlank(productDto.getDetailInfo())) {
             return ResponseJson.error("参数异常:商品详情信息不能为空!", null);
         }
+        if (StringUtils.isBlank(productDto.getSkus())) {
+            return ResponseJson.error("参数异常:商品sku不能为空!", null);
+        }
+        List<Sku> skus = JSON.parseArray(productDto.getSkus(), Sku.class);
+        skus.forEach(s->{
+            Assert.notNull(s.getCostPrice(), "结算价不能为空!");
+            Assert.notNull(s.getNormalPrice(), "市场价不能为空!");
+            Assert.notNull(s.getPrice(), "售价不能为空!");
+            Assert.notNull(s.getUnit(), "规格不能为空!");
+            Assert.notNull(s.getMinBuyNumber(), "起订量不能为空!");
+        });
+
+
+
         JSONObject parseObject = JSON.parseObject(productDto.getParams());
         //图片
         List<Map<String, String>> imageList = (List<Map<String, String>>) parseObject.get("image");
@@ -231,85 +235,29 @@ public class ShopServiceImpl implements ShopService {
         String current = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
         //保存或修改商品
         ProductPo product = new ProductPo();
-        product.setNewProductType(productDto.getNewProductType());
-        log.info("打印日志__________>"+productDto.getNewProductType());
-        if(productDto.getNewProductType()==1){
-            product.setShowFlag(0);
-        }else {
-            product.setShowFlag(3);
-        }
-
-/*        if (null != productDto.getProductId()) {
-            product.setProductId(productDto.getProductId());
-        }
-        product.setShopId(productDto.getShopId());
-        product.setName(productDto.getName());
-        product.setAliasName(productDto.getAliasName());
-        product.setCommodityType(productDto.getCommodityType());
-        product.setBigTypeId(productDto.getBigTypeId());
-        product.setSmallTypeId(productDto.getSmallTypeId());
-        product.setTinyTypeId(productDto.getTinyTypeId());
-        product.setBrandId(productDto.getBrandId());
-        product.setProductType(productDto.getProductType());
-        product.setTags(productDto.getTags());
-        product.setUnit(productDto.getUnit());
-        product.setNormalPrice(productDto.getNormalPrice());
-        product.setPrice(productDto.getPrice());
-        product.setIncludedTax(productDto.getIncludedTax());
-        product.setMinBuyNumber(productDto.getMinBuyNumber());
-        product.setStock(productDto.getStock());
-        product.setSearchKey(productDto.getSearchKey());
-        product.setCostPrice(productDto.getCostPrice());
-        product.setStep(productDto.getStep());
-        product.setAllAreaFlag(productDto.getAllAreaFlag());
-        product.setProvinceIds(productDto.getProvinceIds());
-        product.setProductCode(productDto.getProductCode());
-        product.setServiceNumber(productDto.getMinBuyNumber());
-        product.setSupplierTaxPoint(productDto.getTaxPoint());
-        product.setMachineType(productDto.getMachineType());
-        product.setStep(productDto.getStep());
-        product.setQualificationImg(productDto.getQualificationImg());
-        product.setInvoiceType(productDto.getInvoiceType());
-        product.setTaxPoint(productDto.getTaxPoint());
-        product.setAllAreaFlag(productDto.getAllAreaFlag());
-        product.setProvinceIds(productDto.getProvinceIds());*/
+//        product.setNewProductType(productDto.getNewProductType());
+        Integer showFlag = 1 == productDto.getNewProductType() ? 0 : 3;
+        product.setShowFlag(showFlag);
         BeanUtils.copyProperties(productDto, product);
         product.setUpdateTime(current);
         product.setValidFlag(1);
         product.setProductCategory(1);
-        product.setQualificationNo(productDto.getQualificationNo());
-        product.setProductName(productDto.getProductName());
-        product.setQualificationTime(productDto.getQualificationTime());
+//        product.setQualificationNo(productDto.getQualificationNo());
+//        product.setProductName(productDto.getProductName());
+//        product.setQualificationTime(productDto.getQualificationTime());
         //根据商品类型给价格可见度、商品可见度、商品内容可见度赋值
-        //械字号
-        if (productDto.getProductType() == 2) {
-            //一类
-            if (productDto.getMachineType() == 1) {
-                product.setPriceFlag(0);
-                product.setVisibility(3);
-                product.setCommodityDetailsFlag(1);
-                //二类
-            } else if (productDto.getMachineType() == 2) {
-                product.setPriceFlag(3);
-                product.setVisibility(3);
-                product.setCommodityDetailsFlag(4);
-                //三类
-            } else if (productDto.getMachineType() == 3) {
-                product.setPriceFlag(3);
-                product.setVisibility(3);
-                product.setCommodityDetailsFlag(4);
-                //异常情况赋值
-            } else {
-                product.setPriceFlag(0);
-                product.setVisibility(3);
-                product.setCommodityDetailsFlag(1);
-            }
-            //其他字号商品
+        product.setVisibility(3);
+        Integer priceFlag;
+        Integer commodityDetailsFlag;
+        if (2 == productDto.getProductType()) {
+            priceFlag = 2 == productDto.getMachineType() || 3 == productDto.getMachineType() ? 3 : 0;
+            commodityDetailsFlag = 2 == productDto.getMachineType() || 3 == productDto.getMachineType() ? 4 : 1;
         } else {
-            product.setPriceFlag(2);
-            product.setVisibility(3);
-            product.setCommodityDetailsFlag(1);
+            priceFlag = 2;
+            commodityDetailsFlag = 1;
         }
+        product.setPriceFlag(priceFlag);
+        product.setCommodityDetailsFlag(commodityDetailsFlag);
         //设置主图
         for (Map<String, String> map : imageList) {
             String mainFlag = map.get("mainFlag");
@@ -328,8 +276,10 @@ public class ShopServiceImpl implements ShopService {
             product.setRecommendType(0);
             product.setActFlag(0);
             product.setLadderPriceFlag(0);
-            log.info("+++++++++++++++++++++++++"+product);
+            log.info("---------------------------------->" + product);
             shopMapper.insertProduct(product);
+            //插入sku
+            addSkus(skus, product.getProductId());
             if (StringUtils.isBlank(productDto.getProductCode())) {
                 String productCode = shopMapper.getCodeByTypeId(productDto.getBigTypeId(), productDto.getSmallTypeId(), productDto.getTinyTypeId());
                 productCode = productCode + product.getProductId();
@@ -337,8 +287,10 @@ public class ShopServiceImpl implements ShopService {
                 shopMapper.updateProductCode(productCode, product.getProductId());
             }
         } else {
-            log.info(">>>>>>>>>>>>>>>>>>"+product);
+            log.info("---------------------------------->" + product);
             shopMapper.updateProduct(product);
+            //修改sku
+            updateSkus(skus, product.getProductId());
         }
         //保存或修改商品图片
         List<ProductImagePo> productImageList = shopMapper.getImageByProductId(product.getProductId());
@@ -396,6 +348,23 @@ public class ShopServiceImpl implements ShopService {
         return ResponseJson.success();
     }
 
+    public void addSkus(List<Sku> skus, Integer productId) {
+        //保存sku
+        if (null != skus && skus.size() > 0) {
+            skus.forEach(s -> {
+                s.setProductId(productId);
+                shopMapper.insertSku(s);
+            });
+        }
+    }
+
+    public void updateSkus(List<Sku> skus, Integer productId) {
+        skus.forEach(s -> {
+            s.setProductId(productId);
+            shopMapper.updateSku(s);
+        });
+    }
+
     /**
      * 供应商-商品编辑回显
      *
@@ -406,7 +375,9 @@ public class ShopServiceImpl implements ShopService {
         if (null == productId) {
             return ResponseJson.error("参数异常:商品Id不能为空!", null);
         }
+        List<Sku> skus = priceMapper.findSkus(productId);
         ProductFormVo product = shopMapper.getProductForm(productId);
+        product.setSkus(skus);
         if (null == product) {
             return ResponseJson.error("商品信息异常,productId:" + productId, null);
         }

+ 9 - 15
src/main/resources/mapper/PageMapper.xml

@@ -215,7 +215,6 @@
                p.aliasName,
                p.commodityType,
                p.mainImage,
-               p.stock,
                p.invoiceType,
                p.bigTypeID         as bigTypeId,
                p.smallTypeID       as smallTypeId,
@@ -226,24 +225,18 @@
                p.brandID           as brandId,
                p.productType,
                p.tags,
-               p.unit,
-               p.normalPrice,
-               p.price,
                p.includedTax,
-               p.minBuyNumber,
                p.productCategory,
                p.serviceNumber,
                p.taxPoint,
                p.supplierTaxPoint,
                p.priceFlag,
                p.actFlag,
-               p.ladderPriceFlag,
                p.addTime,
                p.hasSkuFlag,
                p.sellNumber,
                p.sortIndex,
                p.featuredFlag,
-               p.costCheckFlag,
                p.recommendType,
                p.machineType,
                p.productCode,
@@ -252,7 +245,6 @@
                p.searchKey,
                p.allAreaFlag,
                p.step,
-               p.costPrice,
                p.provinceIds,
                p.qualificationImg,
                p.trainingMethod,
@@ -275,17 +267,18 @@
                p.name,
                p.aliasName,
                p.mainImage                as image,
-               p.unit,
+               rpp.skuId,
+               cs.unit,
                p.productCode              as code,
                p.priceFlag,
-               p.price,
-               p.costPrice,
+               cs.price,
+               cs.costPrice,
                ifnull(p.costCheckFlag, 1) as costCheckFlag,
                p.searchKey                as keyword,
-               p.minBuyNumber             as minBuyNumber,
+               cs.minBuyNumber             as minBuyNumber,
                p.maxBuyNumber             as maxBuyNumber,
-               p.ladderPriceFlag,
-               p.normalPrice,
+               cs.ladderPriceFlag,
+               cs.normalPrice,
                p.step,
                p.shopID                   as shopId,
                p.taxPoint                 as taxRate,
@@ -301,7 +294,8 @@
                rpp.currentPrice           as discountPrice,
                p.productType
         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
         where rpp.delFlag = '0'
           and p.validFlag = '2'
           and rpp.userId = #{userId}

+ 115 - 83
src/main/resources/mapper/PriceMapper.xml

@@ -2,105 +2,110 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.commodity.mapper.PriceMapper">
     <select id="getIdentityByUserId" resultType="java.lang.Integer">
-        select userIdentity from user where userID = #{userId}
+        select userIdentity
+        from user
+        where userID = #{userId}
     </select>
     <select id="getDetailPrice" resultType="com.caimei365.commodity.model.vo.PriceVo">
-        select
-            p.productID as productId,
-            p.actStatus,
-            p.price,
-            p.minBuyNumber,
-            p.maxBuyNumber,
-            p.priceFlag,
-            p.ladderPriceFlag,
-            p.normalPrice,
-            p.costPrice,
-            p.costProportional,
-            p.costCheckFlag,
-            p.step,
-            p.shopID as shopId,
-            p.taxPoint as taxRate,
-            p.includedTax,
-            p.invoiceType,
-            if(csp.id is not null,1,0) as svipProductFlag,
-            csp.priceType as svipPriceType,
-            csp.discount as svipDiscount,
-            csp.discountPrice as svipDiscountPrice,
-            p.productType
+        select p.productID                  as productId,
+               p.actStatus,
+               p.maxBuyNumber,
+               p.priceFlag,
+               p.step,
+               p.shopID                     as shopId,
+               p.taxPoint                   as taxRate,
+               p.includedTax,
+               p.invoiceType,
+               if(csp.id is not null, 1, 0) as svipProductFlag,
+               csp.priceType                as svipPriceType,
+               csp.discount                 as svipDiscount,
+               csp.discountPrice            as svipDiscountPrice,
+               p.productType
         from product p
-        left join cm_svip_product csp on p.productID = csp.productId
+                 left join cm_svip_product csp on p.productID = csp.productId
         where p.productID = #{productId}
     </select>
     <select id="getListPriceByProductIds" resultType="com.caimei365.commodity.model.vo.PriceVo">
         select
-            p.productID as productId,
-            p.actStatus,
-            p.price,
-            p.minBuyNumber,
-            p.maxBuyNumber,
-            p.priceFlag,
-            p.ladderPriceFlag,
-            p.normalPrice,
-            p.costPrice,
-            p.costProportional,
-            p.costCheckFlag,
-            p.step,
-            p.shopID as shopId,
-            p.includedTax,
-            p.invoiceType,
-            p.taxPoint as taxRate,
-            if(csp.id is not null,1,0) as svipProductFlag,
-            csp.priceType as svipPriceType,
-            csp.discount as svipDiscount,
-            csp.discountPrice as svipDiscountPrice,
-            p.productType,
-            p.newvalidFlag
+        p.productID as productId,
+        p.actStatus,
+        p.maxBuyNumber,
+        p.priceFlag,
+        p.step,
+        p.shopID as shopId,
+        p.includedTax,
+        p.invoiceType,
+        p.taxPoint as taxRate,
+        if(csp.id is not null,1,0) as svipProductFlag,
+        csp.priceType as svipPriceType,
+        csp.discount as svipDiscount,
+        csp.discountPrice as svipDiscountPrice,
+        p.productType,
+        p.newvalidFlag
         from product p
         left join cm_svip_product csp on p.productID = csp.productId
         where p.productID in
-          <foreach collection="productIds" open="(" separator="," close=")" item="productId">
-              #{productId}
-          </foreach>
+        <foreach collection="productIds" open="(" separator="," close=")" item="productId">
+            #{productId}
+        </foreach>
     </select>
     <select id="getLadderPricesByProductId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
-        select
-        	id, productId, ladderNum, buyNum, buyPrice
+        select id,
+               productId,
+               ladderNum,
+               buyNum,
+               buyPrice
         from product_ladder_price
-        where productId = #{productId} and userType = 3 and delFlag = 0
+        where skuId = #{skuId}
+          and userType = 3
+          and delFlag = 0
         order by ladderNum asc
     </select>
     <select id="findLowerLadderPrice" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
-        select
-        	id, productId, ladderNum, buyNum, buyPrice
+        select id,
+               skuId,
+               productId,
+               ladderNum,
+               buyNum,
+               buyPrice
         from product_ladder_price
-        where productId = #{productId} and userType = 3 and delFlag = 0
+        where skuId = #{skuId}
+          and userType = 3
+          and delFlag = 0
         order by ladderNum DESC
         limit 1
     </select>
     <select id="findMaxLadderPrice" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
-        select
-        	id, productId, ladderNum, buyNum, buyPrice
+        select id,
+               skuId,
+               productId,
+               ladderNum,
+               buyNum,
+               buyPrice
         from product_ladder_price
-        where productId = #{productId} and userType = 3 and delFlag = 0
+        where skuId = #{skuId}
+          and userType = 3
+          and delFlag = 0
         order by ladderNum asc
         limit 1
     </select>
     <select id="getRepurchasePrice" resultType="java.lang.Double">
-        select
-          r.currentPrice,p.productType
+        select r.currentPrice,
+               p.productType
         from repeat_purchase_price r
-        left join product p on p.productID = r.productId
-        where r.productId = #{productId} and userId = #{userId}
-        and ((p.costCheckFlag=1 and r.currentPrice <![CDATA[ >= ]]> p.costPrice) or p.costCheckFlag=2)
-        and p.price <![CDATA[ >= ]]> r.currentPrice
-        and r.delFlag = 0
+                 left join product p on p.productID = r.productId
+                 left join cm_sku cs on r.skuId = cs.skuId
+        where r.skuId = #{skuId}
+          and userId = #{userId}
+          and ((cs.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> cs.costPrice) or cs.costCheckFlag = 2)
+          and cs.price <![CDATA[ >= ]]> r.currentPrice
+          and r.delFlag = 0
     </select>
     <select id="getTaxByProductId" resultType="com.caimei365.commodity.model.vo.TaxVo">
-        select
-        p.includedTax as includedTax,
-        p.invoiceType as invoiceType,
-        p.taxPoint as taxPoint,
-        p.productType
+        select p.includedTax as includedTax,
+               p.invoiceType as invoiceType,
+               p.taxPoint    as taxPoint,
+               p.productType
         from product p
         where productID = #{productId}
     </select>
@@ -114,21 +119,21 @@
     </select>
 
     <select id="getProductSalesInfo" resultType="com.caimei365.commodity.model.vo.ProductSalesVo">
-        select p.productID AS productId,
-               p.name AS productName,
-               p.shopID AS shopId,
+        select p.productID    AS productId,
+               p.name         AS productName,
+               p.shopID       AS shopId,
                p.commodityType,
-               p.bigTypeID as bigTypeId,
-               p.smallTypeID as smallTypeId,
-               p.tinyTypeID as tinyTypeId,
-               s.productId AS id,
-               s.shop AS shopName,
+               p.bigTypeID    as bigTypeId,
+               p.smallTypeID  as smallTypeId,
+               p.tinyTypeID   as tinyTypeId,
+               s.productId    AS id,
+               s.shop         AS shopName,
                s.productCount AS productCount,
-               s.property AS property,
+               s.property     AS property,
                p.productType
         FROM product p
-        LEFT JOIN cm_product_sales s ON p.productID = s.productId
-        where p.productId=#{productId}
+                 LEFT JOIN cm_product_sales s ON p.productID = s.productId
+        where p.productId = #{productId}
     </select>
     <insert id="insertProductSales" parameterType="com.caimei365.commodity.model.vo.ProductSalesVo">
         INSERT INTO cm_product_sales(productId, product, shop, productCount, property)
@@ -147,9 +152,36 @@
         WHERE productId = #{productId}
     </update>
     <select id="getClubTypeById" resultType="java.lang.Integer">
-        SELECT firstClubType FROM club WHERE userID = #{userId}
+        SELECT firstClubType
+        FROM club
+        WHERE userID = #{userId}
     </select>
     <select id="getShopIdByUserId" resultType="java.lang.Integer">
-        SELECT shopID FROM shop WHERE userID = #{userId}
+        SELECT shopID
+        FROM shop
+        WHERE userID = #{userId}
+    </select>
+    <select id="findSkus" resultType="com.caimei365.commodity.model.dto.Sku">
+        select skuId,
+               price,
+               normalPrice,
+               costPrice,
+               ifnull(ladderPriceFlag,0) as ladderPriceFlag,
+               costCheckFlag,
+               costProportional,
+               stock,
+               unit,
+               minBuyNumber
+        from cm_sku
+        where productId = #{productId}
+        ORDER BY price ASC
+    </select>
+    <select id="findLowPrice" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
+        select plp.buyPrice,cs.unit
+        from product_ladder_price plp
+        left join cm_sku cs on plp.skuId=cs.skuId
+        where plp.productId = #{productId}
+        order by buyPrice asc
+        limit 1
     </select>
 </mapper>

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

@@ -70,6 +70,7 @@
     </select>
     <select id="getPromotionGifts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         select cpg.id      as id,
+               cpg.skuId   as giftSkuId,
                p.productID as productId,
                p.actStatus,
                p.shopID    as shopId,

+ 30 - 17
src/main/resources/mapper/SearchMapper.xml

@@ -7,10 +7,8 @@
         p.searchKey as p_keyword,
         p.tags as p_tags,
         p.mainImage as p_image,
-        p.price as p_price,
         p.priceFlag as p_price_flag,
         p.productCode as p_code,
-        p.unit as p_unit,
         br.id as p_brand_id,
         br.name as p_brand_name,
         p.shopID as p_supplier_id,
@@ -28,7 +26,9 @@
         DATE_FORMAT(p.ADDTIME,'%Y%m%d') as p_time,
         IFNULL(p.visibility,3) as p_visibility,
         ifnull(p.newvalidflag,0) as p_newvalidflag,
-        p.productType as p_product_type
+        p.productType as p_product_type,
+        (select unit from cm_sku where p.productID=#{productId} order by price asc LIMIT 1) as p_unit,
+        (select price from cm_sku where p.productID=#{productId} order by price asc LIMIT 1) as p_price
     </sql>
     <sql id="Product_Joins">
         left join tinytype as t on p.tinyTypeID = t.tinyTypeID
@@ -38,7 +38,8 @@
         left join shop as sh on p.shopID = sh.shopID
     </sql>
     <select id="searchProductById" resultType="com.caimei365.commodity.model.search.ProductDO">
-        select<include refid="Search_Product_List"/>
+        select
+        <include refid="Search_Product_List"/>
         from product p
         <include refid="Product_Joins"/>
         where p.validFlag in (2,3,9) and p.productCategory = 1
@@ -233,17 +234,23 @@
     <select id="findArticleCount" resultType="java.lang.Integer">
         select count(*)
         from info
-        where enabledStatus = 1 and auditStatus = 2 and onlineStatus = 2
+        where enabledStatus = 1
+          and auditStatus = 2
+          and onlineStatus = 2
     </select>
     <select id="findArticleInvalidCount" resultType="java.lang.Integer">
         select count(*)
         from info
-        where enabledStatus != 1 or auditStatus != 2 or onlineStatus != 2
+        where enabledStatus != 1
+           or auditStatus != 2
+           or onlineStatus != 2
     </select>
     <select id="findArticleInvalidIds" resultType="java.lang.Integer">
         select id
         from info
-        where enabledStatus != 1 or auditStatus != 2 or onlineStatus != 2
+        where enabledStatus != 1
+           or auditStatus != 2
+           or onlineStatus != 2
     </select>
     <select id="searchArticleList" resultType="com.caimei365.commodity.model.search.ArticleDO">
         select
@@ -468,7 +475,7 @@
             </if>
         </where>
 
-         order by a.pubdate desc
+        order by a.pubdate desc
 
     </select>
     <select id="getHistoryList" resultType="com.caimei365.commodity.model.po.SearchHistoryPo">
@@ -480,7 +487,8 @@
     <select id="getHistoryIdByWord" resultType="java.lang.Integer">
         select id
         from user_search_history
-        where searchWord = #{keyword} and userId = #{userId}
+        where searchWord = #{keyword}
+          and userId = #{userId}
         limit 1
     </select>
     <select id="getHistoryCount" resultType="java.lang.Integer">
@@ -576,7 +584,7 @@
     <select id="findPromotionId" resultType="java.lang.Integer">
         select pr.id
         from cm_promotions pr
-        left join cm_promotions_product prp on pr.id = prp.promotionsId
+                 left join cm_promotions_product prp on pr.id = prp.promotionsId
         where (prp.productId = #{p_id} or
                prp.supplierId = (select p.shopID from product p where p.productID = #{p_id})
             )
@@ -586,17 +594,22 @@
         limit 1
     </select>
     <select id="countViewsByDate" resultType="java.lang.Integer">
-        select IFNULL(sum(views),0) from cm_product_views_record where productId = #{productId} and viewTime > #{date}
+        select IFNULL(sum(views), 0)
+        from cm_product_views_record
+        where productId = #{productId}
+          and viewTime > #{date}
     </select>
     <select id="countSalesByDate" resultType="java.lang.Integer">
-        select IFNULL(sum(sales),0) from cm_product_sales_record where productId = #{productId} and saleTime > #{date}
+        select IFNULL(sum(sales), 0)
+        from cm_product_sales_record
+        where productId = #{productId}
+          and saleTime > #{date}
     </select>
     <select id="findPromotions" resultType="java.lang.Integer">
-        SELECT DISTINCT
-        cpp.productId
+        SELECT DISTINCT cpp.productId
         FROM cm_promotions cp
-        LEFT JOIN cm_promotions_product cpp ON cp.id=cpp.promotionsId
-        WHERE (cp.status=1 OR (cp.status=2 AND cp.endTime>NOW()))
-        AND cp.delFlag=0
+                 LEFT JOIN cm_promotions_product cpp ON cp.id = cpp.promotionsId
+        WHERE (cp.status = 1 OR (cp.status = 2 AND cp.endTime > NOW()))
+          AND cp.delFlag = 0
     </select>
 </mapper>

+ 158 - 140
src/main/resources/mapper/SecondHandMapper.xml

@@ -1,73 +1,84 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.commodity.mapper.SecondHandMapper">
-    <insert id="saveSencondHandProduct" parameterType="com.caimei365.commodity.model.po.ProductSecondPo" keyProperty="id" useGeneratedKeys="true">
-        insert into cm_second_hand_detail(
-			productID, sold, secondHandType, instrumentType, fixedYears, maturityYears, companyName, detailTalkFlag,
-			originalPrice, contactName, contactMobile, dockingPeopleName, dockingPeopleMobile, secondProductType,
-			townId, brandName, provinceCityDistrict, address, productQuality, productDetails, viewingNum, payStatus,
-			payAmount, payFormData, payType, payDate, submitDate, reviewedDate, onLineDate, source, publisher, authenticationImage,
-			fileName, ossName, commitmentImage,publishIdentity,licenseImage,authenticationBackImage
-		) values (
-			#{productId}, #{sold}, #{secondHandType}, #{instrumentType}, #{fixedYears}, #{maturityYears}, #{companyName},
-			#{detailTalkFlag}, #{originalPrice}, #{contactName}, #{contactMobile}, #{dockingPeopleName}, #{dockingPeopleMobile},
-			#{secondProductType}, #{townId}, #{brandName}, #{provinceCityDistrict}, #{address}, #{productQuality}, #{productDetails},
-			#{viewingNum}, #{payStatus}, #{payAmount}, #{payFormData}, #{payType}, #{payDate}, #{submitDate}, #{reviewedDate},
-			#{onLineDate}, #{source}, #{publisher}, #{authenticationImage}, #{fileName}, #{ossName}, #{commitmentImage},#{publishIdentity},
-			#{licenseImage},#{authenticationBackImage}
-		)
+    <insert id="saveSencondHandProduct" parameterType="com.caimei365.commodity.model.po.ProductSecondPo"
+            keyProperty="id" useGeneratedKeys="true">
+        insert into cm_second_hand_detail(productID, sold, secondHandType, instrumentType, fixedYears, maturityYears,
+                                          companyName, detailTalkFlag,
+                                          originalPrice, contactName, contactMobile, dockingPeopleName,
+                                          dockingPeopleMobile, secondProductType,
+                                          townId, brandName, provinceCityDistrict, address, productQuality,
+                                          productDetails, viewingNum, payStatus,
+                                          payAmount, payFormData, payType, payDate, submitDate, reviewedDate,
+                                          onLineDate, source, publisher, authenticationImage,
+                                          fileName, ossName, commitmentImage, publishIdentity, licenseImage,
+                                          authenticationBackImage)
+        values (#{productId}, #{sold}, #{secondHandType}, #{instrumentType}, #{fixedYears}, #{maturityYears},
+                #{companyName},
+                #{detailTalkFlag}, #{originalPrice}, #{contactName}, #{contactMobile}, #{dockingPeopleName},
+                #{dockingPeopleMobile},
+                #{secondProductType}, #{townId}, #{brandName}, #{provinceCityDistrict}, #{address}, #{productQuality},
+                #{productDetails},
+                #{viewingNum}, #{payStatus}, #{payAmount}, #{payFormData}, #{payType}, #{payDate}, #{submitDate},
+                #{reviewedDate},
+                #{onLineDate}, #{source}, #{publisher}, #{authenticationImage}, #{fileName}, #{ossName},
+                #{commitmentImage}, #{publishIdentity},
+                #{licenseImage}, #{authenticationBackImage})
     </insert>
     <insert id="insertProductImage" parameterType="com.caimei365.commodity.model.po.ProductImagePo">
         insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
         values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
     </insert>
-    <insert id="insertProduct" keyColumn="productID" keyProperty="productId" parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
-        insert into product (
-            brandId, name, price, stock, aliasName, normalPrice, mainImage, productCategory, preferredFlag, shopId,
-            sellNumber, costPrice, costCheckFlag, costProportional, hasSkuFlag, validFlag, ladderPriceFlag, sortIndex, featuredFlag, byFlag,
-            step, actFlag, actStatus, freePostFlag, productType, machineType, includedTax, recommendType, invoiceType,
-            visibility, addTime, updateTime, onlineTime, downlineTime,announType
-        ) values (
-            #{brandId}, #{name}, #{price}, #{stock}, #{aliasName}, #{normalPrice}, #{mainImage}, #{productCategory},
-            #{preferredFlag}, #{shopId}, #{sellNumber}, #{costPrice}, #{costCheckFlag}, #{costProportional}, #{hasSkuFlag}, #{validFlag},
-            #{ladderPriceFlag}, #{sortIndex}, #{featuredFlag}, #{byFlag}, #{step}, #{actFlag}, #{actStatus},
-            #{freePostFlag}, #{productType}, #{machineType}, #{includedTax}, #{recommendType}, #{invoiceType},
-            #{visibility}, #{addTime}, #{updateTime}, #{onlineTime}, #{offlineTime},#{announType}
-        )
+    <insert id="insertProduct" keyColumn="productID" keyProperty="productId"
+            parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
+        insert into product (brandId, name, aliasName, mainImage, productCategory, preferredFlag, shopId,
+                             sellNumber, hasSkuFlag, validFlag, sortIndex, featuredFlag, byFlag,
+                             step, actFlag, actStatus, freePostFlag, productType, machineType, includedTax,
+                             recommendType, invoiceType,
+                             visibility, addTime, updateTime, onlineTime, downlineTime, announType)
+        values (#{brandId}, #{name}, #{aliasName}, #{mainImage}, #{productCategory},
+                #{preferredFlag}, #{shopId}, #{sellNumber}, #{hasSkuFlag}, #{validFlag},
+                #{sortIndex}, #{featuredFlag}, #{byFlag}, #{step}, #{actFlag}, #{actStatus},
+                #{freePostFlag}, #{productType}, #{machineType}, #{includedTax}, #{recommendType}, #{invoiceType},
+                #{visibility}, #{addTime}, #{updateTime}, #{onlineTime}, #{offlineTime}, #{announType})
     </insert>
     <insert id="insertSecondFileType">
         insert into cm_second_file_type
-        (fileType,secondId,productId)
-        values (#{fileType},#{secondId},#{productId})
+            (fileType, secondId, productId)
+        values (#{fileType}, #{secondId}, #{productId})
     </insert>
-    <insert id="insertShop" keyColumn="shopID" keyProperty="shopId" parameterType="com.caimei365.commodity.model.vo.ShopVo" useGeneratedKeys="true">
-        insert into shop (name,linkMan,contractMobile,cardNumber,accountType,banOfDeposit,accountName,addTime,status,shopType)
-        values (#{name},#{linkMan},#{contractMobile},#{cardNumber},#{accountType},#{banOfDeposit},#{accountName},now(),90,0)
+    <insert id="insertShop" keyColumn="shopID" keyProperty="shopId"
+            parameterType="com.caimei365.commodity.model.vo.ShopVo" useGeneratedKeys="true">
+        insert into shop (name, linkMan, contractMobile, cardNumber, accountType, banOfDeposit, accountName, addTime,
+                          status, shopType)
+        values (#{name}, #{linkMan}, #{contractMobile}, #{cardNumber}, #{accountType}, #{banOfDeposit}, #{accountName},
+                now(), 90, 0)
     </insert>
     <update id="updateSecondHandViews">
-        UPDATE cm_second_hand_detail SET viewingNum = #{viewingNum}
+        UPDATE cm_second_hand_detail
+        SET viewingNum = #{viewingNum}
         WHERE productID = #{productId}
     </update>
     <select id="getSeconHandList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
         select
-            p.productID as productId,
-            p.actStatus,
-            p.`name` as name,
-            p.mainImage as image,
-            p.price,
-            p.brandID as brandId,
-	        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
-	        cshd.sold as "sold",
-	        cshd.detailTalkFlag as "detailTalkFlag",
-	        cshd.onLineDate as "onLineDate",
-	        cshd.viewingNum as "viewingNum",
-	        cshd.provinceCityDistrict as "provinceCityDistrict"
+        p.productID as productId,
+        p.actStatus,
+        p.`name` as name,
+        p.mainImage as image,
+        p.price,
+        p.brandID as brandId,
+        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
+        cshd.sold as "sold",
+        cshd.detailTalkFlag as "detailTalkFlag",
+        cshd.onLineDate as "onLineDate",
+        cshd.viewingNum as "viewingNum",
+        cshd.provinceCityDistrict as "provinceCityDistrict"
         from
-            product p
+        product p
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_brand cb on cb.id = p.brandID
         where
-            p.productCategory = 2 and p.validFlag = 2
+        p.productCategory = 2 and p.validFlag = 2
         <if test="secondHandType != null and secondHandType != ''">
             and cshd.secondHandType = #{secondHandType}
         </if>
@@ -89,103 +100,105 @@
         order by cshd.sold, cshd.onLineDate desc
     </select>
     <select id="getSecondHandDetail" resultType="com.caimei365.commodity.model.vo.SecondDetailVo">
-        select
-            p.productID as productId,
-            p.actStatus,
-            p.`name` as name,
-            p.mainImage as image,
-            p.price,
-            p.normalPrice,
-            p.productType,
-            p.stock,
-            p.brandID as brandId,
-            p.visibility as visibility,
-	        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
-	        cb.description as "brandInfo",
-	        cshd.originalPrice,
-	        cshd.sold,
-	        cshd.detailTalkFlag,
-	        cshd.onLineDate,
-	        cshd.viewingNum,
-	        cshd.provinceCityDistrict,
-            cshd.productDetails,
-            cshd.productQuality,
-            cshd.secondHandType,
-            ifnull(cshd.instrumentType,0) as instrumentType,
-            cshd.showContactFlag,
-            cshd.contactMobile,
-            cshd.contactName,
-            cshd.fixedYears,
-            cshd.maturityYears,
-            cshd.publishIdentity,
-            cshd.companyName
+        select p.productID                                   as productId,
+               p.actStatus,
+               p.`name`                                      as name,
+               p.mainImage                                   as image,
+               p.price,
+               p.normalPrice,
+               p.productType,
+               p.stock,
+               p.brandID                                     as brandId,
+               p.visibility                                  as visibility,
+               IF(p.brandID != 161, cb.name, cshd.brandName) as "brandName",
+               cb.description                                as "brandInfo",
+               cshd.originalPrice,
+               cshd.sold,
+               cshd.detailTalkFlag,
+               cshd.onLineDate,
+               cshd.viewingNum,
+               cshd.provinceCityDistrict,
+               cshd.productDetails,
+               cshd.productQuality,
+               cshd.secondHandType,
+               ifnull(cshd.instrumentType, 0)                as instrumentType,
+               cshd.showContactFlag,
+               cshd.contactMobile,
+               cshd.contactName,
+               cshd.fixedYears,
+               cshd.maturityYears,
+               cshd.publishIdentity,
+               cshd.companyName
         from product p
-        left join cm_second_hand_detail cshd on p.productID = cshd.productID
-        left join cm_brand cb on cb.id = p.brandID
-        where p.productCategory = 2 and p.productID = #{productId}
+                 left join cm_second_hand_detail cshd on p.productID = cshd.productID
+                 left join cm_brand cb on cb.id = p.brandID
+        where p.productCategory = 2
+          and p.productID = #{productId}
     </select>
     <select id="getImageByProductId" resultType="java.lang.String">
-        select image from productimage
+        select image
+        from productimage
         where productID = #{productId}
         order by mainFlag desc
     </select>
     <select id="getAddressInfo" resultType="com.caimei365.commodity.model.vo.AddressVo">
-        select a.name as "province"
-        ,b.name as "city"
-        ,c.name as "town"
-        ,c.townId as "townID"
+        select a.name   as "province"
+             , b.name   as "city"
+             , c.name   as "town"
+             , c.townId as "townID"
         from province a
-        right join city b on a.provinceId = b.provinceId
-        right join town c on b.cityId = c.cityId where c.townId = #{townId}
+                 right join city b on a.provinceId = b.provinceId
+                 right join town c on b.cityId = c.cityId
+        where c.townId = #{townId}
     </select>
     <select id="getOrderPageSecondList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
         select
-            p.productID as productId,
-            p.actStatus,
-            p.`name` as name,
-            p.mainImage as image,
-            p.price,
-            p.brandID as brandId,
-	        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
-	        cshd.sold as "sold",
-	        cshd.detailTalkFlag as "detailTalkFlag",
-	        cshd.onLineDate as "onLineDate",
-	        cshd.viewingNum as "viewingNum",
-	        cshd.provinceCityDistrict as "provinceCityDistrict"
+        p.productID as productId,
+        p.actStatus,
+        p.`name` as name,
+        p.mainImage as image,
+        p.price,
+        p.brandID as brandId,
+        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
+        cshd.sold as "sold",
+        cshd.detailTalkFlag as "detailTalkFlag",
+        cshd.onLineDate as "onLineDate",
+        cshd.viewingNum as "viewingNum",
+        cshd.provinceCityDistrict as "provinceCityDistrict"
         from
-            product p
+        product p
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_brand cb on cb.id = p.brandID
         where
-            p.productCategory = 2 and p.validFlag = 2
-            <if test="secondHandType != null and secondHandType != ''">
+        p.productCategory = 2 and p.validFlag = 2
+        <if test="secondHandType != null and secondHandType != ''">
             and cshd.secondHandType = #{secondHandType}
-            </if>
-            <if test="instrumentType != null and instrumentType != ''">
-            and cshd.instrumentType  like CONCAT('%',#{instrumentType},'%')
-            </if>
-            <if test="searchKeyword != null and searchKeyword != ''">
+        </if>
+        <if test="instrumentType != null and instrumentType != ''">
+            and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
+        </if>
+        <if test="searchKeyword != null and searchKeyword != ''">
             and p.name like CONCAT('%',#{searchKeyword},'%')
-            </if>
-            and cshd.sold != 1
-            order by cshd.onLineDate desc
+        </if>
+        and cshd.sold != 1
+        order by cshd.onLineDate desc
     </select>
     <select id="getSecondListByLimit" resultType="com.caimei365.commodity.model.vo.SecondListVo">
         select
-            p.productID as productId,
-            p.actStatus,
-            p.`name` as name,
-            p.mainImage as image,
-            p.price,
-            p.brandID as brandId,
-	        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
-	        cshd.sold as "sold",
-	        cshd.detailTalkFlag as "detailTalkFlag",
-	        cshd.onLineDate as "onLineDate",
-	        cshd.viewingNum as "viewingNum",
-	        cshd.provinceCityDistrict as "provinceCityDistrict"
+        p.productID as productId,
+        p.actStatus,
+        p.`name` as name,
+        p.mainImage as image,
+        p.price,
+        p.brandID as brandId,
+        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
+        cshd.sold as "sold",
+        cshd.detailTalkFlag as "detailTalkFlag",
+        cshd.onLineDate as "onLineDate",
+        cshd.viewingNum as "viewingNum",
+        cshd.provinceCityDistrict as "provinceCityDistrict"
         from
-            product p
+        product p
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_brand cb on cb.id = p.brandID
         where p.productCategory = 2 and p.validFlag = 2
@@ -198,28 +211,33 @@
     <select id="getBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
         select id, name
         from cm_brand
-		where status = '1' and delFlag = '0' and description is not null and description != '' and id not in (161)
-		order by sort
+        where status = '1'
+          and delFlag = '0'
+          and description is not null
+          and description != ''
+          and id not in (161)
+        order by sort
     </select>
     <select id="getSecondRecommends" resultType="com.caimei365.commodity.model.vo.SecondListVo">
-        select
-        p.productID as productId,
-        p.actStatus,
-        p.`name` as name,
-        p.mainImage as image,
-        p.price,
-        p.brandID as brandId,
-        cb.name as "brandName"
+        select p.productID as productId,
+               p.actStatus,
+               p.`name`    as name,
+               p.mainImage as image,
+               p.price,
+               p.brandID   as brandId,
+               cb.name     as "brandName"
         from product p
-        left join cm_second_hand_recommend cshr on p.productID = cshr.recommendProductID
-        left join cm_brand cb on cb.id = p.brandID
-        where p.validFlag = 2 and cshr.delFlag = 0
-        and cshr.secondHandProductID = #{productId}
+                 left join cm_second_hand_recommend cshr on p.productID = cshr.recommendProductID
+                 left join cm_brand cb on cb.id = p.brandID
+        where p.validFlag = 2
+          and cshr.delFlag = 0
+          and cshr.secondHandProductID = #{productId}
         order by cshr.sort desc
     </select>
     <select id="findSecondShop" resultType="java.lang.Integer">
-        select shopId from shop
+        select shopId
+        from shop
         where shopType = 3
-        AND cardNumber = #{cardNumber}
+          AND cardNumber = #{cardNumber}
     </select>
 </mapper>

+ 0 - 11
src/main/resources/mapper/SellerMapper.xml

@@ -53,15 +53,9 @@
             p.actStatus,
             p.name,
             p.aliasName,
-            p.unit,
             p.productCode as code,
             p.priceFlag as priceFlag,
-            p.price as price,
             p.shopID as shopId,
-            p.minBuyNumber as minBuyNumber,
-            p.maxBuyNumber as maxBuyNumber,
-            p.ladderPriceFlag,
-            p.normalPrice,
             p.step,
             p.shopID as shopId,
             p.includedTax,
@@ -98,16 +92,11 @@
         p.aliasName,
         p.visibility,
         p.mainImage as image,
-        p.unit,
         p.productCode as code,
         p.priceFlag,
-        p.price,
         p.shopID as shopId,
         p.searchKey as keyword,
-        p.minBuyNumber as minBuyNumber,
         p.maxBuyNumber as maxBuyNumber,
-        p.ladderPriceFlag,
-        p.normalPrice,
         p.step,
         p.shopID as shopId,
         p.taxPoint as taxRate,

+ 58 - 50
src/main/resources/mapper/ShopMapper.xml

@@ -5,7 +5,7 @@
             parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
         insert into product (
         shopID, name, aliasName, commodityType, bigTypeID, smallTypeID, tinyTypeID, mainImage,
-        brandID, productType, tags, unit, normalPrice, price, includedTax, minBuyNumber, stock,
+        brandID, productType, tags, includedTax,
         <if test="productCategory != null and  productCategory != '' ">
             productCategory,
         </if>
@@ -30,9 +30,6 @@
         <if test="featuredFlag != null and  featuredFlag != ''">
             featuredFlag,
         </if>
-        <if test="costCheckFlag != null and  costCheckFlag != ''">
-            costCheckFlag,
-        </if>
         <if test="recommendType != null and  recommendType != ''">
             recommendType,
         </if>
@@ -42,9 +39,6 @@
         <if test="actFlag != null and  actFlag != ''">
             actFlag,
         </if>
-        <if test="ladderPriceFlag != null and  ladderPriceFlag != ''">
-            ladderPriceFlag,
-        </if>
         <if test="visibility != null and  visibility != ''">
             visibility,
         </if>
@@ -63,9 +57,6 @@
         <if test="step != null and  step != ''">
             step,
         </if>
-        <if test="costPrice != null and  costPrice != ''">
-            costPrice,
-        </if>
         <if test="provinceIds != null and  provinceIds != ''">
             provinceIds,
         </if>
@@ -87,12 +78,10 @@
         <if test="qualificationTime != null and  qualificationTime != ''">
             qualificationTime,
         </if>
-
         updateTime,validFlag,newProductType,showFlag,newvalidFlag
         ) values (
         #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
-        #{brandId}, #{productType}, #{tags}, #{unit}, #{normalPrice}, #{price}, #{includedTax}, #{minBuyNumber},
-        #{stock},
+        #{brandId}, #{productType}, #{tags}, #{includedTax},
         <if test="productCategory != null and  productCategory != '' ">
             #{productCategory},
         </if>
@@ -117,9 +106,6 @@
         <if test="featuredFlag != null and  featuredFlag != ''">
             #{featuredFlag},
         </if>
-        <if test="costCheckFlag != null and  costCheckFlag != ''">
-            #{costCheckFlag},
-        </if>
         <if test="recommendType != null and  recommendType != ''">
             #{recommendType},
         </if>
@@ -129,9 +115,6 @@
         <if test="actFlag != null and  actFlag != ''">
             #{actFlag},
         </if>
-        <if test="ladderPriceFlag != null and  ladderPriceFlag != ''">
-            #{ladderPriceFlag},
-        </if>
         <if test="visibility != null and  visibility != ''">
             #{visibility},
         </if>
@@ -150,9 +133,6 @@
         <if test="step != null and  step != ''">
             #{step},
         </if>
-        <if test="costPrice != null and  costPrice != ''">
-            #{costPrice},
-        </if>
         <if test="provinceIds != null and  provinceIds != ''">
             #{provinceIds},
         </if>
@@ -181,11 +161,7 @@
         update product set
         shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
         bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
-        brandId = #{brandId}, productType = #{productType}, tags = #{tags}, unit = #{unit}, normalPrice =
-        #{normalPrice},
-        price = #{price}, price = #{price}, includedTax = #{includedTax}, minBuyNumber = #{minBuyNumber}, stock
-        =#{stock},
-        newProductType=#{newProductType},
+        brandId = #{brandId}, productType = #{productType}, tags = #{tags}, includedTax = #{includedTax},newProductType=#{newProductType},
         <if test="qualificationNo !=null and qualificationNo != ''">
             qualificationNo=#{qualificationNo},
         </if>
@@ -198,7 +174,6 @@
         <if test="qualificationLink !=null and qualificationLink != ''">
             qualificationLink=#{qualificationLink},
         </if>
-
         <if test="productCategory != null and  productCategory != ''">
             productCategory = #{productCategory},
         </if>
@@ -226,9 +201,6 @@
         <if test="featuredFlag != null and  featuredFlag != ''">
             featuredFlag = #{featuredFlag},
         </if>
-        <if test="costCheckFlag != null and  costCheckFlag != ''">
-            costCheckFlag = #{costCheckFlag},
-        </if>
         <if test="recommendType != null and  recommendType != ''">
             recommendType = #{recommendType},
         </if>
@@ -238,9 +210,6 @@
         <if test="actFlag != null and  actFlag != ''">
             actFlag = #{actFlag},
         </if>
-        <if test="ladderPriceFlag != null and  ladderPriceFlag != ''">
-            ladderPriceFlag = #{ladderPriceFlag},
-        </if>
         <if test="visibility != null and  visibility != ''">
             visibility = #{visibility},
         </if>
@@ -259,9 +228,6 @@
         <if test="step != null and  step != ''">
             step = #{step},
         </if>
-        <if test="costPrice != null and  costPrice != ''">
-            costPrice = #{costPrice},
-        </if>
         <if test="provinceIds != null and  provinceIds != ''">
             provinceIds = #{provinceIds},
         </if>
@@ -301,6 +267,27 @@
         values (#{name}, #{source}, #{userId}, #{status}, #{delFlag}, #{createDate}, #{updateDate}, #{logo},
                 #{description})
     </insert>
+    <insert id="insertSku">
+        insert into cm_sku
+        (productId,
+         normalPrice,
+         price,
+         costCheckFlag,
+         costprice,
+         stock,
+         minBuyNumber,
+         unit,
+         ladderPriceFlag)
+        values (#{productId},
+                #{normalPrice},
+                #{price},
+                ifnull(#{costCheckFlag}, 1),
+                #{costPrice},
+                #{stock},
+                #{minBuyNumber},
+                #{unit},
+                ifnull(#{ladderPriceFlag}, 0))
+    </insert>
     <update id="updateBrand">
         update cm_brand
         <set>
@@ -370,6 +357,16 @@
         set productCode = #{productCode}
         where productID = #{productId}
     </update>
+    <update id="updateSku">
+        update cm_sku
+        set minBuyNumber=#{minBuyNumber},
+            costPrice=#{costPrice},
+            stock=#{stock},
+            price=#{price},
+            normalPrice=#{normalPrice},
+            unit=#{unit}
+        where skuId = #{skuId}
+    </update>
     <delete id="deleteProductImage">
         delete
         from productimage
@@ -402,21 +399,21 @@
         order by p.productID desc limit 4
     </select>
     <select id="getShopProductsSelect" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
-        select
+        select DISTINCT
         p.productID as productId,
         p.actStatus,
         p.name,
         p.aliasName,
         p.mainImage as image,
-        p.unit,
+        (select unit from cm_sku where productId=p.productId order by price asc LIMIT 1) as unit,
         p.productCode as code,
         p.priceFlag,
-        p.price,
+        (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,
         p.searchKey as keyword,
-        p.minBuyNumber as minBuyNumber,
+        (select minBuyNumber from cm_sku where productId=p.productId order by price asc LIMIT 1) as minBuyNumber,
         p.maxBuyNumber as maxBuyNumber,
-        p.ladderPriceFlag,
-        p.normalPrice,
+        (select ladderPriceFlag from cm_sku where productId=p.productId order by price asc LIMIT 1) as ladderPriceFlag,
         p.step,
         p.shopID as shopId,
         p.taxPoint as taxRate,
@@ -560,10 +557,10 @@
                trainingType,
                trainingFee,
                ifnull(newProductType, 2) as newProductType,
-                qualificationNo as qualificationNo,
-                productName as productName,
-               qualificationTime as qualificationTime,
-               qualificationLink as qualificationLink
+               qualificationNo           as qualificationNo,
+               productName               as productName,
+               qualificationTime         as qualificationTime,
+               qualificationLink         as qualificationLink
         from product
         where productID = #{productId}
     </select>
@@ -715,15 +712,26 @@
     </select>
 
     <select id="listingFee" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID}
+        SELECT COUNT(*)
+        FROM `cm_discern_receipt`
+        WHERE newReceiptType = 1
+          AND shopID = #{shopID}
     </select>
 
     <select id="listingfeeExpire" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND NOW()> DATE_ADD(receiptDate, INTERVAL 1 YEAR)
+        SELECT COUNT(*)
+        FROM `cm_discern_receipt`
+        WHERE newReceiptType = 1
+          AND shopID = #{shopID}
+          AND NOW() > DATE_ADD(receiptDate, INTERVAL 1 YEAR)
     </select>
 
     <select id="receStatct" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND receStatct=2
+        SELECT COUNT(*)
+        FROM `cm_discern_receipt`
+        WHERE newReceiptType = 1
+          AND shopID = #{shopID}
+          AND receStatct = 2
     </select>
 
 </mapper>

+ 1 - 6
src/main/resources/mapper/UserLikeMapper.xml

@@ -38,15 +38,10 @@
                p.name,
                p.aliasName,
                p.mainImage       AS image,
-               p.unit,
                p.productCode     AS CODE,
                p.priceFlag,
-               p.price,
                p.searchKey       AS keyword,
-               p.minBuyNumber    AS minBuyNumber,
                p.maxBuyNumber    AS maxBuyNumber,
-               p.ladderPriceFlag,
-               p.normalPrice,
                p.step,
                p.shopID          AS shopId,
                p.taxPoint        AS taxRate,
@@ -62,7 +57,7 @@
                p.visibility      AS visibility,
                p.productType
         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'
           AND cpu.userLike = '1'
           AND cpu.userID = #{userId}