Prechádzať zdrojové kódy

fix(marketing): 修复促销活动价格计算相关 bug

- 在促销活动类型 1 中添加了更新商品总金额的逻辑
-优化了促销活动类型 2 中折扣价格的计算方式
- 新增了商品总金额的计算和更新,确保价格信息的准确性
hechunping 1 týždeň pred
rodič
commit
b47e7ac0aa

+ 3 - 2
src/main/java/com/xynet/marketing/service/factory/promotion/impl/base/PromotionFactoryBase.java

@@ -165,6 +165,7 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
                         List<Object> promotionList1 = goods.getList("promotionList");
                         promotionList1.add(promotion);
                         goods.set("promotionList", promotionList1);
+                        goods.set("amount", Integer.valueOf(promotionGoods.get("priceOnsale").toString()) * goods.getInt("num"));
                     }
                 }
             }
@@ -202,9 +203,9 @@ public class PromotionFactoryBase extends ServiceImpl<PromotionMapper, Promotion
                             //设置优惠信息
                             BigDecimal scalar = new BigDecimal(priceJson.getStr("scalar"));
                             //优惠价格 向上取整
-                            int price = scalar.multiply(new BigDecimal(goods.getInt("price"))).setScale(0, RoundingMode.CEILING).intValue();
+                            int price = scalar.multiply(goods.getBigDecimal("price")).setScale(0, RoundingMode.CEILING).intValue();
                             goods.set("priceOnsale", price);
-
+                            goods.set("amount", scalar.multiply(goods.getBigDecimal("amount")).setScale(0, RoundingMode.CEILING).intValue());
                             goods.set("promotionType2", true);
                             goods.set("msg", "促销活动:" + priceJson.getStr("scalar").replace("0.", "") + "折;");
                         }