|
@@ -83,6 +83,9 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
List<CartItemVo> cartAllProducts = new ArrayList<>();
|
|
|
// 用户身份
|
|
|
Integer userIdentity = baseMapper.getIdentityByUserId(userId);
|
|
|
+ // 超级会员标识
|
|
|
+ Integer svipUserId = baseMapper.getSvipUserIdByUserId(userId);
|
|
|
+ boolean svipUserFlag = null != svipUserId;
|
|
|
if (null != shopInfoList && shopInfoList.size()>0) {
|
|
|
// 删除空数据
|
|
|
shopInfoList.removeIf(Objects::isNull);
|
|
@@ -94,6 +97,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
AtomicInteger shopKindCount = new AtomicInteger(0);
|
|
|
// 该供应商总价
|
|
|
AtomicDouble shopPrice = new AtomicDouble(0);
|
|
|
+ // 该供应商下可参与店铺促销的商品总价
|
|
|
+ AtomicDouble shopPromotionPrice = new AtomicDouble(0);
|
|
|
// 该供应商满减金额(供应商满减,单品满减)
|
|
|
AtomicDouble shopReducedPrice = new AtomicDouble(0);
|
|
|
// 供应商促销优惠活动
|
|
@@ -114,55 +119,71 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 默认所有商品未选中状态(前端要求)
|
|
|
cartItemVo.setIsChecked(false);
|
|
|
// 价格是否可见
|
|
|
- boolean priceVisible = (cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && userIdentity == 2));
|
|
|
+ boolean priceVisible = (cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && userIdentity == 2) || svipUserFlag);
|
|
|
// 是否库存充足
|
|
|
boolean isStocked = (cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber());
|
|
|
if (priceVisible && isStocked) {
|
|
|
- // 获取商品促销信息
|
|
|
- PromotionsVo promotions = null;
|
|
|
- // 没有店铺促销时,商品促销才有效
|
|
|
- if (null == shopPromotion) {
|
|
|
+ if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ // 超级会员设置商品优惠价
|
|
|
+ productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
+ if (svipUserFlag) {
|
|
|
+ // 超级会员设置供应商价格-商品优惠金额,店铺优惠总额 + 商品优惠金额
|
|
|
+ shopPrice.set(MathUtil.sub(shopPrice.get(), cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
+ shopReducedPrice.set(MathUtil.add(shopReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
// 获取商品促销信息
|
|
|
- promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
- /*
|
|
|
- * 设置商品促销优惠
|
|
|
- */
|
|
|
- if (null != promotions) {
|
|
|
- // 当前促销活动的价格计算列表
|
|
|
- List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
- // 更新到总促销列表
|
|
|
- productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList);
|
|
|
- //单品满减-计算供应商总价/满减金额
|
|
|
- if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
- BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
- if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
|
|
|
- // 如果满足促销条件,设置供应商价格-满减金额,满减总额 + 当前促销满减金额
|
|
|
- shopPrice.set(MathUtil.sub(shopPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- shopReducedPrice.set(MathUtil.add(shopReducedPrice, promotions.getReducedPrice()).doubleValue());
|
|
|
+ PromotionsVo promotions = null;
|
|
|
+ // 没有店铺促销时,商品促销才有效
|
|
|
+ if (null == shopPromotion) {
|
|
|
+ // 获取商品促销信息
|
|
|
+ promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ /*
|
|
|
+ * 设置商品促销优惠
|
|
|
+ */
|
|
|
+ if (null != promotions) {
|
|
|
+ // 当前促销活动的价格计算列表
|
|
|
+ List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
+ // 更新到总促销列表
|
|
|
+ productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList);
|
|
|
+ //单品满减-计算供应商总价/满减金额
|
|
|
+ if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
+ BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
+ if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
|
|
|
+ // 如果满足促销条件,设置供应商价格-满减金额,满减总额 + 当前促销满减金额
|
|
|
+ shopPrice.set(MathUtil.sub(shopPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ shopReducedPrice.set(MathUtil.add(shopReducedPrice, promotions.getReducedPrice()).doubleValue());
|
|
|
+ }
|
|
|
}
|
|
|
+ cartItemVo.setPromotions(promotions);
|
|
|
}
|
|
|
- cartItemVo.setPromotions(promotions);
|
|
|
}
|
|
|
- }
|
|
|
- if (null != promotions || null != shopPromotion) {
|
|
|
- // 商品处于活动状态
|
|
|
- cartItemVo.setActStatus(1);
|
|
|
- // 关闭阶梯价格,活动优先
|
|
|
- cartItemVo.setLadderFlag(0);
|
|
|
- } else {
|
|
|
- if (cartItemVo.getLadderFlag() == 1) {
|
|
|
- // 设置阶梯价
|
|
|
- productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ if (null != promotions || null != shopPromotion) {
|
|
|
+ // 商品处于活动状态
|
|
|
+ cartItemVo.setActStatus(1);
|
|
|
+ // 关闭阶梯价格,活动优先
|
|
|
+ cartItemVo.setLadderFlag(0);
|
|
|
} else {
|
|
|
- // 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
- if (null != repurchase && repurchase > 0) {
|
|
|
- cartItemVo.setPrice(repurchase);
|
|
|
+ if (cartItemVo.getLadderFlag() == 1) {
|
|
|
+ // 设置阶梯价
|
|
|
+ productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ } else {
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
+ if (null != repurchase && repurchase > 0) {
|
|
|
+ cartItemVo.setPrice(repurchase);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 该供应商下价格累加
|
|
|
shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
|
|
|
+ // 该供应商下可参与店铺促销的商品价格累加
|
|
|
+ if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
|
|
|
+ // 超级会员购买svip商品不享受店铺促销优惠
|
|
|
+ shopPromotionPrice.set(MathUtil.add(shopPromotionPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
|
|
|
+ }
|
|
|
// 该供应商下商品种类 +1
|
|
|
shopKindCount.incrementAndGet();
|
|
|
// 购物车总数量 + 当前商品购买数量
|
|
@@ -223,17 +244,20 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 设置该优惠下的商品列表
|
|
|
List<PromotionPriceVo> promotionPriceList = new ArrayList<>();
|
|
|
productList.forEach(item -> {
|
|
|
- PromotionPriceVo promotionPrice = new PromotionPriceVo();
|
|
|
- promotionPrice.setProductId(item.getProductId());
|
|
|
- promotionPrice.setNumber(item.getNumber());
|
|
|
- promotionPrice.setPrice(item.getPrice());
|
|
|
- promotionPriceList.add(promotionPrice);
|
|
|
+ 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(shopPrice, shopPromotion.getTouchPrice()) > -1) {
|
|
|
+ if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionPrice, shopPromotion.getTouchPrice()) > -1) {
|
|
|
// 该供应商总价 - 满减金额
|
|
|
shopPrice.set(MathUtil.sub(shopPrice.get(), shopPromotion.getReducedPrice()).doubleValue());
|
|
|
// 该供应商优惠总额 + 满减金额
|
|
@@ -632,6 +656,9 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
List<Integer> shopIds = new ArrayList<>();
|
|
|
// 用户身份
|
|
|
Integer userIdentity = baseMapper.getIdentityByUserId(userId);
|
|
|
+ // 超级会员标识
|
|
|
+ Integer svipUserId = baseMapper.getSvipUserIdByUserId(userId);
|
|
|
+ boolean svipUserFlag = null != svipUserId;
|
|
|
|
|
|
// 前端接收商品Id信息
|
|
|
List<String> productIdList = new ArrayList<>();
|
|
@@ -652,6 +679,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
AtomicInteger shopKindCount = new AtomicInteger(0);
|
|
|
// 该供应商总价
|
|
|
AtomicDouble shopPrice = new AtomicDouble(0);
|
|
|
+ // 该供应商下参与店铺促销的商品总价
|
|
|
+ AtomicDouble shopPromotionPrice = new AtomicDouble(0);
|
|
|
// 该供应商满减金额(供应商满减,单品满减)
|
|
|
AtomicDouble shopReducedPrice = new AtomicDouble(0);
|
|
|
// 供应商促销优惠活动
|
|
@@ -672,51 +701,67 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (recharge) {
|
|
|
includeRecharge.set(true);
|
|
|
}
|
|
|
- // 获取商品促销信息
|
|
|
- PromotionsVo promotions = null;
|
|
|
- // 没有店铺促销时,商品促销才有效
|
|
|
- if (null == shopPromotion) {
|
|
|
+ if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ // 超级会员设置商品优惠价
|
|
|
+ productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
+ if (svipUserFlag) {
|
|
|
+ // 超级会员设置供应商价格-商品优惠金额,店铺优惠总额 + 商品优惠金额
|
|
|
+ shopPrice.set(MathUtil.sub(shopPrice.get(), cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
+ shopReducedPrice.set(MathUtil.add(shopReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
// 获取商品促销信息
|
|
|
- promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
- /*
|
|
|
- * 设置商品促销优惠
|
|
|
- */
|
|
|
- if (null != promotions) {
|
|
|
- // 当前促销活动的价格计算列表
|
|
|
- List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
- // 更新到总促销列表
|
|
|
- productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList);
|
|
|
- //单品满减-计算供应商总价/满减金额
|
|
|
- if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
- BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
- if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
|
|
|
- // 如果满足促销条件,设置供应商价格-满减金额,满减总额 + 当前促销满减金额
|
|
|
- shopPrice.set(MathUtil.sub(shopPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- shopReducedPrice.set(MathUtil.add(shopReducedPrice, promotions.getReducedPrice()).doubleValue());
|
|
|
+ PromotionsVo promotions = null;
|
|
|
+ // 没有店铺促销时,商品促销才有效
|
|
|
+ if (null == shopPromotion) {
|
|
|
+ // 获取商品促销信息
|
|
|
+ promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ /*
|
|
|
+ * 设置商品促销优惠
|
|
|
+ */
|
|
|
+ if (null != promotions) {
|
|
|
+ // 当前促销活动的价格计算列表
|
|
|
+ List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
+ // 更新到总促销列表
|
|
|
+ productService.updateTotalPromotions(totalPromotions, promotionsIds, promotions, promotionPriceList);
|
|
|
+ //单品满减-计算供应商总价/满减金额
|
|
|
+ if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
+ BigDecimal totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice());
|
|
|
+ if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) > -1) {
|
|
|
+ // 如果满足促销条件,设置供应商价格-满减金额,满减总额 + 当前促销满减金额
|
|
|
+ shopPrice.set(MathUtil.sub(shopPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ shopReducedPrice.set(MathUtil.add(shopReducedPrice, promotions.getReducedPrice()).doubleValue());
|
|
|
+ }
|
|
|
}
|
|
|
+ cartItemVo.setPromotions(promotions);
|
|
|
}
|
|
|
- cartItemVo.setPromotions(promotions);
|
|
|
}
|
|
|
- }
|
|
|
- if (null != promotions || null != shopPromotion) {
|
|
|
- // 商品处于活动状态
|
|
|
- cartItemVo.setActStatus(1);
|
|
|
- // 关闭阶梯价格,活动优先
|
|
|
- cartItemVo.setLadderFlag(0);
|
|
|
- } else {
|
|
|
- if (cartItemVo.getLadderFlag() == 1) {
|
|
|
- // 设置阶梯价
|
|
|
- productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ if (null != promotions || null != shopPromotion) {
|
|
|
+ // 商品处于活动状态
|
|
|
+ cartItemVo.setActStatus(1);
|
|
|
+ // 关闭阶梯价格,活动优先
|
|
|
+ cartItemVo.setLadderFlag(0);
|
|
|
} else {
|
|
|
- // 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
- if (null != repurchase && repurchase > 0) {
|
|
|
- cartItemVo.setPrice(repurchase);
|
|
|
+ if (cartItemVo.getLadderFlag() == 1) {
|
|
|
+ // 设置阶梯价
|
|
|
+ productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ } else {
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), userId);
|
|
|
+ if (null != repurchase && repurchase > 0) {
|
|
|
+ cartItemVo.setPrice(repurchase);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 该供应商下价格累加
|
|
|
shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
|
|
|
+ // 该供应商下可参与店铺促销的商品价格累加
|
|
|
+ if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
|
|
|
+ // 超级会员购买svip商品不享受店铺促销优惠
|
|
|
+ shopPromotionPrice.set(MathUtil.add(shopPromotionPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
|
|
|
+ }
|
|
|
// 该供应商下商品种类 +1
|
|
|
shopKindCount.incrementAndGet();
|
|
|
// 总数量 + 当前商品购买数量
|
|
@@ -737,17 +782,20 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 设置该优惠下的商品列表
|
|
|
List<PromotionPriceVo> promotionPriceList = new ArrayList<>();
|
|
|
productList.forEach(item -> {
|
|
|
- PromotionPriceVo promotionPrice = new PromotionPriceVo();
|
|
|
- promotionPrice.setProductId(item.getProductId());
|
|
|
- promotionPrice.setNumber(item.getNumber());
|
|
|
- promotionPrice.setPrice(item.getPrice());
|
|
|
- promotionPriceList.add(promotionPrice);
|
|
|
+ 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(shopPrice, shopPromotion.getTouchPrice()) > -1) {
|
|
|
+ if (shopPromotion.getMode() == 2 && MathUtil.compare(shopPromotionPrice, shopPromotion.getTouchPrice()) > -1) {
|
|
|
// 该供应商总价 - 满减金额
|
|
|
shopPrice.set(MathUtil.sub(shopPrice.get(), shopPromotion.getReducedPrice()).doubleValue());
|
|
|
// 该供应商优惠总额 + 满减金额
|