Browse Source

优惠价bugfix

zhijiezhao 2 years ago
parent
commit
c68373b237

+ 5 - 8
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -132,8 +132,6 @@ public class PriceUtilService {
         boolean setFlag = identity == 1 || priceFlag == 0 || (priceFlag == 3 && clubType == 1) || (priceFlag == 2 && (identity == 2 || isSuperVip)) || isShopOwn;
 
         List<Sku> skus = priceMapper.findSkus(price.getProductId());
-        AtomicDouble atomicDouble = new AtomicDouble();
-        atomicDouble.set(skus.get(0).getPrice());
         int size = skus.size();
         //税费标志
         boolean taxFlag = "0".equals(price.getIncludedTax()) && ("1".equals(price.getInvoiceType()) || "2".equals(price.getInvoiceType()));
@@ -145,6 +143,7 @@ public class PriceUtilService {
         price.setUnit(skus.get(0).getUnit());
         price.setStock(skus.get(0).getStock());
         skus.forEach(s -> {
+            s.setOriginalPrice(s.getPrice());
             s.setPriceGrade(getPriceGrade(s.getPrice()));
             if (1 == price.getSvipProductFlag()) {
                 // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
@@ -156,8 +155,6 @@ public class PriceUtilService {
                     price.setSvipPriceTag(MathUtil.div(skus.get(0).getDiscount(), 10, 1) + "折");
                     if (isSuperVip) {
                         // 超级会员用户设置优惠价
-                        price.setOriginalPrice(atomicDouble.get());
-                        s.setOriginalPrice(s.getPrice());
                         svipDiscountPrice = MathUtil.div(MathUtil.mul(s.getPrice(), skus.get(0).getDiscount()), 100, 2);
                         s.setPrice(svipDiscountPrice.doubleValue());
                         price.setPrice(svipDiscountPrice.doubleValue());
@@ -187,11 +184,10 @@ public class PriceUtilService {
                 }
                 if (promotions.getType() == 1 && promotions.getMode() == 1) {
                     // 单品优惠价的时候,取当前sku的touchprice
-                    Double touchPrice = priceMapper.getTouchPriceBySku(s.getSkuId());
-                    s.setOriginalPrice(s.getPrice());
-                    price.setOriginalPrice(atomicDouble.get());
+                    Double touchPrice = priceMapper.getTouchPriceBySku(s.getSkuId(), promotions.getId());
                     s.setPrice(touchPrice);
                     price.setPrice(skus.get(0).getTouchPrice());
+                    promotions.setTouchPrice(skus.get(0).getTouchPrice());
                 }
                 price.setPromotions(promotions);
             } else {
@@ -258,6 +254,7 @@ public class PriceUtilService {
                 s.setOriginalPrice(MathUtil.add(s.getOriginalPrice(), originalTaxFee).doubleValue());
             }
         });
+        price.setOriginalPrice(skus.get(0).getOriginalPrice());
         // price添加税费
         if (taxFlag) {
             BigDecimal thisTaxFee = MathUtil.div(MathUtil.mul(price.getPrice(), price.getTaxRate()), 100, 2);
@@ -304,7 +301,7 @@ public class PriceUtilService {
         product.setSvipPriceTag(price.getSvipPriceTag());
         product.setPrice(price.getPrice());
         product.setSkuId(price.getSkuId());
-        product.setOriginalPrice(price.getPrice());
+        product.setOriginalPrice(price.getOriginalPrice());
         product.setPriceGrade(getPriceGrade(price.getPrice()));
         product.setMinBuyNumber(price.getMinBuyNumber());
         product.setUnit(price.getUnit());

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

@@ -99,5 +99,5 @@ public interface PriceMapper {
 
     VipSkuPriceDto getVipSku(Integer skuId);
 
-    Double getTouchPriceBySku(Integer skuId);
+    Double getTouchPriceBySku(Integer skuId,Integer promotionId);
 }

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

@@ -631,7 +631,7 @@ public class PageServiceImpl implements PageService {
             priceUtilService.setPriceByUserId(price, userId, 0);
             // 设置价格
             product.setPrice(price.getPrice());
-            product.setOriginalPrice(price.getPrice());
+            product.setOriginalPrice(price.getOriginalPrice());
             product.setMinBuyNumber(price.getMinBuyNumber());
             product.setUnit(price.getUnit());
             product.setStock(price.getStock());
@@ -642,7 +642,6 @@ public class PageServiceImpl implements PageService {
             product.setUserIdentity(price.getUserIdentity());
             product.setSvipProductFlag(price.getSvipProductFlag());
             product.setSvipPriceTag(price.getSvipPriceTag());
-            AtomicBoolean lowPrice = new AtomicBoolean(false);
             //设置展示的价格等级
             product.setPriceGrade(priceUtilService.getPriceGrade(product.getPrice()));
             //查询商品收藏情况,1未收藏,0未收藏,未收藏过该商品用户是null
@@ -1351,6 +1350,7 @@ public class PageServiceImpl implements PageService {
                 }
             }
             product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
+            priceUtilService.setProductDetails(userId, product, null);
         });
         PaginationVo<ProductItemVo> pageData = new PaginationVo(list);
         return ResponseJson.success(pageData);

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

@@ -264,5 +264,6 @@
         select touchPrice
         from cm_promotion_sku
         where skuId = #{skuId}
+        and promotionId=#{promotionId}
     </select>
 </mapper>