瀏覽代碼

组合商品立即购买

zhijiezhao 3 年之前
父節點
當前提交
1c6d465592

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

@@ -148,7 +148,7 @@ public class ProductService {
                 // 获取赠品
                 List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
                 // 符合条件赠品翻倍
-                if (floor != null && promotions.getDiscount() != null && floor > 1 && promotions.getDiscount().equals("0")) {
+                if (floor != null && promotions.getDiscount() != null && floor > 1 && promotions.getDiscount() == 0) {
                     Integer in = floor.intValue();
                     List<CartItemVo> g = new ArrayList<>();
                     for (Integer i = 1; i < in; i++) {

+ 16 - 0
src/main/java/com/caimei365/order/controller/CartClubApi.java

@@ -184,6 +184,22 @@ public class CartClubApi {
         return cartClubService.buyNowProduct(cartDto);
     }
 
+    @ApiOperation("组合商品立即购买")
+    @GetMapping("/product/buynow")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = false, name = "productInfo", value = "组合商品信息:Json字符串格式[{\"id\":4351,\"count\":1},{}]"),
+            @ApiImplicitParam(required = false, name = "source", value = "来源 : 1 网站 ; 2 小程序")
+    })
+    public ResponseJson<Map<String, Object>> MultipleBuyNow(Integer userId, String productInfo, Integer source){
+        if (null == userId) {
+            return ResponseJson.error("用户Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(productInfo)) {
+            return ResponseJson.error("组合商品信息不能为空!", null);
+        }
+        return cartClubService.MultipleBuyNow(userId, productInfo, source);
+    }
     /**
      * 获取结算商品运费
      */

+ 15 - 0
src/main/java/com/caimei365/order/mapper/CartClubMapper.java

@@ -59,11 +59,26 @@ public interface CartClubMapper {
      * @param userId 用户Id
      */
     List<CartShopVo> getCartShopsByProductIds(@Param("userId") Integer userId, @Param("productIds") List<String> productIds);
+
+    /**
+     * 根据商品ids获取供应商列表
+     * @param productIds
+     * @return
+     */
+    List<CartShopVo> getShopsByProductIds(@Param("productIds") List<String> productIds);
     /**
      * 根据商品Ids获取购物车已上架商品列表
      * @param userId 用户Id
      */
     List<CartItemVo> getCartProductsByShopIdAndProductIds(@Param("userId") Integer userId,@Param("shopId")  Integer shopId, @Param("productIds") List<String> productIds);
+
+    /**
+     * 根据商品id获取已上架商品列表
+     * @param shopId
+     * @param productIds
+     * @return
+     */
+    List<CartItemVo> getProductsByShopIdAndProductIds(@Param("shopId")  Integer shopId, @Param("productIds") List<String> productIds);
     /**
      * 删除用户发票信息
      */

+ 2 - 2
src/main/java/com/caimei365/order/model/vo/PromotionsVo.java

@@ -19,11 +19,11 @@ public class PromotionsVo implements Serializable {
     /**
      * 活动可见度,0所有人,1仅对机构
      */
-    private String seen;
+    private Integer seen;
     /**
      * 是否支持叠加优惠,0支持,1不支持
      */
-    private String discount;
+    private Integer discount;
     /**
      * 促销id
      */

+ 7 - 0
src/main/java/com/caimei365/order/service/CartClubService.java

@@ -127,4 +127,11 @@ public interface CartClubService {
      * @param userId 用户ID
      */
     ResponseJson<Integer> getUserCartCount(Integer userId);
+
+    /**
+     * 组合商品立即购买
+     * @param
+     * @return
+     */
+    ResponseJson<Map<String, Object>> MultipleBuyNow(Integer userId, String productInfo, Integer source);
 }

+ 385 - 20
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -1,5 +1,8 @@
 package com.caimei365.order.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.components.ProductService;
 import com.caimei365.order.mapper.BaseMapper;
 import com.caimei365.order.mapper.CartClubMapper;
@@ -26,6 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import static com.alibaba.fastjson.JSON.parseArray;
+
 
 /**
  * Description
@@ -110,7 +115,7 @@ public class CartClubServiceImpl implements CartClubService {
                 AtomicDouble shopOriginalPrice = new AtomicDouble(0);
                 // 供应商促销优惠活动,以活动分类排序,店铺>凑单>单品
                 PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
-                if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen().equals("1") && userIdentity == 1) {
+                if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen() == 1 && userIdentity == 1) {
                     shopPromotion = null;
                 }
                 // 供应商下商品列表 ,购物车里的该供应商商品
@@ -149,7 +154,7 @@ public class CartClubServiceImpl implements CartClubService {
                                     // 获取商品促销信息
                                     promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
                                     // 促销活动如果协销不可见直接置空
-                                    if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
+                                    if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1 && userIdentity == 1) {
                                         promotions = null;
                                     }
                                     /*
@@ -165,7 +170,7 @@ public class CartClubServiceImpl implements CartClubService {
                                         //单品满减-计算供应商总价/满减金额
                                         // 叠加优惠计算
                                         if (promotions.getType() == 1 && promotions.getMode() == 2) {
-                                            if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                                            if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                                                 //叠加优惠计算
                                                 //叠加倍数
                                                 shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -267,7 +272,7 @@ public class CartClubServiceImpl implements CartClubService {
                                 // 获取赠品
                                 List<CartItemVo> giftList = baseMapper.getPromotionGifts(shopPromotion.getId());
                                 // 叠加赠品
-                                if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                                if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                     Integer in = floor.intValue();
                                     List<CartItemVo> g = new ArrayList<>();
                                     g.addAll(giftList);
@@ -296,7 +301,7 @@ public class CartClubServiceImpl implements CartClubService {
                             totalPromotions.add(shopPromotion);
                             // 店铺满减-计算供应商总价/满减金额
                             if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionFee, shopPromotion.getTouchPrice()) > -1) {
-                                if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                                if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                     // 该供应商总价 - 满减金额
                                     shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
                                     // 该供应商优惠总额 + 满减金额
@@ -345,7 +350,7 @@ public class CartClubServiceImpl implements CartClubService {
                     //叠加倍数
                     Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
                     if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
-                        if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                        if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                             //叠加优惠计算
                             // 总价 - 满减金额
                             totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -523,7 +528,7 @@ public class CartClubServiceImpl implements CartClubService {
                 // 获取商品促销信息
                 PromotionsVo promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
                 // 如果促销活动协销不可见,移除促销
-                if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
+                if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1 && userIdentity == 1) {
                     promotions = null;
                 }
                 /*
@@ -576,7 +581,7 @@ public class CartClubServiceImpl implements CartClubService {
                     //叠加倍数
                     Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
                     if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
-                        if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                        if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                             //叠加优惠计算
                             // 总价 - 满减金额
                             totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -792,7 +797,7 @@ public class CartClubServiceImpl implements CartClubService {
                     AtomicDouble shopOriginalPrice = new AtomicDouble(0);
                     // 供应商促销优惠活动
                     PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
-                    if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen().equals("1") && userIdentity == 1) {
+                    if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen() == 1 && userIdentity == 1) {
                         shopPromotion = null;
                     }
                     // 供应商下商品列表
@@ -830,7 +835,367 @@ public class CartClubServiceImpl implements CartClubService {
                                     // 获取商品促销信息
                                     promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
                                     // 如果促销活动协销不可见,移除促销
-                                    if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
+                                    if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1 && userIdentity == 1) {
+                                        promotions = null;
+                                    }
+                                    /*
+                                     * 设置商品促销优惠
+                                     */
+                                    if (null != promotions) {
+                                        BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
+                                        //叠加倍数
+                                        Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
+                                        // 当前促销活动的价格计算列表
+                                        List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
+                                        // 更新到总促销列表
+                                        productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList, floor);
+                                        //单品满减-计算供应商总价/满减金额
+                                        if (promotions.getType() == 1 && promotions.getMode() == 2) {
+                                            if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
+                                                if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
+                                                    //叠加优惠计算
+                                                    shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
+                                                    shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
+                                                } else {
+                                                    // 如果满足促销条件,设置供应商价格-满减金额,满减总额 + 当前促销满减金额
+                                                    shopPrice.set(MathUtil.sub(shopPrice.get(), promotions.getReducedPrice()).doubleValue());
+                                                    shopReducedPrice.set(MathUtil.add(shopReducedPrice, promotions.getReducedPrice()).doubleValue());
+                                                }
+                                            }
+                                        }
+                                        cartItemVo.setPromotions(promotions);
+                                    }
+                                }
+                                if (null != promotions || null != shopPromotion) {
+                                    // 商品处于活动状态
+                                    cartItemVo.setActStatus(1);
+                                    // 关闭阶梯价格,活动优先
+                                    cartItemVo.setLadderFlag(0);
+                                } else {
+                                    if (cartItemVo.getLadderFlag() == 1) {
+                                        // 设置阶梯价
+                                        productService.setCartLadderPrices(cartItemVo, taxFlag);
+                                    } else {
+                                        // 复购价
+                                        Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
+                                        if (null != repurchase && repurchase > 0) {
+                                            if (taxFlag) {
+                                                BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(repurchase, cartItemVo.getTaxRate()), 100, 2);
+                                                cartItemVo.setPrice(MathUtil.add(repurchase, cartItemTax).doubleValue());
+                                            } else {
+                                                cartItemVo.setPrice(repurchase);
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                            // 该供应商下价格累加
+                            shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
+                            shopOriginalPrice.set(MathUtil.add(shopOriginalPrice.get(), MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getOriginalPrice())).doubleValue());
+                            // 该供应商下可参与店铺促销的商品价格累加
+                            if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
+                                // 超级会员购买svip商品不享受店铺促销优惠
+                                shopPromotionFee.set(MathUtil.add(shopPromotionFee, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
+                            }
+                            // 该供应商下商品种类 +1
+                            shopKindCount.incrementAndGet();
+                            // 总数量 + 当前商品购买数量
+                            totalCount.updateAndGet(v -> v + cartItemVo.getNumber());
+                        }
+
+                        if (shopKindCount.get() > 0) {
+                            // 店铺促销
+                            if (null != shopPromotion) {
+                                Double floor = Math.floor(MathUtil.div(shopPromotionFee, shopPromotion.getTouchPrice()).doubleValue());
+                                shop.setPromotions(shopPromotion);
+                                if (!promotionsIds.contains(shopPromotion.getId())) {
+                                    promotionsIds.add(shopPromotion.getId());
+                                    // 店铺满赠
+                                    if (shopPromotion.getMode() == 3 && MathUtil.compare(shopPromotionFee, shopPromotion.getTouchPrice()) > -1) {
+                                        // 获取赠品
+                                        List<CartItemVo> giftList = baseMapper.getPromotionGifts(shopPromotion.getId());
+                                        //叠加满赠
+                                        if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && 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);
+                                                }
+                                            }
+                                        }
+                                        shopPromotion.setGiftList(giftList);
+                                    }
+                                    // 设置该优惠下的商品列表
+                                    List<PromotionPriceVo> promotionPriceList = new ArrayList<>();
+                                    productList.forEach(item -> {
+                                        if (!(1 == item.getSvipProductFlag() && svipUserFlag)) {
+                                            // 超级会员购买svip商品不享受店铺促销优惠
+                                            PromotionPriceVo promotionPrice = new PromotionPriceVo();
+                                            promotionPrice.setProductId(item.getProductId());
+                                            promotionPrice.setNumber(item.getNumber());
+                                            promotionPrice.setPrice(item.getPrice());
+                                            promotionPriceList.add(promotionPrice);
+                                        }
+                                    });
+                                    shopPromotion.setProductList(promotionPriceList);
+                                    // 添加到总促销
+                                    totalPromotions.add(shopPromotion);
+                                    // 店铺满减-计算供应商总价/满减金额
+                                    // 满减叠加计算
+                                    if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionFee, shopPromotion.getTouchPrice()) > -1) {
+                                        if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
+                                            shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
+                                            shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
+                                        } else {
+                                            // 该供应商总价 - 满减金额
+                                            shopPrice.set(MathUtil.sub(shopPrice.get(), shopPromotion.getReducedPrice()).doubleValue());
+                                            // 该供应商优惠总额 + 满减金额
+                                            shopReducedPrice.set(MathUtil.add(shopReducedPrice.get(), shopPromotion.getReducedPrice()).doubleValue());
+                                        }
+                                    }
+                                }
+                            }
+                            // 供应商商品
+                            shop.setCartList(productList);
+                            // 供应商总价
+                            shop.setTotalPrice(shopPrice.get());
+                            // 供应商总优惠
+                            shop.setReducedPrice(shopReducedPrice.get());
+                            // 供应商总超级会员优惠
+                            shop.setSvipReducedPrice(shopSvipReducedPrice.get());
+                            // 供应商划线价
+                            shop.setOriginalPrice(shopOriginalPrice.get());
+                            // 添加供应商Id集合
+                            shopIds.add(shop.getShopId());
+                            // 计算总价
+                            totalPrice.set(MathUtil.add(totalPrice, shop.getTotalPrice()).doubleValue());
+                            // 优惠总额
+                            reducedPrice.set(MathUtil.add(reducedPrice, shop.getReducedPrice()).doubleValue());
+                            // 超级会员优惠总额
+                            svipReducedPrice.set(MathUtil.add(svipReducedPrice, shop.getSvipReducedPrice()).doubleValue());
+                            // 总划线价
+                            totalOriginalPrice.set(MathUtil.add(totalOriginalPrice, shop.getOriginalPrice()).doubleValue());
+                            // 商品种类
+                            kindCount.updateAndGet(v -> v + shopKindCount.get());
+                        }
+                        totalProductList.addAll(productList);
+                    }
+                    // 供应商下商品种类
+                    shop.setCount(shopKindCount.get());
+                }
+            });
+            // 删除空数据
+            shopList.removeIf(shop -> (null == shop || shop.getCount() == 0));
+
+        }
+        // 总促销计算
+        // 满减满赠叠加计算
+        totalPromotions.forEach(promotions -> {
+            // 该促销内商品总价
+            double touchPrice = promotions.getProductList().stream().mapToDouble(product -> product.getNumber() * product.getPrice()).sum();
+            // 满足促销条件
+            if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
+                //叠加倍数
+                Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
+                // 凑单满减
+                if (promotions.getType() == 2 && promotions.getMode() == 2) {
+                    if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
+                        //叠加优惠计算
+                        // 总价 - 满减金额
+                        totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
+                        // 优惠总额 + 满减金额
+                        reducedPrice.set(MathUtil.add(reducedPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
+                    } else {
+                        // 总价 - 满减金额
+                        totalPrice.set(MathUtil.sub(totalPrice, promotions.getReducedPrice()).doubleValue());
+                        // 优惠总额 + 满减金额
+                        reducedPrice.set(MathUtil.add(reducedPrice, promotions.getReducedPrice()).doubleValue());
+                    }
+                } else if (promotions.getMode() == 3) {
+                    //满赠叠加
+                    List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
+                    //满足叠加
+                    if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && 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);
+                            }
+                        }
+                    }
+                    promotions.setGiftList(giftList);
+                    // 全部满赠
+                    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);
+                        }
+                    });
+                }
+            }
+        });
+
+        // 发票信息
+        InvoiceVo invoice = baseMapper.getUserInvoice(userId);
+        // 可用余额
+        Double availableMoney = baseMapper.getAbleUserMoney(userId);
+        // 可用采美豆
+        Integer userBeans = baseMapper.getUserBeans(userId);
+        // 用户可用优惠券(总)
+        List<CouponVo> couponList = getUserCartCoupons(totalProductList, source, userId);
+
+        // 包装返回数据
+        Map<String, Object> resultData = new HashMap<>();
+        resultData.put("list", shopList);
+        resultData.put("kindCount", kindCount);
+        resultData.put("totalCount", totalCount);
+        resultData.put("totalPrice", totalPrice);
+        resultData.put("reducedPrice", reducedPrice);
+        resultData.put("svipReducedPrice", svipReducedPrice);
+        resultData.put("totalOriginalPrice", totalOriginalPrice);
+        resultData.put("promotions", totalPromotions);
+        resultData.put("invoice", invoice);
+        resultData.put("userMoney", availableMoney);
+        resultData.put("userBeans", userBeans);
+        resultData.put("includeRecharge", includeRecharge);
+        resultData.put("couponList", couponList);
+        return ResponseJson.success(resultData);
+    }
+
+    /**
+     * 组合商品立即购买
+     *
+     * @param userId      用户ID
+     * @param productInfo 组合商品信息:Json字符串格式[{"id":4351,"count":1},{}]
+     * @param source      来源 : 1 网站 ; 2 小程序
+     * @return
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> MultipleBuyNow(Integer userId, String productInfo, Integer source) {
+        log.info("¥¥¥¥¥¥¥¥¥¥ > 组合商品立即购买");
+        // 商品种类
+        AtomicInteger kindCount = new AtomicInteger(0);
+        // 商品总数量
+        AtomicInteger totalCount = new AtomicInteger(0);
+        // 统计商品总金额
+        AtomicDouble totalPrice = new AtomicDouble(0);
+        // 统计总促销满减
+        AtomicDouble reducedPrice = new AtomicDouble(0);
+        // 统计总超级会员优惠
+        AtomicDouble svipReducedPrice = new AtomicDouble(0);
+        // 统计总划线价
+        AtomicDouble totalOriginalPrice = new AtomicDouble(0);
+        // 促销活动(总)
+        List<PromotionsVo> totalPromotions = new ArrayList<>();
+        // 是否包含充值商品,默认false
+        AtomicBoolean includeRecharge = new AtomicBoolean(false);
+        //所有的商品数据
+        List<CartItemVo> totalProductList = new ArrayList<>();
+        // 促销活动Id集合,用于合并促销活动
+        List<Integer> promotionsIds = new ArrayList<>();
+        // 供应商Id集合,用户判断赠品供应商是否在当前供应商中
+        List<Integer> shopIds = new ArrayList<>();
+        // 商品信息map
+        Map<String, Integer> productInfos = new HashMap<>();
+        // 前端接收商品Id信息
+        List<String> productIdList = new ArrayList<>();
+        // 用户身份
+        Integer userIdentity = baseMapper.getIdentityByUserId(userId);
+        // 超级会员标识
+        Integer svipUserId = baseMapper.getSvipUserIdByUserId(userId);
+        boolean svipUserFlag = null != svipUserId;
+        // productInfo拆解
+        try {
+            JSONArray productArr = parseArray(productInfo);
+            for (Object o : productArr) {
+                JSONObject product = (JSONObject) o;
+                String productId = product.getString("id");
+                Integer productCount = product.getInteger("count");
+                productInfos.put(productId, productCount);
+                productIdList.add(productId);
+            }
+        } catch (Exception e) {
+            log.error("组合商品信息格式错误", e);
+            return ResponseJson.error("组合商品信息格式错误!Json字符串格式[{\"id\":4351,\"count\":1},{}]", null);
+        }
+
+        // 商品的供应商列表
+        List<CartShopVo> shopList = cartClubMapper.getShopsByProductIds(productIdList);
+        //按供应商分类统计商品
+        if (null != shopList && shopList.size() > 0) {
+            // 遍历供应商列表
+            List<String> finalIdList = productIdList;//商品id列表
+            shopList.forEach(shop -> {
+                if (null != shop) {
+                    // 该供应商下商品种类
+                    AtomicInteger shopKindCount = new AtomicInteger(0);
+                    // 该供应商总价
+                    AtomicDouble shopPrice = new AtomicDouble(0);
+                    // 该供应商下参与店铺促销的商品总价
+                    AtomicDouble shopPromotionFee = new AtomicDouble(0);
+                    // 该供应商满减金额(供应商满减,单品满减)
+                    AtomicDouble shopReducedPrice = new AtomicDouble(0);
+                    // 该供应商svip优惠金额
+                    AtomicDouble shopSvipReducedPrice = new AtomicDouble(0);
+                    // 该供应商划线价
+                    AtomicDouble shopOriginalPrice = new AtomicDouble(0);
+                    // 供应商促销优惠活动
+                    PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
+                    if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen() == 1 && userIdentity == 1) {
+                        shopPromotion = null;
+                    }
+                    // 供应商下商品列表
+                    // 过滤保存已上架商品
+                    List<CartItemVo> productList = cartClubMapper.getProductsByShopIdAndProductIds(shop.getShopId(), finalIdList);
+                    productList.forEach(p -> p.setNumber(productInfos.get(p.getProductId().toString())));
+                    if (null != productList && productList.size() > 0) {
+                        // 去除价格不可见商品
+                        productList.removeIf(cartItemVo -> !(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (userIdentity == 2 || svipUserFlag))));
+                        // 去除库存不足商品
+                        productList.removeIf(cartItemVo -> !(cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber()));
+                        // 迭代器设置商品信息
+                        for (CartItemVo cartItemVo : productList) {
+                            // 设置商品图片及税费
+                            boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
+                            // 是否充值商品
+                            boolean recharge = productService.isRechargeProduct(cartItemVo.getProductId());
+                            if (recharge) {
+                                includeRecharge.set(true);
+                            }
+
+                            if (1 == cartItemVo.getSvipProductFlag()) {
+                                // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
+                                // 超级会员设置商品优惠价
+                                productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
+                                if (svipUserFlag) {
+                                    // 超级会员设置超级会员优惠总额 + 商品优惠金额
+                                    shopSvipReducedPrice.set(MathUtil.add(shopSvipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
+                                }
+                            } else {
+                                // 非超级会员优惠商品参与促销活动
+                                // 获取商品促销信息
+                                PromotionsVo promotions = null;
+                                // 没有店铺促销时,商品促销才有效 单品/凑单活动
+                                if (null == shopPromotion) {
+                                    // 获取商品促销信息
+                                    promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
+                                    // 如果促销活动协销不可见,移除促销
+                                    if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1 && userIdentity == 1) {
                                         promotions = null;
                                     }
                                     /*
@@ -847,7 +1212,7 @@ public class CartClubServiceImpl implements CartClubService {
                                         //单品满减-计算供应商总价/满减金额
                                         if (promotions.getType() == 1 && promotions.getMode() == 2) {
                                             if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
-                                                if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                                                if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                                                     //叠加优惠计算
                                                     shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
                                                     shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -910,7 +1275,7 @@ public class CartClubServiceImpl implements CartClubService {
                                         // 获取赠品
                                         List<CartItemVo> giftList = baseMapper.getPromotionGifts(shopPromotion.getId());
                                         //叠加满赠
-                                        if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                                        if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                             Integer in = floor.intValue();
                                             List<CartItemVo> g = new ArrayList<>();
                                             g.addAll(giftList);
@@ -940,7 +1305,7 @@ public class CartClubServiceImpl implements CartClubService {
                                     // 店铺满减-计算供应商总价/满减金额
                                     // 满减叠加计算
                                     if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionFee, shopPromotion.getTouchPrice()) > -1) {
-                                        if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                                        if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                             shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
                                             shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
                                         } else {
@@ -996,7 +1361,7 @@ public class CartClubServiceImpl implements CartClubService {
                 Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
                 // 凑单满减
                 if (promotions.getType() == 2 && promotions.getMode() == 2) {
-                    if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                    if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                         //叠加优惠计算
                         // 总价 - 满减金额
                         totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -1012,7 +1377,7 @@ public class CartClubServiceImpl implements CartClubService {
                     //满赠叠加
                     List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
                     //满足叠加
-                    if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                    if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                         Integer in = floor.intValue();
                         List<CartItemVo> g = new ArrayList<>();
                         g.addAll(giftList);
@@ -1126,7 +1491,7 @@ public class CartClubServiceImpl implements CartClubService {
 
         // 供应商促销优惠活动
         PromotionsVo promotions = baseMapper.getPromotionByShopId(shop.getShopId());
-        if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
+        if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1 && userIdentity == 1) {
             promotions = null;
         }
         boolean hasGift = false;
@@ -1144,7 +1509,7 @@ public class CartClubServiceImpl implements CartClubService {
                 // 获取商品促销信息
                 promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
                 //协销不可见
-                if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
+                if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1 && userIdentity == 1) {
                     promotions = null;
                 }
             } else {
@@ -1164,7 +1529,7 @@ public class CartClubServiceImpl implements CartClubService {
                     // 满减
                     if (promotions.getMode() == 2) {
                         // 总价 - 满减金额
-                        if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                        if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                             totalPrice.set(MathUtil.sub(totalPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
                             // 优惠总额 + 满减金额
                             reducedPrice.set(MathUtil.add(reducedPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -1178,7 +1543,7 @@ public class CartClubServiceImpl implements CartClubService {
                         hasGift = true;
                         List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
                         //满足叠加
-                        if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                        if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                             Integer in = floor.intValue();
                             List<CartItemVo> g = new ArrayList<>();
                             g.addAll(giftList);
@@ -1241,7 +1606,7 @@ public class CartClubServiceImpl implements CartClubService {
             Double totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice()).doubleValue();
             Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
             //满足叠加
-            if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+            if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                 Integer in = floor.intValue();
                 List<CartItemVo> g = new ArrayList<>();
                 g.addAll(giftList);

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

@@ -107,7 +107,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                 AtomicDouble shopSvipReducedPrice = new AtomicDouble(0);
                 // 供应商促销优惠活动
                 PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
-                if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen().equals("1")) {
+                if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen() == 1) {
                     shopPromotion = null;
                 }
                 // 供应商下商品列表
@@ -147,13 +147,13 @@ public class CartSellerServiceImpl implements CartSellerService {
                                 // 获取商品促销信息
                                 promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
                                 // 促销活动如果协销不可见直接置空
-                                if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1")) {
+                                if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1) {
                                     promotions = null;
                                 }
                                 /*
                                  * 设置商品促销优惠
                                  */
-                                if (null != promotions && !promotions.getSeen().equals("1")) {
+                                if (null != promotions) {
                                     BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
                                     //叠加倍数
                                     Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
@@ -164,7 +164,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                                     //单品满减-计算供应商总价/满减金额
                                     if (promotions.getType() == 1 && promotions.getMode() == 2) {
                                         if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
-                                            if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                                            if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                                                 //叠加优惠计算
                                                 shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
                                                 shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -227,7 +227,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                             // 获取赠品
                             List<CartItemVo> giftList = baseMapper.getPromotionGifts(shopPromotion.getId());
                             // 叠加赠品
-                            if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                            if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                 Integer in = floor.intValue();
                                 List<CartItemVo> g = new ArrayList<>();
                                 g.addAll(giftList);
@@ -253,7 +253,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                         totalPromotions.add(shopPromotion);
                         // 店铺满减-计算供应商总价/满减金额
                         if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPrice, shopPromotion.getTouchPrice()) > -1) {
-                            if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                            if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                 // 该供应商总价 - 满减金额
                                 shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
                                 // 该供应商优惠总额 + 满减金额
@@ -484,7 +484,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                 AtomicDouble shopSvipReducedPrice = new AtomicDouble(0);
                 // 供应商促销优惠活动
                 PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
-                if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen().equals("1")) {
+                if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen() == 1) {
                     shopPromotion = null;
                 }
                 // 供应商下商品列表
@@ -514,7 +514,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                                 // 获取商品促销信息
                                 promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
                                 // 促销活动如果协销不可见直接置空
-                                if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1")) {
+                                if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1) {
                                     promotions = null;
                                 }
                                 /*
@@ -531,7 +531,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                                     //单品满减-计算供应商总价/满减金额
                                     if (promotions.getType() == 1 && promotions.getMode() == 2) {
                                         if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
-                                            if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                                            if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                                                 //叠加优惠计算
                                                 shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
                                                 shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -582,7 +582,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                     }
                     if (shopKindCount.get() > 0) {
                         // 店铺促销
-                        if (null != shopPromotion && !shopPromotion.getSeen().equals("1")) {
+                        if (null != shopPromotion) {
                             shop.setPromotions(shopPromotion);
                             if (!promotionsIds.contains(shopPromotion.getId())) {
                                 promotionsIds.add(shopPromotion.getId());
@@ -592,7 +592,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                                     // 获取赠品
                                     List<CartItemVo> giftList = baseMapper.getPromotionGifts(shopPromotion.getId());
                                     // 叠加赠品
-                                    if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                                    if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                         Integer in = floor.intValue();
                                         List<CartItemVo> g = new ArrayList<>();
                                         g.addAll(giftList);
@@ -621,7 +621,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                                 totalPromotions.add(shopPromotion);
                                 // 店铺满减-计算供应商总价/满减金额
                                 if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionFee, shopPromotion.getTouchPrice()) > -1) {
-                                    if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
+                                    if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount() == 0 && floor > 1) {
                                         // 该供应商总价 - 满减金额
                                         shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
                                         // 该供应商优惠总额 + 满减金额
@@ -676,7 +676,7 @@ public class CartSellerServiceImpl implements CartSellerService {
             Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
             if (promotions.getType() == 2 && promotions.getMode() == 2) {
                 if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
-                    if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                    if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                         //叠加优惠计算
                         // 总价 - 满减金额
                         totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
@@ -693,7 +693,7 @@ public class CartSellerServiceImpl implements CartSellerService {
                 //满赠叠加
                 List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
                 //满足叠加
-                if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
+                if (promotions.getDiscount() != null && promotions.getDiscount() == 0 && floor > 1) {
                     Integer in = floor.intValue();
                     List<CartItemVo> g = new ArrayList<>();
                     g.addAll(giftList);

+ 9 - 10
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -377,6 +377,7 @@ public class SubmitServiceImpl implements SubmitService {
         // 订单商品列表
         List<OrderProductPo> orderProductList = new ArrayList<>();
         List<String> productIdList = new ArrayList<>();
+        Integer userIdentity = baseMapper.getIdentityByUserId(orderParamBo.getUserId());
 
         // 子订单订单列表
         List<OrderShopPo> shopOrderList = new ArrayList<>();
@@ -500,11 +501,10 @@ public class SubmitServiceImpl implements SubmitService {
                         promotions = baseMapper.getPromotionByProductId(productId);
                     }
                     //促销活动如果协销不可见,置为空
-                    Integer userIdentity = baseMapper.getIdentityByUserId(orderParamBo.getUserId());
-                    if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
+                    if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 1 && userIdentity == 1) {
                         promotions = null;
                     }
-                    if (shopPromotions != null && shopPromotions.getSeen() != null && shopPromotions.getSeen().equals("1") && userIdentity == 1) {
+                    if (shopPromotions != null && shopPromotions.getSeen() != null && shopPromotions.getSeen() == 1 && userIdentity == 1) {
                         shopPromotions = null;
                     }
                     // 计算单价
@@ -603,7 +603,7 @@ public class SubmitServiceImpl implements SubmitService {
                                 // 满减
                                 if (promotions.getMode() == 2) {
 
-                                    if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
+                                    if (promotions.getDiscount() != null && promotions.getDiscount() == 0) {
                                         //叠加优惠计算
                                         //叠加倍数
                                         Double floor = Math.floor(MathUtil.div(productFee, promotions.getTouchPrice()).doubleValue());
@@ -764,7 +764,7 @@ public class SubmitServiceImpl implements SubmitService {
                     hasActProductFlag = true;
                     // 满减
                     if (shopPromotions.getMode() == 2) {
-                        if (shopPromotions.getDiscount() != null && shopPromotions.getDiscount().equals("0")) {
+                        if (shopPromotions.getDiscount() != null && shopPromotions.getDiscount() == 0) {
                             //叠加优惠计算
                             //叠加倍数
                             Double floor = Math.floor(MathUtil.div(shopPromotionFee.get(), shopPromotions.getTouchPrice()).doubleValue());
@@ -866,16 +866,15 @@ public class SubmitServiceImpl implements SubmitService {
                         //判断是否达到满减满赠要求
                         if (MathUtil.compare(tempProductFee.get(), promotions.getTouchPrice()) >= 0) {
                             if (promotions.getMode() == 2) {
-                                if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
+                                if (promotions.getDiscount() != null && promotions.getDiscount() == 0) {
                                     //叠加优惠计算
                                     //叠加倍数
                                     Double floor = Math.floor(MathUtil.div(tempProductFee.get(), promotions.getTouchPrice()).doubleValue());
                                     // 满减
-                                    promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), MathUtil.mul(promotions.getReducedPrice(),floor)).doubleValue());
+                                    promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
                                     // 统计商品总金额
-                                    productTotalFee.set(MathUtil.sub(productTotalFee.get(), MathUtil.mul(promotions.getReducedPrice(),floor)).doubleValue());
-                                }
-                                else{
+                                    productTotalFee.set(MathUtil.sub(productTotalFee.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
+                                } else {
                                     // 满减
                                     promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), promotions.getReducedPrice()).doubleValue());
                                     // 统计商品总金额

+ 51 - 0
src/main/resources/mapper/CartClubMapper.xml

@@ -28,6 +28,22 @@
         GROUP BY c.shopID, c.cm_cartID
         ORDER BY c.cm_cartID DESC
     </select>
+
+    <select id="getShopsByProductIds" resultType="com.caimei365.order.model.vo.CartShopVo">
+        SELECT DISTINCT
+        s.shopID AS shopId,
+        s.name AS shopName,
+        s.logo AS shopLogo
+        FROM shop s
+        LEFT JOIN product p ON p.shopID = s.shopID
+        WHERE
+        p.productID in
+        <foreach collection="productIds" open="(" separator="," close=")" item="productId">
+            #{productId}
+        </foreach>
+        GROUP BY s.shopID
+    </select>
+
     <select id="getCartProductsByShopId" resultType="com.caimei365.order.model.vo.CartItemVo">
         SELECT
             c.cm_cartID AS id,
@@ -97,6 +113,41 @@
         </foreach>
         ORDER BY c.cm_cartID DESC
     </select>
+
+    <select id="getProductsByShopIdAndProductIds" resultType="com.caimei365.order.model.vo.CartItemVo">
+        SELECT
+        p.productID AS productId,
+        p.shopID AS shopId,
+        p.`name` AS `name`,
+        p.mainImage AS image,
+        p.productCode,
+        p.price1 AS price,
+        p.price1 AS originalPrice,
+        p.unit AS unit,
+        p.stock AS stock,
+        p.step AS step,
+        p.minBuyNumber AS min,
+        p.price1TextFlag AS priceFlag,
+        p.ladderPriceFlag AS ladderFlag,
+        p.includedTax AS includedTax,
+        p.invoiceType AS invoiceType,
+        p.taxPoint AS taxRate,
+        p.productCategory,
+        p.validFlag AS validFlag,
+        p.commodityType as commodityType,
+        if(csp.id is not null,1,0) as svipProductFlag,
+        csp.priceType as svipPriceType,
+        csp.discount as svipDiscount,
+        csp.discountPrice as svipDiscountPrice
+        FROM product p
+        LEFT JOIN cm_svip_product csp ON p.productID = csp.productId
+        WHERE p.shopID = #{shopId}
+        AND p.validFlag='2' AND p.productID in
+        <foreach collection="productIds" open="(" separator="," close=")" item="productId">
+            #{productId}
+        </foreach>
+    </select>
+
     <select id="getCartProductList" resultType="com.caimei365.order.model.vo.CartItemVo">
         SELECT
             c.cm_cartID AS id,