Browse Source

采美sku bugfix

zhijiezhao 2 years ago
parent
commit
cd0d1f07f8

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

@@ -201,6 +201,8 @@ public class PriceUtilService {
                             }
                             s.setLadderPriceList(ladderPrices);
                             price.setLadderPriceFlag(1);
+                            price.setPrice(lowerPrice.getBuyPrice());
+                            price.setMinBuyNumber(lowerPrice.getBuyNum());
                         } else {
                             price.setLadderPriceFlag(0);
                             // 复购价

+ 5 - 5
src/main/java/com/caimei365/commodity/service/impl/HeheServiceImpl.java

@@ -249,12 +249,12 @@ public class HeheServiceImpl implements HeheService {
         boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
         if (addTaxFlag) {
             // 售价税费
-            BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
-            BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
+            BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(sku.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+            BigDecimal price = MathUtil.add(sku.getPrice(), addedValueTax);
             sku.setPrice(price);
             // 原价税费
-            addedValueTax = MathUtil.div(MathUtil.mul(product.getNormalPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
-            price = MathUtil.add(product.getNormalPrice(), addedValueTax);
+            addedValueTax = MathUtil.div(MathUtil.mul(sku.getNormalPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+            price = MathUtil.add(sku.getNormalPrice(), addedValueTax);
             sku.setNormalPrice(price);
         }
         // 查询用户的注册时间
@@ -275,7 +275,7 @@ public class HeheServiceImpl implements HeheService {
         if (couponList.size() > 0) {
             // 有可用优惠券
             couponList.forEach(coupon -> {
-                if (1 == coupon.getNoThresholdFlag() || MathUtil.compare(product.getPrice(), coupon.getTouchPrice()) >= 0) {
+                if (1 == coupon.getNoThresholdFlag() || MathUtil.compare(sku.getPrice(), coupon.getTouchPrice()) >= 0) {
                     ableCouponList.add(coupon);
                 } else {
                     unableCouponList.add(coupon);

+ 6 - 3
src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java

@@ -213,7 +213,7 @@ public class ShopServiceImpl implements ShopService {
             return ResponseJson.error("参数异常:商品sku不能为空!", null);
         }
         List<Sku> skus = JSON.parseArray(productDto.getSkus(), Sku.class);
-        skus.forEach(s->{
+        skus.forEach(s -> {
             Assert.notNull(s.getCostPrice(), "结算价不能为空!");
             Assert.notNull(s.getNormalPrice(), "市场价不能为空!");
             Assert.notNull(s.getPrice(), "售价不能为空!");
@@ -222,7 +222,6 @@ public class ShopServiceImpl implements ShopService {
         });
 
 
-
         JSONObject parseObject = JSON.parseObject(productDto.getParams());
         //图片
         List<Map<String, String>> imageList = (List<Map<String, String>>) parseObject.get("image");
@@ -361,7 +360,11 @@ public class ShopServiceImpl implements ShopService {
     public void updateSkus(List<Sku> skus, Integer productId) {
         skus.forEach(s -> {
             s.setProductId(productId);
-            shopMapper.updateSku(s);
+            if (null != s.getSkuId()) {
+                shopMapper.updateSku(s);
+            } else {
+                shopMapper.insertSku(s);
+            }
         });
     }
 

+ 34 - 15
src/main/resources/mapper/HeheMapper.xml

@@ -64,10 +64,10 @@
             order by rand()
         </if>
         <if test="sortType == 2">
-            order by chp.price
+            order by price
         </if>
         <if test="sortType == 3">
-            order by chp.price desc
+            order by price desc
         </if>
         <if test="sortType == 4">
             order by chp.id desc
@@ -77,19 +77,33 @@
     <select id="getProduct" resultType="com.caimei365.commodity.model.vo.HeheProductVo">
         SELECT chp.productId,
                (select price from cm_hehe_sku where productId = chp.productId order by price asc limit 1) as price,
-               (select price from cm_hehe_sku where productId = chp.productId order by price asc limit 1) as normalPrice,
-               (select unit from cm_sku cs left join cm_hehe_sku chs on cs.skuId=chs.skuId where cs.productId = chp.productId order by chs.price asc limit 1) as unit,
-               (select stock from cm_sku cs left join cm_hehe_sku chs on cs.skuId=chs.skuId where cs.productId = chp.productId order by chs.price asc limit 1) as stock,
+               (select price
+                from cm_hehe_sku
+                where productId = chp.productId
+                order by price asc
+                limit 1)                                                                                  as normalPrice,
+               (select unit
+                from cm_sku cs
+                         left join cm_hehe_sku chs on cs.skuId = chs.skuId
+                where cs.productId = chp.productId
+                order by chs.price asc
+                limit 1)                                                                                  as unit,
+               (select stock
+                from cm_sku cs
+                         left join cm_hehe_sku chs on cs.skuId = chs.skuId
+                where cs.productId = chp.productId
+                order by chs.price asc
+                limit 1)                                                                                  as stock,
                chp.includedTax,
                chp.invoiceType,
                chp.clubTaxPoint,
                p.name,
                p.mainImage,
-               cb.name        as "brandName",
+               cb.name                                                                                    as "brandName",
                p.tags
         FROM cm_hehe_product chp
-        LEFT JOIN product p ON chp.productId = p.productID
-        LEFT JOIN cm_brand cb on p.brandID = cb.id
+                 LEFT JOIN product p ON chp.productId = p.productID
+                 LEFT JOIN cm_brand cb on p.brandID = cb.id
         WHERE chp.validFlag = 1
           and chp.productId = #{productId}
     </select>
@@ -103,9 +117,14 @@
           AND a.productId = #{productId}
     </select>
     <select id="getCollageProduct" resultType="com.caimei365.commodity.model.po.HeheCollageProductPo">
-        select chcs.skuId,chcp.productId, chcs.collagePrice as price, chcp.limitedNum, chcp.unlimitedFlag, chcp.memberNum
+        select chcs.skuId,
+               chcp.productId,
+               chcs.collagePrice as price,
+               chcp.limitedNum,
+               chcp.unlimitedFlag,
+               chcp.memberNum
         from cm_hehe_collage_product chcp
-        left join cm_hehe_collage_sku chcs on chcp.productId=chcs.productId
+                 left join cm_hehe_collage_sku chcs on chcp.productId = chcs.productId
         where chcs.skuId = #{skuId}
           and chcp.status = 1
         ORDER BY price ASC
@@ -152,8 +171,8 @@
     <select id="getDiscountPrice" resultType="com.caimei365.commodity.model.po.HeheDiscountPricePo">
         select chds.discountPrice, a.productId, chda.offlineTime
         from hehe_discount_activity_product a
-        left join cm_hehe_discount_activity_sku chds on a.productId=chds.productId
-        left join cm_hehe_discount_activity chda on a.activityId = chda.id
+                 left join cm_hehe_discount_activity_sku chds on a.productId = chds.productId
+                 left join cm_hehe_discount_activity chda on a.activityId = chda.id
         where chds.skuId = #{skuId}
           and a.status = 1
           and NOW() between chda.onlineTime and chda.offlineTime
@@ -332,9 +351,9 @@
                cs.stock,
                chs.price,
                chs.price as normalPrice
-        from cm_sku cs
-        left join cm_hehe_sku chs on cs.skuId = chs.skuId
-        where cs.productId=#{productId}
+        from cm_hehe_sku chs
+                 left join cm_sku cs on cs.skuId = chs.skuId
+        where chs.productId = #{productId}
         order by chs.price asc
     </select>
     <select id="getActivityLadderListBySkuId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">

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

@@ -71,7 +71,7 @@
         where skuId = #{skuId}
           and userType = 3
           and delFlag = 0
-        order by ladderNum DESC
+        order by buyPrice asc
         limit 1
     </select>
     <select id="findMaxLadderPrice" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
@@ -85,7 +85,7 @@
         where skuId = #{skuId}
           and userType = 3
           and delFlag = 0
-        order by ladderNum asc
+        order by buyprice desc
         limit 1
     </select>
     <select id="getRepurchasePrice" resultType="java.lang.Double">