|
@@ -97,15 +97,23 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
totalCouponList.addAll(couponList);
|
|
|
totalCouponList.addAll(preCouponList);
|
|
|
List<CartItemVo> cartAllProducts = new ArrayList<>();
|
|
|
- // 用户身份
|
|
|
+ // 用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构
|
|
|
Integer userIdentity = baseMapper.getIdentityByUserId(userId);
|
|
|
-
|
|
|
+ userIdentity = null == userIdentity ? 0 : userIdentity;
|
|
|
+ // 会员机构类型:1医美,2生美
|
|
|
+ Integer userClubType = 0;
|
|
|
+ if (null != userIdentity && userIdentity == 2) {
|
|
|
+ userClubType = cartClubMapper.getClubTypeById(userId);
|
|
|
+ userClubType = null == userClubType ? 0 : userClubType;
|
|
|
+ }
|
|
|
// 超级会员标识
|
|
|
Integer svipUserId = baseMapper.getSvipUserIdByUserId(userId);
|
|
|
boolean svipUserFlag = null != svipUserId;
|
|
|
if (null != shopInfoList && shopInfoList.size() > 0) {
|
|
|
// 删除空数据
|
|
|
shopInfoList.removeIf(Objects::isNull);
|
|
|
+ Integer finalUserIdentity = userIdentity;
|
|
|
+ Integer finalUserClubType = userClubType;
|
|
|
// 遍历供应商列表
|
|
|
shopInfoList.forEach(shop -> {
|
|
|
// 默认未选中状态(前端要求)
|
|
@@ -124,7 +132,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
AtomicDouble shopOriginalPrice = new AtomicDouble(0);
|
|
|
// 供应商促销优惠活动,以活动分类排序,店铺>凑单>单品
|
|
|
PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
|
|
|
- if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen() == 2 && userIdentity == 1) {
|
|
|
+ if (shopPromotion != null && shopPromotion.getSeen() != null && shopPromotion.getSeen() == 2 && finalUserIdentity == 1) {
|
|
|
shopPromotion = null;
|
|
|
}
|
|
|
// 供应商下商品列表 ,购物车里的该供应商商品
|
|
@@ -136,14 +144,21 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
CartItemVo cartItemVo = productIterator.next();
|
|
|
// 设置商品图片及税费
|
|
|
boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
|
|
|
+ // 商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
|
|
|
+ Integer visibility = cartItemVo.getVisibility();
|
|
|
+ boolean visibleFlag = visibility == 3 || visibility==2 || (visibility == 1 && finalUserIdentity == 2) || (visibility == 4 && finalUserClubType == 1);
|
|
|
+ if (!visibleFlag) {
|
|
|
+ //不可见商品 不加入失效商品,直接去除
|
|
|
+ productIterator.remove();
|
|
|
+ }
|
|
|
// 已上架商品
|
|
|
- if (cartItemVo.getValidFlag() == 2) {
|
|
|
+ else if (cartItemVo.getValidFlag() == 2) {
|
|
|
// 设置商品有效
|
|
|
cartItemVo.setStatus(0);
|
|
|
// 默认所有商品未选中状态(前端要求)
|
|
|
cartItemVo.setIsChecked(false);
|
|
|
- // 价格是否可见
|
|
|
- boolean priceVisible = (cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (userIdentity == 2 || svipUserFlag)));
|
|
|
+ // 价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
|
|
|
+ boolean priceVisible = (cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (finalUserIdentity == 2 || svipUserFlag)) || (cartItemVo.getPriceFlag() == 3 && finalUserClubType == 1));
|
|
|
// 是否库存充足
|
|
|
boolean isStocked = (cartItemVo.getStock() != null && cartItemVo.getStock() > 0 && cartItemVo.getStock() >= cartItemVo.getMin() && cartItemVo.getStock() >= cartItemVo.getNumber());
|
|
|
if (priceVisible && isStocked) {
|
|
@@ -163,7 +178,7 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
// 获取商品促销信息
|
|
|
promotions = baseMapper.getPromotionByProductId(cartItemVo.getProductId());
|
|
|
// 促销活动如果协销不可见直接置空
|
|
|
- if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && userIdentity == 1) {
|
|
|
+ if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && finalUserIdentity == 1) {
|
|
|
promotions = null;
|
|
|
}
|
|
|
/*
|
|
@@ -233,9 +248,12 @@ public class CartClubServiceImpl implements CartClubService {
|
|
|
if (cartItemVo.getPriceFlag() == 1) {
|
|
|
// 未公开价格
|
|
|
cartItemVo.setStatus(6);
|
|
|
- } else if (cartItemVo.getPriceFlag() == 2 && userIdentity == 4) {
|
|
|
+ } 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);
|