|
@@ -166,153 +166,175 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
} else {
|
|
|
cartItemVo.setSkus(orderClubMapper.getOrganizeSku(cartItemVo.getProductId()));
|
|
|
}
|
|
|
- // 设置商品图片及税费
|
|
|
- boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
|
|
|
- // 商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
|
|
|
- Integer visibility = cartItemVo.getVisibility();
|
|
|
- boolean visibleFlag = visibility == 3 || visibility == 2 || (visibility == 1 && (finalUserIdentity == 2 || svipUserFlag)) || (visibility == 4 && finalUserClubType == 1);
|
|
|
- if (!visibleFlag) {
|
|
|
- //不可见商品 不加入失效商品,直接去除
|
|
|
- productIterator.remove();
|
|
|
- }
|
|
|
- // 已上架商品
|
|
|
- else if (cartItemVo.getValidFlag() == 2) {
|
|
|
- // 设置商品有效
|
|
|
- cartItemVo.setStatus(0);
|
|
|
- // 默认所有商品未选中状态(前端要求)
|
|
|
- cartItemVo.setIsChecked(false);
|
|
|
- // 价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
|
|
|
- boolean priceVisible = (cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && finalUserClubType == 1));
|
|
|
- // 是否库存充足 只看所有sku的stock是否为0
|
|
|
-// boolean isStocked = (cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber());
|
|
|
- boolean isStocked = orderCommonMapper.findMaxStock(cartItemVo.getProductId()) > 0;
|
|
|
- if (priceVisible && isStocked) {
|
|
|
- if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
- // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
- // 超级会员设置商品优惠价
|
|
|
- productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
- if (svipUserFlag) {
|
|
|
- // 超级会员设置超级会员优惠总额 + 商品优惠金额
|
|
|
- shopSvipReducedPrice.set(MathUtil.add(shopSvipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
- }
|
|
|
- } else {
|
|
|
- //失效无库存不统计
|
|
|
- totalCount.updateAndGet(v -> v - 1);
|
|
|
- kindCount.updateAndGet(v -> v - 1);
|
|
|
- // 获取商品促销信息
|
|
|
- PromotionsVo promotions = null;
|
|
|
- // 没有店铺促销时,商品促销才有效
|
|
|
- if (null == shopPromotion) {
|
|
|
- // 获取商品促销信息
|
|
|
- promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
- // 促销活动如果协销不可见直接置空
|
|
|
- if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && finalUserIdentity == 1) {
|
|
|
- promotions = null;
|
|
|
- }
|
|
|
- /*
|
|
|
- * 设置商品促销优惠
|
|
|
- */
|
|
|
- if (null != promotions) {
|
|
|
- if (1 == promotions.getMode()) {
|
|
|
- promotions.setTouchPrice(baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(), promotions.getId()));
|
|
|
+ if (0 == organizeId) {
|
|
|
+ // 设置商品图片及税费
|
|
|
+ boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
|
|
|
+ // 商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
|
|
|
+ Integer visibility = cartItemVo.getVisibility();
|
|
|
+ boolean visibleFlag = visibility == 3 || visibility == 2 || (visibility == 1 && (finalUserIdentity == 2 || svipUserFlag)) || (visibility == 4 && finalUserClubType == 1);
|
|
|
+ if (!visibleFlag) {
|
|
|
+ //不可见商品 不加入失效商品,直接去除
|
|
|
+ productIterator.remove();
|
|
|
+ }
|
|
|
+ // 已上架商品
|
|
|
+ else if (cartItemVo.getValidFlag() == 2) {
|
|
|
+ // 设置商品有效
|
|
|
+ cartItemVo.setStatus(0);
|
|
|
+ // 默认所有商品未选中状态(前端要求)
|
|
|
+ cartItemVo.setIsChecked(false);
|
|
|
+ // 价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
|
|
|
+ boolean priceVisible = (cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && finalUserClubType == 1));
|
|
|
+ // 是否库存充足 只看所有sku的stock是否为0
|
|
|
+ // boolean isStocked = (cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber());
|
|
|
+ boolean isStocked = orderCommonMapper.findMaxStock(cartItemVo.getProductId()) > 0;
|
|
|
+ if (priceVisible && isStocked) {
|
|
|
+ if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ // 超级会员设置商品优惠价
|
|
|
+ productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
+ if (svipUserFlag) {
|
|
|
+ // 超级会员设置超级会员优惠总额 + 商品优惠金额
|
|
|
+ shopSvipReducedPrice.set(MathUtil.add(shopSvipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
}
|
|
|
- // 当前促销活动的价格计算列表
|
|
|
- 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, floor);
|
|
|
- //单品满减-计算供应商总价/满减金额
|
|
|
- // 叠加优惠计算
|
|
|
- if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
- if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && 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());
|
|
|
+ } else {
|
|
|
+ //失效无库存不统计
|
|
|
+ totalCount.updateAndGet(v -> v - 1);
|
|
|
+ kindCount.updateAndGet(v -> v - 1);
|
|
|
+ // 获取商品促销信息
|
|
|
+ PromotionsVo promotions = null;
|
|
|
+ // 没有店铺促销时,商品促销才有效
|
|
|
+ if (null == shopPromotion) {
|
|
|
+ // 获取商品促销信息
|
|
|
+ promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ // 促销活动如果协销不可见直接置空
|
|
|
+ if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && finalUserIdentity == 1) {
|
|
|
+ promotions = null;
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 设置商品促销优惠
|
|
|
+ */
|
|
|
+ if (null != promotions) {
|
|
|
+ if (1 == promotions.getMode()) {
|
|
|
+ promotions.setTouchPrice(baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(), promotions.getId()));
|
|
|
+ }
|
|
|
+ // 当前促销活动的价格计算列表
|
|
|
+ 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, floor);
|
|
|
+ //单品满减-计算供应商总价/满减金额
|
|
|
+ // 叠加优惠计算
|
|
|
+ if (promotions.getType() == 1 && promotions.getMode() == 2) {
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && 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);
|
|
|
}
|
|
|
}
|
|
|
- cartItemVo.setPromotions(promotions);
|
|
|
- }
|
|
|
- }
|
|
|
- if (null != promotions || null != shopPromotion) {
|
|
|
- // 商品处于活动状态
|
|
|
- cartItemVo.setActStatus(1);
|
|
|
- // 关闭阶梯价格,活动优先
|
|
|
- cartItemVo.setLadderFlag(0);
|
|
|
- } else {
|
|
|
- if (1 == cartItemVo.getLadderFlag()) {
|
|
|
- // 设置阶梯价
|
|
|
- productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
- } else {
|
|
|
- // 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), 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());
|
|
|
+ if (null != promotions || null != shopPromotion) {
|
|
|
+ // 商品处于活动状态
|
|
|
+ cartItemVo.setActStatus(1);
|
|
|
+ // 关闭阶梯价格,活动优先
|
|
|
+ cartItemVo.setLadderFlag(0);
|
|
|
+ } else {
|
|
|
+ if (1 == cartItemVo.getLadderFlag()) {
|
|
|
+ // 设置阶梯价
|
|
|
+ productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
} else {
|
|
|
- cartItemVo.setPrice(repurchase);
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), 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 (0 == organizeId) {
|
|
|
+ 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());
|
|
|
+ } else {
|
|
|
+ // 失效商品
|
|
|
+ if (cartItemVo.getPriceFlag() == 1) {
|
|
|
+ // 未公开价格
|
|
|
+ cartItemVo.setStatus(6);
|
|
|
+ } else if (cartItemVo.getPriceFlag() == 2 && finalUserIdentity == 4) {
|
|
|
+ // 价格仅会员可见
|
|
|
+ cartItemVo.setStatus(5);
|
|
|
+ } else if (cartItemVo.getPriceFlag() == 3 && finalUserClubType != 1) {
|
|
|
+ // 价格仅医美机构可见
|
|
|
+ cartItemVo.setStatus(8);
|
|
|
+ } else if (cartItemVo.getStock() == null || cartItemVo.getStock() == 0) {
|
|
|
+ // 售罄
|
|
|
+ cartItemVo.setStatus(4);
|
|
|
+ } else if (cartItemVo.getStock() != null && (cartItemVo.getStock() < cartItemVo.getMin() || cartItemVo.getStock() < cartItemVo.getNumber())) {
|
|
|
+ // 库存不足
|
|
|
+ cartItemVo.setStatus(7);
|
|
|
}
|
|
|
+ invalidList.add(cartItemVo);
|
|
|
+ productIterator.remove();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 失效商品
|
|
|
+ if (cartItemVo.getValidFlag() == 0) {
|
|
|
+ // 后台逻辑删除,已停售
|
|
|
+ cartItemVo.setStatus(1);
|
|
|
+ invalidList.add(cartItemVo);
|
|
|
+ } else if (cartItemVo.getValidFlag() == 10) {
|
|
|
+ // 已冻结,已丢失
|
|
|
+ cartItemVo.setStatus(2);
|
|
|
+ invalidList.add(cartItemVo);
|
|
|
+ } else if (cartItemVo.getValidFlag() == 3) {
|
|
|
+ // 已下架
|
|
|
+ cartItemVo.setStatus(3);
|
|
|
+ invalidList.add(cartItemVo);
|
|
|
}
|
|
|
+ //隐身商品validFlag = 9 不加入失效商品,直接去除
|
|
|
+ productIterator.remove();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (cartItemVo.getValidFlag() == 1) {
|
|
|
+ // 设置商品有效
|
|
|
+ cartItemVo.setStatus(0);
|
|
|
// 该供应商下价格累加
|
|
|
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());
|
|
|
} else {
|
|
|
- // 失效商品
|
|
|
- if (cartItemVo.getPriceFlag() == 1) {
|
|
|
- // 未公开价格
|
|
|
- cartItemVo.setStatus(6);
|
|
|
- } else if (cartItemVo.getPriceFlag() == 2 && finalUserIdentity == 4) {
|
|
|
- // 价格仅会员可见
|
|
|
- cartItemVo.setStatus(5);
|
|
|
- } else if (cartItemVo.getPriceFlag() == 3 && finalUserClubType != 1) {
|
|
|
- // 价格仅医美机构可见
|
|
|
- cartItemVo.setStatus(8);
|
|
|
- } else if (cartItemVo.getStock() == null || cartItemVo.getStock() == 0) {
|
|
|
- // 售罄
|
|
|
- cartItemVo.setStatus(4);
|
|
|
- } else if (cartItemVo.getStock() != null && (cartItemVo.getStock() < cartItemVo.getMin() || cartItemVo.getStock() < cartItemVo.getNumber())) {
|
|
|
- // 库存不足
|
|
|
- cartItemVo.setStatus(7);
|
|
|
- }
|
|
|
- invalidList.add(cartItemVo);
|
|
|
- productIterator.remove();
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 失效商品
|
|
|
- if (cartItemVo.getValidFlag() == 0) {
|
|
|
- // 后台逻辑删除,已停售
|
|
|
- cartItemVo.setStatus(1);
|
|
|
- invalidList.add(cartItemVo);
|
|
|
- } else if (cartItemVo.getValidFlag() == 10) {
|
|
|
- // 已冻结,已丢失
|
|
|
- cartItemVo.setStatus(2);
|
|
|
- invalidList.add(cartItemVo);
|
|
|
- } else if (cartItemVo.getValidFlag() == 3) {
|
|
|
- // 已下架
|
|
|
+ // 设置商品失效
|
|
|
cartItemVo.setStatus(3);
|
|
|
invalidList.add(cartItemVo);
|
|
|
}
|
|
|
- //隐身商品validFlag = 9 不加入失效商品,直接去除
|
|
|
- productIterator.remove();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
cartAllProducts.addAll(productList);
|
|
|
|
|
@@ -819,6 +841,31 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
return ResponseJson.success(cartCount);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取机构购物车数量(商品种类数) -- 组织
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Integer> getShoppingCartOrganizeCount(Integer userId) {
|
|
|
+ Integer count = 0;
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.success(count);
|
|
|
+ }
|
|
|
+ // 获取购物车商品列表(不区分供应商)
|
|
|
+ List<CartItemVo> cartList = cartClubMapper.getCartOrganizeProductList(userId);
|
|
|
+ if (null != cartList && cartList.size() > 0) {
|
|
|
+
|
|
|
+ cartList.removeIf(cartItemVo ->
|
|
|
+ cartItemVo.getValidFlag() == 2
|
|
|
+ );
|
|
|
+ return ResponseJson.success(cartList.size());
|
|
|
+ } else {
|
|
|
+ return ResponseJson.success(count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取机构购物车数量(商品种类数)
|
|
|
*
|
|
@@ -870,6 +917,8 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<Map<String, Object>> settlementShoppingCart(Integer userId, String skuIds, Integer source) {
|
|
|
+ // 用户组织Id
|
|
|
+ Integer organizeId = baseMapper.getOrganizeId(userId);
|
|
|
log.info("¥¥¥¥¥¥¥¥¥¥ > 商品结算");
|
|
|
// 商品种类
|
|
|
AtomicInteger kindCount = new AtomicInteger(0);
|
|
@@ -963,14 +1012,21 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
}
|
|
|
// 供应商下商品列表
|
|
|
// 过滤保存已上架商品
|
|
|
- List<CartItemVo> productList = cartClubMapper.getCartProductsByShopIdAndProductIds(userId, shop.getShopId(), finalIdList, shop.getSplitCode());
|
|
|
+ List<CartItemVo> productList = null;
|
|
|
+ if (0 == organizeId) {
|
|
|
+ productList = cartClubMapper.getCartProductsByShopIdAndProductIds(userId, shop.getShopId(), finalIdList, shop.getSplitCode());
|
|
|
+ } else {
|
|
|
+ productList = cartClubMapper.getCartProductsOrganize(userId, shop.getShopId(), organizeId, finalIdList, shop.getSplitCode());
|
|
|
+ }
|
|
|
if (null != productList && productList.size() > 0) {
|
|
|
- // 去除不可见商品,visibility商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
|
|
|
- productList.removeIf(cartItemVo -> !(cartItemVo.getVisibility() == 3 || cartItemVo.getVisibility() == 2 || (cartItemVo.getVisibility() == 1 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getVisibility() == 4 && finalUserClubType == 1)));
|
|
|
- // 去除价格不可见商品,价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
|
|
|
- productList.removeIf(cartItemVo -> !(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && finalUserClubType == 1)));
|
|
|
- // 去除库存不足商品
|
|
|
- productList.removeIf(cartItemVo -> !(cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber()));
|
|
|
+ if (0 == organizeId) {
|
|
|
+ // 去除不可见商品,visibility商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
|
|
|
+ productList.removeIf(cartItemVo -> !(cartItemVo.getVisibility() == 3 || cartItemVo.getVisibility() == 2 || (cartItemVo.getVisibility() == 1 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getVisibility() == 4 && finalUserClubType == 1)));
|
|
|
+ // 去除价格不可见商品,价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
|
|
|
+ productList.removeIf(cartItemVo -> !(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && finalUserClubType == 1)));
|
|
|
+ // 去除库存不足商品
|
|
|
+ productList.removeIf(cartItemVo -> !(cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber()));
|
|
|
+ }
|
|
|
// 迭代器设置商品信息
|
|
|
for (CartItemVo cartItemVo : productList) {
|
|
|
// 设置商品图片及税费
|
|
@@ -980,78 +1036,79 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
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());
|
|
|
- // 手动获取skuId优惠价
|
|
|
- if (promotions != null && (promotions.getTouchPrice() == null || promotions.getTouchPrice() == 0d)) {
|
|
|
- Double touchPrice = baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(),promotions.getId());
|
|
|
- promotions.setTouchPrice(touchPrice);
|
|
|
+ if (0 == organizeId) {
|
|
|
+ if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ // 超级会员设置商品优惠价
|
|
|
+ productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
+ if (svipUserFlag) {
|
|
|
+ // 超级会员设置超级会员优惠总额 + 商品优惠金额
|
|
|
+ shopSvipReducedPrice.set(MathUtil.add(shopSvipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
}
|
|
|
- // 如果促销活动协销不可见,移除促销
|
|
|
- if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && finalUserIdentity1 == 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() == 1 && 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());
|
|
|
+ } else {
|
|
|
+ // 非超级会员优惠商品参与促销活动
|
|
|
+ // 获取商品促销信息
|
|
|
+ PromotionsVo promotions = null;
|
|
|
+ // 没有店铺促销时,商品促销才有效 单品/凑单活动
|
|
|
+ if (null == shopPromotion) {
|
|
|
+ // 获取商品促销信息
|
|
|
+ promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ // 手动获取skuId优惠价
|
|
|
+ if (promotions != null && (promotions.getTouchPrice() == null || promotions.getTouchPrice() == 0d)) {
|
|
|
+ Double touchPrice = baseMapper.getTouchPriceBySku(cartItemVo.getSkuId(), promotions.getId());
|
|
|
+ promotions.setTouchPrice(touchPrice);
|
|
|
+ }
|
|
|
+ // 如果促销活动协销不可见,移除促销
|
|
|
+ if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && finalUserIdentity1 == 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() == 1 && 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);
|
|
|
}
|
|
|
- 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.getSkuId(), 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);
|
|
|
+ if (cartItemVo.getLadderFlag() == 1) {
|
|
|
+ // 设置阶梯价
|
|
|
+ productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ } else {
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1060,10 +1117,12 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 该供应商下价格累加
|
|
|
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());
|
|
|
+ if (0 == organizeId) {
|
|
|
+ // 该供应商下可参与店铺促销的商品价格累加
|
|
|
+ if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
|
|
|
+ // 超级会员购买svip商品不享受店铺促销优惠
|
|
|
+ shopPromotionFee.set(MathUtil.add(shopPromotionFee, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
|
|
|
+ }
|
|
|
}
|
|
|
// 该供应商下商品种类 +1
|
|
|
shopKindCount.incrementAndGet();
|
|
@@ -1149,12 +1208,15 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
}
|
|
|
});
|
|
|
// 删除空数据
|
|
|
+ log.info("shopList===="+shopList);
|
|
|
shopList.removeIf(shop -> (null == shop || shop.getCount() == 0));
|
|
|
+ log.info("shopList----"+shopList);
|
|
|
|
|
|
}
|
|
|
// 总促销计算
|
|
|
// 满减满赠叠加计算
|
|
|
List<CartShopVo> finalShopList = shopList;
|
|
|
+ log.info("shopList*****"+shopList);
|
|
|
totalPromotions.forEach(promotions -> {
|
|
|
// 该促销内商品总价
|
|
|
double touchPrice = promotions.getProductList().stream().mapToDouble(product -> product.getNumber() * product.getPrice()).sum();
|
|
@@ -1650,12 +1712,19 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
@Override
|
|
|
public ResponseJson<Map<String, Object>> buyNowProduct(CartDto cartDto) {
|
|
|
log.info("¥¥¥¥¥¥¥¥¥¥ > 立即购买");
|
|
|
+ // 用户组织Id
|
|
|
+ Integer organizeId = baseMapper.getOrganizeId(cartDto.getUserId());
|
|
|
// 供应商信息
|
|
|
CartShopVo shop = baseMapper.getShopByProductId(cartDto.getProductId());
|
|
|
if (null == shop) {
|
|
|
return ResponseJson.error("商品供应商异常!", null);
|
|
|
}
|
|
|
- CartItemVo cartItemVo = cartClubMapper.getCartItemByProductId(cartDto.getSkuId());
|
|
|
+ CartItemVo cartItemVo = null;
|
|
|
+ if (0 == organizeId) {
|
|
|
+ cartItemVo = cartClubMapper.getCartItemByProductId(cartDto.getSkuId());
|
|
|
+ } else {
|
|
|
+ cartItemVo = cartClubMapper.getCartOrganizeProductId(cartDto.getSkuId());
|
|
|
+ }
|
|
|
if (null == cartItemVo) {
|
|
|
return ResponseJson.error("商品数据异常!", null);
|
|
|
} else {
|
|
@@ -1686,8 +1755,10 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
return ResponseJson.error("商品不可见!", null);
|
|
|
}
|
|
|
// 价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
|
|
|
- if (!(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (userIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && userClubType == 1))) {
|
|
|
- return ResponseJson.error("商品价格不可见!", null);
|
|
|
+ if (0 == organizeId) {
|
|
|
+ if (!(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (userIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && userClubType == 1))) {
|
|
|
+ return ResponseJson.error("商品价格不可见!", null);
|
|
|
+ }
|
|
|
}
|
|
|
cartItemVo.setNumber(cartDto.getProductCount());
|
|
|
// 库存不足商品
|
|
@@ -1716,82 +1787,84 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
promotions = null;
|
|
|
}
|
|
|
boolean hasGift = false;
|
|
|
- if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
- // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
- // 超级会员设置商品优惠价
|
|
|
- productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
- if (svipUserFlag) {
|
|
|
- // 超级会员设置超级会员优惠总额 + 商品优惠金额
|
|
|
- svipReducedPrice.set(MathUtil.add(svipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 没有店铺促销时,商品促销才有效
|
|
|
- if (null == promotions) {
|
|
|
- // 获取商品促销信息
|
|
|
- promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
- //协销不可见
|
|
|
- if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && userIdentity == 1) {
|
|
|
- promotions = null;
|
|
|
+ if (0 == organizeId) {
|
|
|
+ if (1 == cartItemVo.getSvipProductFlag()) {
|
|
|
+ // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
|
|
|
+ // 超级会员设置商品优惠价
|
|
|
+ productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
|
|
|
+ if (svipUserFlag) {
|
|
|
+ // 超级会员设置超级会员优惠总额 + 商品优惠金额
|
|
|
+ svipReducedPrice.set(MathUtil.add(svipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
|
|
|
}
|
|
|
} 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();
|
|
|
- Double floor = Math.floor(MathUtil.div(totalAmount, promotions.getTouchPrice()).doubleValue());
|
|
|
- // 满足促销条件
|
|
|
- if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
|
|
|
- // 满减
|
|
|
- if (promotions.getMode() == 2) {
|
|
|
- // 总价 - 满减金额
|
|
|
- if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && 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());
|
|
|
- } else {
|
|
|
- totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- // 优惠总额 + 满减金额
|
|
|
- reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
- }
|
|
|
- } else if (promotions.getMode() == 3) {
|
|
|
- // 满足满赠
|
|
|
- hasGift = true;
|
|
|
- List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
- //满足叠加
|
|
|
- if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && floor > 1) {
|
|
|
- Integer in = floor.intValue();
|
|
|
- giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
|
|
|
- }
|
|
|
- promotions.setGiftList(giftList);
|
|
|
+ // 没有店铺促销时,商品促销才有效
|
|
|
+ if (null == promotions) {
|
|
|
+ // 获取商品促销信息
|
|
|
+ promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
+ //协销不可见
|
|
|
+ if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && userIdentity == 1) {
|
|
|
+ promotions = null;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ shop.setPromotions(promotions);
|
|
|
}
|
|
|
- // 添加到总促销
|
|
|
- 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) {
|
|
|
+ // 当前促销活动的价格计算列表
|
|
|
+ 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) {
|
|
|
+ // 满减
|
|
|
+ if (promotions.getMode() == 2) {
|
|
|
+ // 总价 - 满减金额
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && 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());
|
|
|
+ } else {
|
|
|
+ totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ // 优惠总额 + 满减金额
|
|
|
+ reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
|
|
|
+ }
|
|
|
+ } else if (promotions.getMode() == 3) {
|
|
|
+ // 满足满赠
|
|
|
+ hasGift = true;
|
|
|
+ List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
|
|
|
+ //满足叠加
|
|
|
+ if (promotions.getDiscount() != null && promotions.getDiscount() == 1 && floor > 1) {
|
|
|
+ Integer in = floor.intValue();
|
|
|
+ giftList.forEach(g -> g.setNumber(MathUtil.mul(g.getNumber(), in).intValue()));
|
|
|
+ }
|
|
|
+ promotions.setGiftList(giftList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 添加到总促销
|
|
|
+ totalPromotions.add(promotions);
|
|
|
+ // 商品处于活动状态
|
|
|
+ cartItemVo.setActStatus(1);
|
|
|
+ // 关闭阶梯价格,活动优先
|
|
|
+ cartItemVo.setLadderFlag(0);
|
|
|
+ cartItemVo.setPromotions(promotions);
|
|
|
} else {
|
|
|
- // 复购价
|
|
|
- Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), 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);
|
|
|
+ cartItemVo.setActStatus(0);
|
|
|
+ if (cartItemVo.getLadderFlag() == 1) {
|
|
|
+ // 设置阶梯价
|
|
|
+ productService.setCartLadderPrices(cartItemVo, taxFlag);
|
|
|
+ } else {
|
|
|
+ // 复购价
|
|
|
+ Double repurchase = baseMapper.getRepurchasePrice(cartItemVo.getSkuId(), 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|