Browse Source

医美可见度购物车结算bugfix

chao 3 years ago
parent
commit
44d54d776a
1 changed files with 45 additions and 10 deletions
  1. 45 10
      src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

+ 45 - 10
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -860,6 +860,13 @@ public class CartClubServiceImpl implements CartClubService {
         List<Integer> shopIds = new ArrayList<>();
         // 用户身份
         Integer userIdentity = baseMapper.getIdentityByUserId(userId);
+        if (null == userIdentity) {userIdentity = 0;}
+        // 会员机构类型:1医美,2生美
+        Integer userClubType = 0;
+        if (userIdentity == 2) {
+            userClubType = cartClubMapper.getClubTypeById(userId);
+            if (null == userClubType) {userClubType = 0;}
+        }
         // 超级会员标识
         Integer svipUserId = baseMapper.getSvipUserIdByUserId(userId);
         boolean svipUserFlag = null != svipUserId;
@@ -877,6 +884,9 @@ public class CartClubServiceImpl implements CartClubService {
         if (null != shopList && shopList.size() > 0) {
             // 遍历供应商列表
             List<String> finalIdList = productIdList;//购物车商品id列表
+            Integer finalUserIdentity = userIdentity;
+            Integer finalUserClubType = userClubType;
+            Integer finalUserIdentity1 = userIdentity;
             shopList.forEach(shop -> {
                 if (null != shop) {
                     // 该供应商下商品种类
@@ -893,15 +903,17 @@ 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 && finalUserIdentity1 == 1) {
                         shopPromotion = null;
                     }
                     // 供应商下商品列表
                     // 过滤保存已上架商品
                     List<CartItemVo> productList = cartClubMapper.getCartProductsByShopIdAndProductIds(userId, shop.getShopId(), finalIdList);
                     if (null != productList && productList.size() > 0) {
-                        // 去除价格不可见商品
-                        productList.removeIf(cartItemVo -> !(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (userIdentity == 2 || svipUserFlag))));
+                        // 去除不可见商品,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()));
                         // 迭代器设置商品信息
@@ -931,7 +943,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 && finalUserIdentity1 == 1) {
                                         promotions = null;
                                     }
                                     /*
@@ -1200,6 +1212,13 @@ public class CartClubServiceImpl implements CartClubService {
         List<String> productIdList = new ArrayList<>();
         // 用户身份
         Integer userIdentity = baseMapper.getIdentityByUserId(userId);
+        if (null == userIdentity) {userIdentity = 0;}
+        // 会员机构类型:1医美,2生美
+        Integer userClubType = 0;
+        if (userIdentity == 2) {
+            userClubType = cartClubMapper.getClubTypeById(userId);
+            if (null == userClubType) {userClubType = 0;}
+        }
         // 超级会员标识
         Integer svipUserId = baseMapper.getSvipUserIdByUserId(userId);
         boolean svipUserFlag = null != svipUserId;
@@ -1224,6 +1243,9 @@ public class CartClubServiceImpl implements CartClubService {
         if (null != shopList && shopList.size() > 0) {
             // 遍历供应商列表
             List<String> finalIdList = productIdList;//商品id列表
+            Integer finalUserIdentity = userIdentity;
+            Integer finalUserClubType = userClubType;
+            Integer finalUserIdentity1 = userIdentity;
             shopList.forEach(shop -> {
                 if (null != shop) {
                     // 该供应商下商品种类
@@ -1240,7 +1262,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 && finalUserIdentity1 == 1) {
                         shopPromotion = null;
                     }
                     // 供应商下商品列表
@@ -1248,8 +1270,10 @@ public class CartClubServiceImpl implements CartClubService {
                     List<CartItemVo> productList = cartClubMapper.getProductsByShopIdAndProductIds(shop.getShopId(), finalIdList);
                     productList.forEach(p -> p.setNumber(productInfos.get(p.getProductId().toString())));
                     if (null != productList && productList.size() > 0) {
-                        // 去除价格不可见商品
-                        productList.removeIf(cartItemVo -> !(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (userIdentity == 2 || svipUserFlag))));
+                        // 去除不可见商品,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()));
                         // 迭代器设置商品信息
@@ -1279,7 +1303,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 && finalUserIdentity1 == 1) {
                                         promotions = null;
                                     }
                                     /*
@@ -1533,11 +1557,22 @@ public class CartClubServiceImpl implements CartClubService {
         }
         // 用户身份
         Integer userIdentity = baseMapper.getIdentityByUserId(cartDto.getUserId());
+        if (null == userIdentity) {userIdentity = 0;}
+        // 会员机构类型:1医美,2生美
+        Integer userClubType = 0;
+        if (userIdentity == 2) {
+            userClubType = cartClubMapper.getClubTypeById(cartDto.getUserId());
+            if (null == userClubType) {userClubType = 0;}
+        }
         // 超级会员标识
         Integer svipUserId = baseMapper.getSvipUserIdByUserId(cartDto.getUserId());
         boolean svipUserFlag = null != svipUserId;
-        // 价格不可见商品
-        if (!(cartItemVo.getPriceFlag() == 0 || (cartItemVo.getPriceFlag() == 2 && (userIdentity == 2 || svipUserFlag)))) {
+        // visibility商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
+        if (!(cartItemVo.getVisibility() == 3 || cartItemVo.getVisibility()==2 || (cartItemVo.getVisibility() == 1 && (userIdentity == 2 || svipUserFlag)) || (cartItemVo.getVisibility() == 4 && userClubType == 1))){
+            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);
         }
         cartItemVo.setNumber(cartDto.getProductCount());