|
@@ -110,6 +110,9 @@ 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) {
|
|
|
+ shopPromotion = null;
|
|
|
+ }
|
|
|
// 供应商下商品列表 ,购物车里的该供应商商品
|
|
|
List<CartItemVo> productList = cartClubMapper.getCartProductsByShopId(shop.getShopId(), userId);
|
|
|
|
|
@@ -155,16 +158,16 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (null != promotions) {
|
|
|
// 当前促销活动的价格计算列表
|
|
|
List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
+ BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
+ Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
|
|
|
// 更新到总促销列表
|
|
|
- productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList);
|
|
|
+ productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList, floor);
|
|
|
//单品满减-计算供应商总价/满减金额
|
|
|
// 叠加优惠计算
|
|
|
if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
- BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
- if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
|
|
|
//叠加优惠计算
|
|
|
//叠加倍数
|
|
|
- Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
|
|
|
shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
} else {
|
|
@@ -259,9 +262,21 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (!promotionsIds.contains(shopPromotion.getId())) {
|
|
|
promotionsIds.add(shopPromotion.getId());
|
|
|
// 店铺满赠
|
|
|
+ Double floor = Math.floor(MathUtil.div(shopPromotionFee, shopPromotion.getTouchPrice()).doubleValue());
|
|
|
if (shopPromotion.getMode() == 3) {
|
|
|
// 获取赠品
|
|
|
List<CartItemVo> giftList = baseMapper.getPromotionGifts(shopPromotion.getId());
|
|
|
+ // 叠加赠品
|
|
|
+ if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("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);
|
|
|
}
|
|
|
// 设置该优惠下的商品列表
|
|
@@ -281,10 +296,17 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
totalPromotions.add(shopPromotion);
|
|
|
// 店铺满减-计算供应商总价/满减金额
|
|
|
if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionFee, shopPromotion.getTouchPrice()) > -1) {
|
|
|
- // 该供应商总价 - 满减金额
|
|
|
- shopPrice.set(MathUtil.sub(shopPrice.get(), shopPromotion.getReducedPrice()).doubleValue());
|
|
|
- // 该供应商优惠总额 + 满减金额
|
|
|
- shopReducedPrice.set(MathUtil.add(shopReducedPrice.get(), shopPromotion.getReducedPrice()).doubleValue());
|
|
|
+ if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0") && floor > 1) {
|
|
|
+ // 该供应商总价 - 满减金额
|
|
|
+ shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(shopPromotion.getReducedPrice(), floor)).doubleValue());
|
|
|
+ // 该供应商优惠总额 + 满减金额
|
|
|
+ shopReducedPrice.set(MathUtil.add(shopReducedPrice.get(), 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());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -320,11 +342,11 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (promotions.getType() == 2 && promotions.getMode() == 2) {
|
|
|
// 该促销内商品总价
|
|
|
double touchPrice = promotions.getProductList().stream().mapToDouble(product -> product.getNumber() * product.getPrice()).sum();
|
|
|
+ //叠加倍数
|
|
|
+ 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")) {
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
|
|
|
//叠加优惠计算
|
|
|
- //叠加倍数
|
|
|
- Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
|
|
|
// 总价 - 满减金额
|
|
|
totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
// 优惠总额 + 满减金额
|
|
@@ -508,6 +530,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
* 设置商品促销优惠
|
|
|
*/
|
|
|
if (null != promotions) {
|
|
|
+ BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
+ Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
|
|
|
// 关闭阶梯价格,活动优先
|
|
|
cartItemVo.setLadderFlag(0);
|
|
|
// 商品处于活动状态
|
|
@@ -515,7 +539,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 当前促销活动的价格计算列表
|
|
|
List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
// 更新到总促销列表
|
|
|
- productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList);
|
|
|
+ productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList, floor);
|
|
|
} else {
|
|
|
if (cartItemVo.getLadderFlag() == 1) {
|
|
|
// 设置阶梯价
|
|
@@ -549,11 +573,11 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (promotions.getMode() == 2) {
|
|
|
// 该促销内商品总价
|
|
|
double touchPrice = promotions.getProductList().stream().mapToDouble(product -> product.getNumber() * product.getPrice()).sum();
|
|
|
+ //叠加倍数
|
|
|
+ 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")) {
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
|
|
|
//叠加优惠计算
|
|
|
- //叠加倍数
|
|
|
- Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
|
|
|
// 总价 - 满减金额
|
|
|
totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
} else {
|
|
@@ -768,6 +792,9 @@ 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) {
|
|
|
+ shopPromotion = null;
|
|
|
+ }
|
|
|
// 供应商下商品列表
|
|
|
// 过滤保存已上架商品
|
|
|
List<CartItemVo> productList = cartClubMapper.getCartProductsByShopIdAndProductIds(userId, shop.getShopId(), finalIdList);
|
|
@@ -810,18 +837,18 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
* 设置商品促销优惠
|
|
|
*/
|
|
|
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);
|
|
|
+ productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList, floor);
|
|
|
//单品满减-计算供应商总价/满减金额
|
|
|
if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
- BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
|
|
|
- if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
|
|
|
//叠加优惠计算
|
|
|
- //叠加倍数
|
|
|
- Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
|
|
|
shopPrice.set(MathUtil.sub(shopPrice.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
shopReducedPrice.set(MathUtil.add(shopReducedPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
} else {
|
|
@@ -883,17 +910,17 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 获取赠品
|
|
|
List<CartItemVo> giftList = baseMapper.getPromotionGifts(shopPromotion.getId());
|
|
|
//叠加满赠
|
|
|
- if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0")) {
|
|
|
- Integer in = Integer.valueOf(String.valueOf(floor));
|
|
|
+ if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("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(giftList);
|
|
|
+ giftList.addAll(g);
|
|
|
}
|
|
|
}
|
|
|
- shopPromotion.setGiftList(giftList);
|
|
|
- } else {
|
|
|
- shopPromotion.setGiftList(giftList);
|
|
|
}
|
|
|
+ shopPromotion.setGiftList(giftList);
|
|
|
}
|
|
|
// 设置该优惠下的商品列表
|
|
|
List<PromotionPriceVo> promotionPriceList = new ArrayList<>();
|
|
@@ -913,7 +940,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 店铺满减-计算供应商总价/满减金额
|
|
|
// 满减叠加计算
|
|
|
if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionFee, shopPromotion.getTouchPrice()) > -1) {
|
|
|
- if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("0")) {
|
|
|
+ if (shopPromotion.getDiscount() != null && shopPromotion.getDiscount().equals("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 {
|
|
@@ -965,16 +992,16 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
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().equals("0")) {
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("0") && floor > 1) {
|
|
|
//叠加优惠计算
|
|
|
- //叠加倍数
|
|
|
- Double floor = Math.floor(MathUtil.div(touchPrice, promotions.getTouchPrice()).doubleValue());
|
|
|
// 总价 - 满减金额
|
|
|
- totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(),floor)).doubleValue());
|
|
|
+ totalPrice.set(MathUtil.sub(totalPrice, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
|
|
|
// 优惠总额 + 满减金额
|
|
|
- reducedPrice.set(MathUtil.add(reducedPrice, 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());
|
|
@@ -982,6 +1009,20 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
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().equals("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())) {
|
|
@@ -1085,6 +1126,9 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
|
|
|
// 供应商促销优惠活动
|
|
|
PromotionsVo promotions = baseMapper.getPromotionByShopId(shop.getShopId());
|
|
|
+ if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
|
|
|
+ promotions = null;
|
|
|
+ }
|
|
|
boolean hasGift = false;
|
|
|
if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
// 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
@@ -1099,6 +1143,10 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (null == promotions) {
|
|
|
// 获取商品促销信息
|
|
|
promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ //协销不可见
|
|
|
+ if (promotions != null && promotions.getSeen() != null && promotions.getSeen().equals("1") && userIdentity == 1) {
|
|
|
+ promotions = null;
|
|
|
+ }
|
|
|
} else {
|
|
|
shop.setPromotions(promotions);
|
|
|
}
|
|
@@ -1110,13 +1158,13 @@ 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();
|
|
|
+ Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
|
|
|
// 满足促销条件
|
|
|
if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
|
|
|
- Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
|
|
|
// 满减
|
|
|
if (promotions.getMode() == 2) {
|
|
|
// 总价 - 满减金额
|
|
|
- if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("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());
|
|
@@ -1128,20 +1176,19 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
} else if (promotions.getMode() == 3) {
|
|
|
// 满足满赠
|
|
|
hasGift = true;
|
|
|
+ List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
//满足叠加
|
|
|
- if (promotions.getDiscount() != null && promotions.getDiscount().equals("0")) {
|
|
|
- List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
- Integer in = Integer.valueOf(String.valueOf(floor));
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount().equals("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(giftList);
|
|
|
+ giftList.addAll(g);
|
|
|
}
|
|
|
}
|
|
|
- promotions.setGiftList(giftList);
|
|
|
- } else {
|
|
|
- List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
- promotions.setGiftList(giftList);
|
|
|
}
|
|
|
+ promotions.setGiftList(giftList);
|
|
|
}
|
|
|
}
|
|
|
// 添加到总促销
|
|
@@ -1190,6 +1237,22 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
shopList.add(0, shop);
|
|
|
// 满足促销满赠
|
|
|
if (hasGift) {
|
|
|
+ List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
+ 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) {
|
|
|
+ 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())) {
|
|
|
// 赠品在当前订单内的供应商下
|