Browse Source

sku相关

zhijiezhao 2 years ago
parent
commit
a5e0fbcb34

+ 2 - 0
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -267,6 +267,7 @@ public class PriceUtilService {
             ProductItemVo showProduct = priceMapper.findLowPrice(product.getProductId());
             product.setSkuId(showProduct.getSkuId());
             product.setPrice(showProduct.getPrice());
+            product.setOriginalPrice(showProduct.getPrice());
             product.setUnit(showProduct.getUnit());
             product.setMinBuyNumber(showProduct.getMinBuyNumber());
             product.setPriceGrade(getPriceGrade(showProduct.getPrice()));
@@ -274,6 +275,7 @@ public class PriceUtilService {
             List<Sku> collect = skus.stream().sorted(Comparator.comparing(Sku::getPrice)).collect(Collectors.toList());
             product.setSkuId(collect.get(0).getSkuId());
             product.setPrice(collect.get(0).getPrice());
+            product.setOriginalPrice(collect.get(0).getPrice());
             product.setUnit(collect.get(0).getUnit());
             product.setMinBuyNumber(collect.get(0).getMinBuyNumber());
             product.setPriceGrade(getPriceGrade(collect.get(0).getPrice()));

+ 1 - 1
src/main/java/com/caimei365/commodity/controller/ProductPriceApi.java

@@ -87,7 +87,7 @@ public class ProductPriceApi {
      * 更新商品销量
      *
      * @param productSalesDto {productInfo: [ // 商品id,数量
-     *                        {"productId": 2789, "productCount": 1},
+     *                        {"skuId": 2789, "productCount": 1},
      *                        {"productId": 2790, "productCount": 2}
      *                        ]
      *                        }

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

@@ -18,6 +18,10 @@ public class PriceVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
     private List<Sku> skus;
+    /**
+     * 展示的最低市场价
+     */
+    private Double normalPrice;
     /**
      * 展示的sku的skuId
      */

+ 4 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductDetailVo.java

@@ -23,6 +23,10 @@ import java.util.List;
 @Data
 public class ProductDetailVo implements Serializable {
     private static final long serialVersionUID = 1L;
+    /**
+     * 展示的最低市场价
+     */
+    private Double normalPrice;
     /**
      * 展示的sku的skuId
      */

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

@@ -186,6 +186,7 @@ public class PageServiceImpl implements PageService {
             }
             pageFloorList.forEach(po -> po.setFloorImageList4(floorImageLists));
         }
+        log.info("pagefloorlist-----------------------"+pageFloorList);
         map.put("pageFloorList", pageFloorList);
 
         // 优质供应商
@@ -1028,7 +1029,6 @@ public class PageServiceImpl implements PageService {
                         //优惠券标识
                         Boolean couponsLogo = setCouponsLogo(userId, image.getProductId(), source);
                         product.setCouponsLogo(couponsLogo);
-
                         image.setProduct(product);
                     }
                 } else {

+ 12 - 7
src/main/java/com/caimei365/commodity/service/impl/SellerServiceImpl.java

@@ -11,6 +11,7 @@ import com.caimei365.commodity.model.vo.ProductItemVo;
 import com.caimei365.commodity.service.PageService;
 import com.caimei365.commodity.service.SellerService;
 import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -27,6 +28,7 @@ import java.util.concurrent.atomic.AtomicReference;
  * @date : 2021/4/23
  */
 @Service
+@Slf4j
 public class SellerServiceImpl implements SellerService {
     @Value("${caimei.wwwDomain}")
     private String domain;
@@ -109,8 +111,18 @@ public class SellerServiceImpl implements SellerService {
         PaginationVo<ProductItemVo> productItemVoPaginationVo = new PaginationVo<>(productList);
         if (combinationId != null) {
             List<Integer> productIdList = sellerMapper.findProductList(combinationId);
+            List<Integer> p = new ArrayList<>();
+            p.add(productId);
+            List<ProductItemVo> pd = sellerMapper.getProductList(p);
+            ProductItemVo productItemVo = new ProductItemVo();
+            if (pd != null && pd.size() > 0) {
+                productItemVo = pd.get(0);
+            }
             PageHelper.startPage(pageNum, pageSize);
             productList = sellerMapper.getProductList(productIdList);
+            //本商品设置首位
+            productList.remove(productItemVo);
+            productList.add(0, productItemVo);
             Integer userIdentity = shopMapper.getUserIdentityById(userId);
             // 如果非会员身份剔除会员可见商品
             if (userIdentity != null) {
@@ -118,20 +130,13 @@ public class SellerServiceImpl implements SellerService {
                     productList.removeIf(c -> "1".equals(c.getVisibility()));
                 }
             }
-            AtomicReference<ProductItemVo> item = new AtomicReference<>(new ProductItemVo());
             productList.forEach(product -> {
                 // 设置商品主图及价格
                 priceUtilService.setProductDetails(userId, product);
                 //优惠券标识
                 Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), source);
                 product.setCouponsLogo(couponsLogo);
-                if (productId.equals(product.getProductId())) {
-                    item.set(product);
-                }
             });
-            //本商品设置首位
-            productList.removeIf(productItemVo -> productItemVo.getProductId().equals(productId));
-            productList.add(0, item.get());
             productItemVoPaginationVo = new PaginationVo<>(productList);
         }
         return ResponseJson.success(productItemVoPaginationVo);

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

@@ -157,15 +157,16 @@
                p.name,
                p.aliasName,
                p.mainImage         as image,
-               p.unit,
                p.productCode       as code,
                p.priceFlag,
-               p.price,
+               (select unit from cm_sku where p.productID=#{productId} order by price asc LIMIT 1) as unit,
+               (select price from cm_sku where p.productID=#{productId} order by price asc LIMIT 1) as price,
+               (select price from cm_sku where p.productID=#{productId} order by price asc LIMIT 1) as originalPrice,
                p.shopID            as shopId,
                p.searchKey         as keyword,
-               p.minBuyNumber      as minBuyNumber,
+               (select minBuyNumber from cm_sku where p.productID=#{productId} order by price asc LIMIT 1) as minBuyNumber,
                p.maxBuyNumber      as maxBuyNumber,
-               p.ladderPriceFlag,
+               (select ladderPriceFlag from cm_sku where p.productID=#{productId} order by price asc LIMIT 1) as ladderPriceFlag,
                p.normalPrice,
                p.step,
                p.shopID            as shopId,
@@ -183,7 +184,7 @@
                cshd.detailTalkFlag as detailTalkFlag,
                p.productType
         from product p
-                 left join cm_second_hand_detail cshd on p.productID = cshd.productID
+        left join cm_second_hand_detail cshd on p.productID = cshd.productID
         where p.productID = #{productId}
           and p.validFlag = 2
     </select>
@@ -211,6 +212,7 @@
     <select id="getProductDetails" resultType="com.caimei365.commodity.model.vo.ProductDetailVo">
         select p.productID         as productId,
                p.shopID            as shopId,
+               (select normalPrice from cm_sku where productId=#{productId} order by price asc limit 1) as normalPrice,
                p.name,
                p.aliasName,
                p.commodityType,
@@ -942,15 +944,11 @@
         p.aliasName,
         p.visibility,
         p.mainImage as image,
-        p.unit,
         p.productCode as code,
         p.priceFlag,
         p.shopID as shopId,
         p.searchKey as keyword,
-        p.minBuyNumber as minBuyNumber,
-        p.maxBuyNumber as maxBuyNumber,
-        p.ladderPriceFlag,
-        p.normalPrice,
+        p.maxBuyNumber      as maxBuyNumber,
         p.step,
         p.taxPoint as taxRate,
         p.includedTax,
@@ -963,8 +961,7 @@
         p.smallTypeID as smallTypeId,
         p.tinyTypeID as tinyTypeId,
         p.productType,
-        p.brandID,
-        p.price
+        p.brandID
         from product p
         <where>
             and p.showFlag!=5

+ 2 - 1
src/main/resources/mapper/PriceMapper.xml

@@ -9,6 +9,7 @@
     <select id="getDetailPrice" resultType="com.caimei365.commodity.model.vo.PriceVo">
         select p.productID                  as productId,
                p.actStatus,
+               (select normalPrice from cm_sku where productId=#{productId} order by price asc limit 1) as normalPrice,
                p.maxBuyNumber,
                p.priceFlag,
                p.step,
@@ -179,7 +180,7 @@
     <select id="findLowPrice" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         select plp.buyPrice as price, cs.unit as unit, cs.minBuyNumber as minBuyNumber, cs.skuId as skuId
         from product_ladder_price plp
-                 left join cm_sku cs on plp.skuId = cs.skuId
+        left join cm_sku cs on plp.skuId = cs.skuId
         where plp.productId = #{productId}
         order by buyPrice asc
         limit 1