Browse Source

赠品叠加改为只加数量

zhijiezhao 3 years ago
parent
commit
889f6b3311

+ 1 - 4
src/main/java/com/caimei365/order/components/ProductService.java

@@ -150,10 +150,7 @@ public class ProductService {
                 // 符合条件赠品翻倍
                 if (floor != null && promotions.getDiscount() != null && floor > 1 && promotions.getDiscount() == 1) {
                     Integer in = floor.intValue();
-                    List<CartItemVo> g = new ArrayList<>();
-                    for (Integer i = 1; i < in; i++) {
-                        giftList.addAll(g);
-                    }
+                    giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                 }
                 promotions.setGiftList(giftList);
             }

+ 7 - 49
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -279,13 +279,7 @@ public class CartClubServiceImpl implements CartClubService {
                                 // 叠加赠品
                                 if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 1 && floor > 1) {
                                     Integer in = floor.intValue();
-                                    List<CartItemVo> g = new ArrayList<>();
-                                    g.addAll(giftList);
-                                    if (in > 1) {
-                                        for (Integer i = 1; i < in; i++) {
-                                            giftList.addAll(g);
-                                        }
-                                    }
+                                    giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                                 }
                                 shopPromotion.setGiftList(giftList);
                             }
@@ -964,13 +958,7 @@ public class CartClubServiceImpl implements CartClubService {
                                         //叠加满赠
                                         if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 1 && floor > 1) {
                                             Integer in = floor.intValue();
-                                            List<CartItemVo> g = new ArrayList<>();
-                                            g.addAll(giftList);
-                                            if (in > 1) {
-                                                for (Integer i = 1; i < in; i++) {
-                                                    giftList.addAll(g);
-                                                }
-                                            }
+                                            giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                                         }
                                         shopPromotion.setGiftList(giftList);
                                     }
@@ -1066,13 +1054,7 @@ public class CartClubServiceImpl implements CartClubService {
                     //满足叠加
                     if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && floor > 1) {
                         Integer in = floor.intValue();
-                        List<CartItemVo> g = new ArrayList<>();
-                        g.addAll(giftList);
-                        if (in > 1) {
-                            for (Integer i = 1; i < in; i++) {
-                                giftList.addAll(g);
-                            }
-                        }
+                        giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                     }
                     promotions.setGiftList(giftList);
                     // 全部满赠
@@ -1324,13 +1306,7 @@ public class CartClubServiceImpl implements CartClubService {
                                         //叠加满赠
                                         if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 1 && floor > 1) {
                                             Integer in = floor.intValue();
-                                            List<CartItemVo> g = new ArrayList<>();
-                                            g.addAll(giftList);
-                                            if (in > 1) {
-                                                for (Integer i = 1; i < in; i++) {
-                                                    giftList.addAll(g);
-                                                }
-                                            }
+                                            giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                                         }
                                         shopPromotion.setGiftList(giftList);
                                     }
@@ -1426,13 +1402,7 @@ public class CartClubServiceImpl implements CartClubService {
                     //满足叠加
                     if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && floor > 1) {
                         Integer in = floor.intValue();
-                        List<CartItemVo> g = new ArrayList<>();
-                        g.addAll(giftList);
-                        if (in > 1) {
-                            for (Integer i = 1; i < in; i++) {
-                                giftList.addAll(g);
-                            }
-                        }
+                        giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                     }
                     promotions.setGiftList(giftList);
                     // 全部满赠
@@ -1592,13 +1562,7 @@ public class CartClubServiceImpl implements CartClubService {
                         //满足叠加
                         if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && floor > 1) {
                             Integer in = floor.intValue();
-                            List<CartItemVo> g = new ArrayList<>();
-                            g.addAll(giftList);
-                            if (in > 1) {
-                                for (Integer i = 1; i < in; i++) {
-                                    giftList.addAll(g);
-                                }
-                            }
+                            giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                         }
                         promotions.setGiftList(giftList);
                     }
@@ -1655,13 +1619,7 @@ public class CartClubServiceImpl implements CartClubService {
             //满足叠加
             if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && floor > 1) {
                 Integer in = floor.intValue();
-                List<CartItemVo> g = new ArrayList<>();
-                g.addAll(giftList);
-                if (in > 1) {
-                    for (Integer i = 1; i < in; i++) {
-                        giftList.addAll(g);
-                    }
-                }
+                giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
             }
             promotions.setGiftList(giftList);
 

+ 3 - 21
src/main/java/com/caimei365/order/service/impl/CartSellerServiceImpl.java

@@ -229,13 +229,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                             // 叠加赠品
                             if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 1 && floor > 1) {
                                 Integer in = floor.intValue();
-                                List<CartItemVo> g = new ArrayList<>();
-                                g.addAll(giftList);
-                                if (in > 1) {
-                                    for (Integer i = 1; i < in; i++) {
-                                        giftList.addAll(g);
-                                    }
-                                }
+                                giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                             }
                             shopPromotion.setGiftList(giftList);
                         }
@@ -594,13 +588,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                                     // 叠加赠品
                                     if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 1 && floor > 1) {
                                         Integer in = floor.intValue();
-                                        List<CartItemVo> g = new ArrayList<>();
-                                        g.addAll(giftList);
-                                        if (in > 1) {
-                                            for (Integer i = 1; i < in; i++) {
-                                                giftList.addAll(g);
-                                            }
-                                        }
+                                        giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                                     }
                                     shopPromotion.setGiftList(giftList);
                                 }
@@ -695,13 +683,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                 //满足叠加
                 if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && floor > 1) {
                     Integer in = floor.intValue();
-                    List<CartItemVo> g = new ArrayList<>();
-                    g.addAll(giftList);
-                    if (in > 1) {
-                        for (Integer i = 1; i < in; i++) {
-                            giftList.addAll(g);
-                        }
-                    }
+                    giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
                 }
                 promotions.setGiftList(giftList);
                 // 全部满赠