plf hace 4 años
padre
commit
2ac7bfd5df

+ 5 - 0
src/main/java/com/caimei/model/vo/CartProductVo.java

@@ -95,6 +95,11 @@ public class CartProductVo implements Serializable {
      */
     private Integer productCount;
 
+    /**
+     * 满减金额
+     */
+    private BigDecimal fullReduction;
+
     /**
      * 是否是赠品 2是,其他否
      */

+ 6 - 0
src/main/java/com/caimei/model/vo/ShopVo.java

@@ -39,6 +39,12 @@ public class ShopVo implements Serializable {
     @ApiModelProperty("购物车该供应商下总价")
     private BigDecimal shopTotalPrice;
 
+    /**
+     * 满减金额
+     */
+    @ApiModelProperty("满减金额")
+    private BigDecimal fullReduction;
+
     /**
      * 前端选中状态
      */

+ 6 - 0
src/main/java/com/caimei/service/impl/OrderSubmitServiceImpl.java

@@ -52,6 +52,8 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
             log.info("<<<<< 结算订单 >>>>>");
             //商品总金额
             AtomicReference<BigDecimal> totalPrice = new AtomicReference<BigDecimal>(BigDecimal.ZERO);
+            //促销满减
+            AtomicReference<BigDecimal> totalFullReduction = new AtomicReference<BigDecimal>(BigDecimal.ZERO);
             String[] productId = productIds.split(",");
             List<Integer> shopIds = new ArrayList<>();
             List<CartProductVo> productGifts = new ArrayList<>();
@@ -60,14 +62,17 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
                 shopIds.add(shop.getShopId());
                 //购物车购买
                 List<CartProductVo> products = orderSubmitMapper.findProductListByCart(shop.getShopId(), productId, userId);
+                BigDecimal fullReduction = BigDecimal.ZERO;
                 BigDecimal shopTotalPrice = BigDecimal.ZERO;
                 for (CartProductVo product : products) {
                     productGifts.addAll(shoppingCartService.setProductPrice(product));
                     shopTotalPrice = MathUtil.add(shopTotalPrice, MathUtil.mul(product.getProductCount(), product.getRetailPrice()));
+                    fullReduction = MathUtil.add(fullReduction, product.getFullReduction());
                 }
                 shop.setShopTotalPrice(shopTotalPrice);
                 shop.setProductList(products);
                 totalPrice.set(MathUtil.add(totalPrice.get(), shopTotalPrice));
+                totalFullReduction.set(MathUtil.add(totalFullReduction.get(), shop.getFullReduction()));
             });
             //单品满赠
             if (productGifts.size() > 0) {
@@ -90,6 +95,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
                 }
             }
             confirmData.put("totalPrice", totalPrice);
+            confirmData.put("totalFullReduction", totalFullReduction);
             confirmData.put("shopList", shopList);
             // 发票信息
             CmUserInvoiceInfoPo invoice = orderSubmitMapper.findUserInvoice(userId);

+ 6 - 2
src/main/java/com/caimei/service/impl/ShoppingCartServiceImpl.java

@@ -62,12 +62,15 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
         Map<String, Object> map = new HashMap<>(3);
         List<ShopVo> shopList = shoppingCartMapper.findCartShop(userId);
         shopList.forEach(shop -> {
+            BigDecimal fullReduction = BigDecimal.ZERO;
             BigDecimal shopTotalPrice = BigDecimal.ZERO;
             List<CartProductVo> productList = shoppingCartMapper.findByShopCartProduct(shop.getShopId(), userId);
             for (CartProductVo product : productList) {
                 setProductPrice(product);
                 shopTotalPrice = MathUtil.add(shopTotalPrice, MathUtil.mul(product.getProductCount(), product.getRetailPrice()));
+                fullReduction = MathUtil.add(fullReduction, product.getFullReduction());
             }
+            shop.setFullReduction(fullReduction);
             shop.setShopTotalPrice(shopTotalPrice);
             shop.setProductList(productList);
         });
@@ -101,6 +104,8 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
             // 活动价
             if (activity.getMode() == 1) {
                 product.setRetailPrice(activity.getTouchPrice());
+                BigDecimal reduction = MathUtil.sub(product.getPrice(), activity.getTouchPrice());
+                product.setFullReduction(MathUtil.mul(reduction, product.getProductCount()));
             } else {
                 BigDecimal totalPrice = MathUtil.mul(product.getProductCount(), product.getPrice());
                 if (addTaxFlag) {
@@ -113,8 +118,7 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
                 }
                 if (MathUtil.compare(totalPrice, activity.getTouchPrice()) > -1) {
                     if (activity.getMode() == 2) {
-                        BigDecimal retailPrice = MathUtil.sub(product.getPrice(), activity.getReducedPrice());
-                        product.setRetailPrice(retailPrice);
+                        product.setFullReduction(activity.getReducedPrice());
                     } else {
                         productGifts = activity.getProductGifts();
                     }

+ 2 - 0
src/main/resources/mapper/OrderMapper.xml

@@ -72,6 +72,8 @@
         cso.userID AS userId,
         cso.shopID AS shopId,
         cso.itemCount,
+        cso.totalAmount,
+        cso.promotionFullReduction,
         s.name AS shopName,
         s.logo AS shopLogo
         FROM