Browse Source

价格仅医美机构可见

chao 3 years ago
parent
commit
730205ec55

+ 4 - 1
src/main/java/com/caimei365/order/mapper/CartClubMapper.java

@@ -102,5 +102,8 @@ public interface CartClubMapper {
     CartItemVo getCartItemByProductId(Integer productId);
 
     List<Integer> findVipCoupon();
-
+    /**
+     * 会员机构类型:1医美,2生美
+     */
+    Integer getClubTypeById(Integer userId);
 }

+ 6 - 2
src/main/java/com/caimei365/order/model/vo/CartItemVo.java

@@ -24,7 +24,7 @@ public class CartItemVo implements Serializable {
      */
     private Integer number;
     /**
-     * 购物商品效状态:0有效,1后台删除的,2冻结的,3下架,4售罄 >7库存不足,5价格仅会员可见,6未公开价格
+     * 购物商品效状态:0有效,1后台删除的,2冻结的,3下架,4售罄 >7库存不足,5价格仅会员可见,6未公开价格, 8价格仅医美机构可见
      */
     private Integer status;
     /**
@@ -72,7 +72,7 @@ public class CartItemVo implements Serializable {
      */
     private Integer step;
     /**
-     * 价格可见度:0公开价格 1不公开价格 2仅对会员机构公开
+     * 价格可见度: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
      */
     private Integer priceFlag;
     /**
@@ -99,6 +99,10 @@ public class CartItemVo implements Serializable {
      * 商品是否处于活动状态 1是 0否
      */
     private Integer actStatus;
+    /**
+     * 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
+     */
+    private Integer visibility;
     /**
      * 商品上架状态:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已冻结
      */

+ 26 - 8
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -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);

+ 8 - 0
src/main/resources/mapper/CartClubMapper.xml

@@ -66,6 +66,7 @@
             p.taxPoint AS taxRate,
             p.productCategory,
             p.validFlag AS validFlag,
+            p.visibility,
             if(csp.id is not null,1,0) as svipProductFlag,
             csp.priceType as svipPriceType,
             csp.discount as svipDiscount,
@@ -98,6 +99,7 @@
         p.taxPoint AS taxRate,
         p.productCategory,
         p.validFlag AS validFlag,
+        p.visibility,
         p.commodityType as commodityType,
         if(csp.id is not null,1,0) as svipProductFlag,
         csp.priceType as svipPriceType,
@@ -134,6 +136,7 @@
         p.taxPoint AS taxRate,
         p.productCategory,
         p.validFlag AS validFlag,
+        p.visibility,
         p.commodityType as commodityType,
         if(csp.id is not null,1,0) as svipProductFlag,
         csp.priceType as svipPriceType,
@@ -169,6 +172,7 @@
             p.invoiceType AS invoiceType,
             p.taxPoint AS taxRate,
             p.productCategory,
+            p.visibility,
             p.validFlag AS validFlag
         FROM cm_cart c
         LEFT JOIN product p ON c.productID = p.productID
@@ -252,6 +256,7 @@
         p.taxPoint AS taxRate,
         p.productCategory,
         p.validFlag AS validFlag,
+        p.visibility,
         p.commodityType AS commodityType,
         if(csp.id is not null,1,0) as svipProductFlag,
         csp.priceType as svipPriceType,
@@ -265,4 +270,7 @@
     <select id="findVipCoupon" resultType="java.lang.Integer">
         select couponId from cm_svip_coupon
     </select>
+    <select id="getClubTypeById" resultType="java.lang.Integer">
+        SELECT firstClubType FROM club WHERE userID = #{userId}
+    </select>
 </mapper>