Browse Source

Merge remote-tracking branch 'origin/developer' into developerA

# Conflicts:
#	src/main/java/com/caimei365/order/components/ProductService.java
#	src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java
chao 3 năm trước cách đây
mục cha
commit
8d1c1a5f6c

+ 2 - 1
src/main/java/com/caimei365/order/components/OrderCommonService.java

@@ -77,7 +77,8 @@ public class OrderCommonService {
                 // 不含税可开票商品,单价/折后单价在原基础上加上税费
                 boolean taxFlag = (Integer.valueOf(0).equals(orderProduct.getIncludedTax()) && (Integer.valueOf(1).equals(orderProduct.getInvoiceType()) || Integer.valueOf(2).equals(orderProduct.getInvoiceType())));
                 if (taxFlag) {
-                    orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
+                    Double valueTax = MathUtil.div(MathUtil.mul(orderProduct.getPrice(), orderProduct.getTaxRate()), 100).doubleValue();
+                    orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax).doubleValue());
                     orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
                 }
                 orderProduct.setImage(ImageUtil.getImageUrl("product", orderProduct.getImage(), domain));

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

@@ -44,9 +44,9 @@ public class ProductService {
         boolean taxFlag = (Integer.valueOf(0).equals(cartItemVo.getIncludedTax()) && (Integer.valueOf(1).equals(cartItemVo.getInvoiceType()) || Integer.valueOf(2).equals(cartItemVo.getInvoiceType())));
         if (taxFlag) {
             BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(cartItemVo.getPrice(), cartItemVo.getTaxRate()), 100, 2);
-            double price = MathUtil.add(cartItemVo.getPrice(), cartItemTax).doubleValue();
-            cartItemVo.setPrice(price);
-            cartItemVo.setOriginalPrice(price);
+            BigDecimal originalcartItemTax = MathUtil.div(MathUtil.mul(cartItemVo.getOriginalPrice(), cartItemVo.getTaxRate()), 100, 2);
+            cartItemVo.setPrice(MathUtil.add(cartItemVo.getPrice(), cartItemTax).doubleValue());
+            cartItemVo.setOriginalPrice(MathUtil.add(cartItemVo.getOriginalPrice(), originalcartItemTax).doubleValue());
         }
         return taxFlag;
     }

+ 56 - 48
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -101,6 +101,8 @@ public class CartClubServiceImpl implements CartClubService {
                 AtomicDouble shopPromotionFee = new AtomicDouble(0);
                 // 该供应商满减金额(svip优惠,供应商满减,单品满减)
                 AtomicDouble shopReducedPrice = new AtomicDouble(0);
+                // 该供应商划线价
+                AtomicDouble shopOriginalPrice = new AtomicDouble(0);
                 // 供应商促销优惠活动
                 PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
                 // 供应商下商品列表
@@ -184,6 +186,7 @@ public class CartClubServiceImpl implements CartClubService {
                             }
                             // 该供应商下价格累加
                             shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
+                            shopOriginalPrice.set(MathUtil.sub(shopOriginalPrice.get(), MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getOriginalPrice())).doubleValue());
                             // 该供应商下可参与店铺促销的商品价格累加
                             if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
                                 // 超级会员购买svip商品不享受店铺促销优惠
@@ -281,7 +284,7 @@ public class CartClubServiceImpl implements CartClubService {
                     // 供应商总优惠
                     shop.setReducedPrice(shopReducedPrice.get());
                     // 供应商划线价
-                    shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReducedPrice.get()).doubleValue());
+                    shop.setOriginalPrice(shopOriginalPrice.get());
                     // 计算总价
                     totalPrice.set(MathUtil.add(totalPrice, shop.getTotalPrice()).doubleValue());
                     // 优惠总额
@@ -693,6 +696,8 @@ public class CartClubServiceImpl implements CartClubService {
                     AtomicDouble shopPromotionFee = new AtomicDouble(0);
                     // 该供应商满减金额(svip优惠,供应商满减,单品满减)
                     AtomicDouble shopReducedPrice = new AtomicDouble(0);
+                    // 该供应商划线价
+                    AtomicDouble shopOriginalPrice = new AtomicDouble(0);
                     // 供应商促销优惠活动
                     PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
                     // 供应商下商品列表
@@ -772,6 +777,7 @@ public class CartClubServiceImpl implements CartClubService {
                             }
                             // 该供应商下价格累加
                             shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
+                            shopOriginalPrice.set(MathUtil.sub(shopOriginalPrice.get(), MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getOriginalPrice())).doubleValue());
                             // 该供应商下可参与店铺促销的商品价格累加
                             if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
                                 // 超级会员购买svip商品不享受店铺促销优惠
@@ -825,8 +831,7 @@ public class CartClubServiceImpl implements CartClubService {
                             // 供应商总优惠
                             shop.setReducedPrice(shopReducedPrice.get());
                             // 供应商划线价
-                            shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReducedPrice.get()).doubleValue());
-
+                            shop.setOriginalPrice(shopOriginalPrice.get());
                             // 添加供应商Id集合
                             shopIds.add(shop.getShopId());
                             // 计算总价
@@ -852,33 +857,34 @@ public class CartClubServiceImpl implements CartClubService {
         totalPromotions.forEach(promotions -> {
             // 该促销内商品总价
             double touchPrice = promotions.getProductList().stream().mapToDouble(product -> product.getNumber() * product.getPrice()).sum();
-            // 凑单满减
-            if (promotions.getType() == 2 && promotions.getMode() == 2) {
-                if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
+            // 满足促销条件
+            if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
+                // 凑单满减
+                if (promotions.getType() == 2 && promotions.getMode() == 2) {
                     // 总价 - 满减金额
                     totalPrice.set(MathUtil.sub(totalPrice, promotions.getReducedPrice()).doubleValue());
                     // 优惠总额 + 满减金额
                     reducedPrice.set(MathUtil.add(reducedPrice, promotions.getReducedPrice()).doubleValue());
+                } else if (promotions.getMode() == 3) {
+                    // 全部满赠
+                    promotions.getGiftList().forEach(gift -> {
+                        if (shopIds.contains(gift.getShopId())) {
+                            // 赠品在当前订单内的供应商下
+                            shopList.forEach(shop -> {
+                                if (shop.getShopId().equals(gift.getShopId())) {
+                                    shop.getCartList().add(gift);
+                                }
+                            });
+                        } else {
+                            // 获取赠品供应商
+                            CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
+                            shopIds.add(giftShop.getShopId());
+                            giftShop.setCartList(new ArrayList<>());
+                            giftShop.getCartList().add(gift);
+                            shopList.add(giftShop);
+                        }
+                    });
                 }
-            } else if (promotions.getMode() == 3) {
-                // 全部满赠
-                promotions.getGiftList().forEach(gift -> {
-                    if (shopIds.contains(gift.getShopId())) {
-                        // 赠品在当前订单内的供应商下
-                        shopList.forEach(shop -> {
-                            if (shop.getShopId().equals(gift.getShopId())) {
-                                shop.getCartList().add(gift);
-                            }
-                        });
-                    } else {
-                        // 获取赠品供应商
-                        CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
-                        shopIds.add(giftShop.getShopId());
-                        giftShop.setCartList(new ArrayList<>());
-                        giftShop.getCartList().add(gift);
-                        shopList.add(giftShop);
-                    }
-                });
             }
         });
 
@@ -969,31 +975,33 @@ public class CartClubServiceImpl implements CartClubService {
             List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
             promotions.setProductList(promotionPriceList);
             Double totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice()).doubleValue();
-            // 满减
-            if (promotions.getMode() == 2 && MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
-                // 总价 - 满减金额
-                totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
-                // 优惠总额 + 满减金额
-                reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
-            }
-            if (promotions.getMode() == 3) {
-                // 获取赠品
-                List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
-                giftList.forEach(gift -> {
-                    if (shop.getShopId().equals(gift.getShopId())) {
-                        // 赠品在当前订单内的供应商下
+            // 满足促销条件
+            if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
+                // 满减
+                if (promotions.getMode() == 2) {
+                    // 总价 - 满减金额
+                    totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
+                    // 优惠总额 + 满减金额
+                    reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
+                } else if (promotions.getMode() == 3) {
+                    // 满赠
+                    List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
+                    giftList.forEach(gift -> {
                         if (shop.getShopId().equals(gift.getShopId())) {
-                            shop.getCartList().add(gift);
+                            // 赠品在当前订单内的供应商下
+                            if (shop.getShopId().equals(gift.getShopId())) {
+                                shop.getCartList().add(gift);
+                            }
+                        } else {
+                            // 获取赠品供应商
+                            CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
+                            giftShop.setCartList(new ArrayList<>());
+                            giftShop.getCartList().add(gift);
+                            shopList.add(giftShop);
                         }
-                    } else {
-                        // 获取赠品供应商
-                        CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
-                        giftShop.setCartList(new ArrayList<>());
-                        giftShop.getCartList().add(gift);
-                        shopList.add(giftShop);
-                    }
-                });
-                promotions.setGiftList(giftList);
+                    });
+                    promotions.setGiftList(giftList);
+                }
             }
             // 添加到总促销
             totalPromotions.add(promotions);

+ 2 - 0
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -756,6 +756,8 @@ public class SubmitServiceImpl implements SubmitService {
             shopOrder.setShopTaxFee(shopTaxFee.get());
             // 付供应商 = 商品费 + 运费 + 税费
             shopOrder.setShouldPayShopAmount(MathUtil.add(shopProductAmount.get(), shopTaxFee.get()).doubleValue());
+            // 付给供应商运费
+            shopOrder.setShopPostFee(0d);
             // 已付供应商金额
             shopOrder.setPayedShopAmount(0d);
             // (付款供应商)付款状态:1待付款、2部分付款、3已付款