|
@@ -951,6 +951,9 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
}
|
|
|
// 用户身份
|
|
|
Integer userIdentity = baseMapper.getIdentityByUserId(cartDto.getUserId());
|
|
|
+ // 超级会员标识
|
|
|
+ Integer svipUserId = baseMapper.getSvipUserIdByUserId(cartDto.getUserId());
|
|
|
+ boolean svipUserFlag = null != svipUserId;
|
|
|
// 价格不可见商品
|
|
|
if (!(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && userIdentity == 2))) {
|
|
|
return ResponseJson.error("商品价格不可见!", null);
|
|
@@ -973,76 +976,88 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
AtomicDouble totalPrice = new AtomicDouble(0);
|
|
|
// 统计总促销满减
|
|
|
AtomicDouble reducedPrice = new AtomicDouble(0);
|
|
|
+ // svip优惠金额
|
|
|
+ AtomicDouble svipReducedPrice = new AtomicDouble(0);
|
|
|
|
|
|
// 供应商促销优惠活动
|
|
|
PromotionsVo promotions = baseMapper.getPromotionByShopId(shop.getShopId());
|
|
|
- // 没有店铺促销时,商品促销才有效
|
|
|
- if (null == promotions) {
|
|
|
- // 获取商品促销信息
|
|
|
- promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
- } else {
|
|
|
- shop.setPromotions(promotions);
|
|
|
- }
|
|
|
- /*
|
|
|
- * 设置商品促销优惠
|
|
|
- */
|
|
|
- if (null != promotions) {
|
|
|
- // 当前促销活动的价格计算列表
|
|
|
- List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
- promotions.setProductList(promotionPriceList);
|
|
|
- Double totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice()).doubleValue();
|
|
|
- // 满足促销条件
|
|
|
- if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
|
|
|
- // 满减
|
|
|
- if (promotions.getMode() == 2) {
|
|
|
- // 总价 - 满减金额
|
|
|
- totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- // 优惠总额 + 满减金额
|
|
|
- reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- } else if (promotions.getMode() == 3) {
|
|
|
- // 满赠
|
|
|
- List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
- giftList.forEach(gift -> {
|
|
|
- if (shopIds.contains(gift.getShopId())) {
|
|
|
- // 赠品在当前订单内的供应商下
|
|
|
- shopList.forEach(s -> {
|
|
|
- if (s.getShopId().equals(gift.getShopId())) {
|
|
|
- s.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);
|
|
|
- }
|
|
|
- });
|
|
|
- promotions.setGiftList(giftList);
|
|
|
- }
|
|
|
+ if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ // 超级会员设置商品优惠价
|
|
|
+ productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
+ if (svipUserFlag) {
|
|
|
+ // 超级会员设置超级会员优惠总额 + 商品优惠金额
|
|
|
+ svipReducedPrice.set(MathUtil.add(svipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
}
|
|
|
- // 添加到总促销
|
|
|
- totalPromotions.add(promotions);
|
|
|
- // 商品处于活动状态
|
|
|
- cartItemVo.setActStatus(1);
|
|
|
- // 关闭阶梯价格,活动优先
|
|
|
- cartItemVo.setLadderFlag(0);
|
|
|
- cartItemVo.setPromotions(promotions);
|
|
|
} else {
|
|
|
- cartItemVo.setActStatus(0);
|
|
|
- if (cartItemVo.getLadderFlag() == 1) {
|
|
|
- // 设置阶梯价
|
|
|
- productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ // 没有店铺促销时,商品促销才有效
|
|
|
+ if (null == promotions) {
|
|
|
+ // 获取商品促销信息
|
|
|
+ promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
} else {
|
|
|
- // 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), cartDto.getUserId());
|
|
|
- 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);
|
|
|
+ shop.setPromotions(promotions);
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 设置商品促销优惠
|
|
|
+ */
|
|
|
+ if (null != promotions) {
|
|
|
+ // 当前促销活动的价格计算列表
|
|
|
+ List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
|
|
|
+ promotions.setProductList(promotionPriceList);
|
|
|
+ Double totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice()).doubleValue();
|
|
|
+ // 满足促销条件
|
|
|
+ if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
|
|
|
+ // 满减
|
|
|
+ if (promotions.getMode() == 2) {
|
|
|
+ // 总价 - 满减金额
|
|
|
+ totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ // 优惠总额 + 满减金额
|
|
|
+ reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ } else if (promotions.getMode() == 3) {
|
|
|
+ // 满赠
|
|
|
+ List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
+ giftList.forEach(gift -> {
|
|
|
+ if (shopIds.contains(gift.getShopId())) {
|
|
|
+ // 赠品在当前订单内的供应商下
|
|
|
+ shopList.forEach(s -> {
|
|
|
+ if (s.getShopId().equals(gift.getShopId())) {
|
|
|
+ s.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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ promotions.setGiftList(giftList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 添加到总促销
|
|
|
+ totalPromotions.add(promotions);
|
|
|
+ // 商品处于活动状态
|
|
|
+ cartItemVo.setActStatus(1);
|
|
|
+ // 关闭阶梯价格,活动优先
|
|
|
+ cartItemVo.setLadderFlag(0);
|
|
|
+ cartItemVo.setPromotions(promotions);
|
|
|
+ } else {
|
|
|
+ cartItemVo.setActStatus(0);
|
|
|
+ if (cartItemVo.getLadderFlag() == 1) {
|
|
|
+ // 设置阶梯价
|
|
|
+ productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ } else {
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getProductId(), cartDto.getUserId());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1061,6 +1076,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
shop.setReducedPrice(reducedPrice.get());
|
|
|
// 供应商划线价
|
|
|
shop.setOriginalPrice(originalPrice.get());
|
|
|
+ // svip优惠金额
|
|
|
+ shop.setSvipReducedPrice(svipReducedPrice.get());
|
|
|
// 当前供应商添加到首位
|
|
|
shopList.add(0, shop);
|
|
|
|
|
@@ -1085,6 +1102,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
resultData.put("totalCount", cartDto.getProductCount());
|
|
|
resultData.put("totalPrice", totalPrice.get());
|
|
|
resultData.put("reducedPrice", reducedPrice.get());
|
|
|
+ resultData.put("svipReducedPrice", svipReducedPrice.get());
|
|
|
resultData.put("totalOriginalPrice", originalPrice.get());
|
|
|
resultData.put("invoice", invoice);
|
|
|
resultData.put("userMoney", availableMoney);
|