|
@@ -82,6 +82,9 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
List<Integer> promotionsIds = new ArrayList<>();
|
|
|
// 获取机构用户Id
|
|
|
Integer clubUserId = baseMapper.getUserIdByClubId(clubId);
|
|
|
+ // 超级会员标识
|
|
|
+ Integer svipUserId = baseMapper.getSvipUserIdByClubId(clubId);
|
|
|
+ boolean svipUserFlag = null != svipUserId;
|
|
|
// 开始分页请求供应商数据
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
// 协销购物车供应商列表
|
|
@@ -96,8 +99,12 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
AtomicInteger shopKindCount = new AtomicInteger(0);
|
|
|
// 该供应商总价
|
|
|
AtomicDouble shopPrice = new AtomicDouble(0);
|
|
|
- // 该供应商满减金额(svip优惠,供应商满减,单品满减)
|
|
|
+ // 该供应商下参与店铺促销的商品总价
|
|
|
+ AtomicDouble shopPromotionFee = new AtomicDouble(0);
|
|
|
+ // 该供应商满减金额(供应商满减,单品满减)
|
|
|
AtomicDouble shopReducedPrice = new AtomicDouble(0);
|
|
|
+ // 该供应商svip优惠金额
|
|
|
+ AtomicDouble shopSvipReducedPrice = new AtomicDouble(0);
|
|
|
// 供应商促销优惠活动
|
|
|
PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
|
|
|
// 供应商下商品列表
|
|
@@ -121,50 +128,60 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
cartItemVo.setStatus(0);
|
|
|
// 设置商品图片及税费
|
|
|
boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
|
|
|
- // 获取商品促销信息
|
|
|
- PromotionsVo promotions = null;
|
|
|
- // 没有店铺促销时,商品促销才有效
|
|
|
- if (null == shopPromotion) {
|
|
|
+ if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ // 超级会员设置商品优惠价
|
|
|
+ productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
+ if (svipUserFlag) {
|
|
|
+ // 超级会员设置超级会员优惠总额 + 商品优惠金额
|
|
|
+ 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(), clubUserId);
|
|
|
- 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);
|
|
|
+ if (cartItemVo.getLadderFlag() == 1) {
|
|
|
+ // 设置阶梯价
|
|
|
+ productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ } else {
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), clubUserId);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -175,6 +192,11 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
}
|
|
|
// 该供应商下价格累加
|
|
|
shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
|
|
|
+ // 该供应商下可参与店铺促销的商品价格累加
|
|
|
+ if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
|
|
|
+ // 超级会员购买svip商品不享受店铺促销优惠
|
|
|
+ shopPromotionFee.set(MathUtil.add(shopPromotionFee, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
|
|
|
+ }
|
|
|
// 该供应商下商品种类 +1
|
|
|
shopKindCount.incrementAndGet();
|
|
|
}
|
|
@@ -215,10 +237,14 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
shop.setCartList(productList);
|
|
|
// 供应商总价
|
|
|
shop.setTotalPrice(shopPrice.get());
|
|
|
+ // 当有超级会员优惠时,取超级会员优惠
|
|
|
+ Double shopReduction = MathUtil.compare(shopSvipReducedPrice, 0) > 0 ? shopSvipReducedPrice.get() : shopReducedPrice.get();
|
|
|
// 供应商总优惠
|
|
|
shop.setReducedPrice(shopReducedPrice.get());
|
|
|
+ // 供应商总超级会员优惠
|
|
|
+ shop.setSvipReducedPrice(shopSvipReducedPrice.get());
|
|
|
// 供应商划线价
|
|
|
- shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReducedPrice.get()).doubleValue());
|
|
|
+ shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReduction).doubleValue());
|
|
|
// 供应商下商品种类
|
|
|
shop.setCount(shopKindCount.get());
|
|
|
});
|
|
@@ -417,8 +443,10 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
AtomicDouble shopPrice = new AtomicDouble(0);
|
|
|
// 该供应商下参与店铺促销的商品总价
|
|
|
AtomicDouble shopPromotionFee = new AtomicDouble(0);
|
|
|
- // 该供应商满减金额(svip优惠,供应商满减,单品满减)
|
|
|
+ // 该供应商满减金额(供应商满减,单品满减)
|
|
|
AtomicDouble shopReducedPrice = new AtomicDouble(0);
|
|
|
+ // 该供应商svip优惠金额
|
|
|
+ AtomicDouble shopSvipReducedPrice = new AtomicDouble(0);
|
|
|
// 供应商促销优惠活动
|
|
|
PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
|
|
|
// 供应商下商品列表
|
|
@@ -437,8 +465,7 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
// 超级会员设置商品优惠价
|
|
|
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{
|
|
@@ -543,10 +570,14 @@ public class CartSellerServiceImpl implements CartSellerService {
|
|
|
shop.setCartList(productList);
|
|
|
// 供应商总价
|
|
|
shop.setTotalPrice(shopPrice.get());
|
|
|
+ // 当有超级会员优惠时,取超级会员优惠
|
|
|
+ Double shopReduction = MathUtil.compare(shopSvipReducedPrice, 0) > 0 ? shopSvipReducedPrice.get() : shopReducedPrice.get();
|
|
|
// 供应商总优惠
|
|
|
shop.setReducedPrice(shopReducedPrice.get());
|
|
|
+ // 供应商总超级会员优惠
|
|
|
+ shop.setSvipReducedPrice(shopSvipReducedPrice.get());
|
|
|
// 供应商划线价
|
|
|
- shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReducedPrice.get()).doubleValue());
|
|
|
+ shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReduction).doubleValue());
|
|
|
|
|
|
// 添加供应商Id集合
|
|
|
shopIds.add(shop.getShopId());
|