Browse Source

个人超级会员权限

Aslee 3 years ago
parent
commit
958241c25f

+ 7 - 0
src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -274,4 +274,11 @@ public interface PageMapper {
      * @return
      */
     List<ProductItemVo> getSvipProductList();
+
+    /**
+     * 查询超级会员用户id
+     * @param userId    用户id
+     * @return
+     */
+    Integer getSvipUserIdByUserId(Integer userId);
 }

+ 8 - 2
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -650,6 +650,9 @@ public class PageServiceImpl implements PageService {
                 identity = 0;
             }
         }
+        // 超级会员标识
+        Integer svipUserId = pageMapper.getSvipUserIdByUserId(userId);
+        boolean svipUserFlag = null != svipUserId;
         List<ProductListVo> list = null;
         //相关推荐类型 0自动选择(默认); 1手动推荐
         if (null == recommendType || 1 != recommendType) {
@@ -663,7 +666,7 @@ public class PageServiceImpl implements PageService {
             // boolean passFlag = identity ==1 || identity == 2 || product.getVisibility()==3 || (identity == 4 && product.getVisibility()==2);
             try {
                 Integer finalIdentity = identity;
-                list.removeIf(product -> (null == product || null == product.getVisibility() || !(finalIdentity == 1 || finalIdentity == 2 || product.getVisibility() == 3 || (finalIdentity == 4 && product.getVisibility() == 2))));
+                list.removeIf(product -> (null == product || null == product.getVisibility() || !(finalIdentity == 1 || finalIdentity == 2 || svipUserFlag || product.getVisibility() == 3 || (finalIdentity == 4 && product.getVisibility() == 2))));
                 list.forEach(product -> {
                     // 设置 图片路径
                     product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
@@ -785,6 +788,9 @@ public class PageServiceImpl implements PageService {
             Map<String, Object> linkParam = AppletsLinkUtil.getLinkParam(linkType, image.getLink());
             image.setLinkType(linkType);
             image.setLinkParam(linkParam);
+            // 超级会员标识
+            Integer svipUserId = pageMapper.getSvipUserIdByUserId(userId);
+            boolean svipUserFlag = null != svipUserId;
             if (image.getProductId() != null) {
                 // 获取商品及价格
                 ProductItemVo product = pageMapper.getProductItemById(image.getProductId());
@@ -798,7 +804,7 @@ public class PageServiceImpl implements PageService {
                     image.setProduct(product);
                     if (userId != null) {
                         if (product.getUserIdentity() > 0) {
-                            if (4 == product.getUserIdentity() && "1".equals(product.getVisibility())) {
+                            if (!svipUserFlag && 4 == product.getUserIdentity() && "1".equals(product.getVisibility())) {
                                 iterator.remove();
                             }
                         } else {

+ 8 - 1
src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java

@@ -1,6 +1,7 @@
 package com.caimei365.commodity.service.impl;
 
 import com.caimei365.commodity.components.RedisService;
+import com.caimei365.commodity.mapper.PageMapper;
 import com.caimei365.commodity.mapper.PriceMapper;
 import com.caimei365.commodity.mapper.SecondHandMapper;
 import com.caimei365.commodity.model.ResponseJson;
@@ -12,6 +13,7 @@ import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.SecondHandService;
 import com.caimei365.commodity.utils.ImageUtils;
 import com.github.pagehelper.PageHelper;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -42,6 +44,8 @@ public class SecondHandServiceImpl implements SecondHandService {
     private RedisService redisService;
     @Resource
     private PriceMapper priceMapper;
+    @Resource
+    private PageMapper pageMapper;
 
 
     /**
@@ -108,10 +112,13 @@ public class SecondHandServiceImpl implements SecondHandService {
         if (userId != null && userId > 0) {
             userIdentity = priceMapper.getIdentityByUserId(userId);
         }
+        // 超级会员标识
+        Integer svipUserId = pageMapper.getSvipUserIdByUserId(userId);
+        boolean svipUserFlag = null != svipUserId;
         SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
         Integer visibility = second.getVisibility();
         boolean b = userIdentity == 0 && (visibility == 1 || visibility == 2);
-        boolean a = userIdentity == 4 && visibility == 1;
+        boolean a = userIdentity == 4 && visibility == 1 && !svipUserFlag;
         if (b || a) {
             return ResponseJson.error("无权限查看", null);
         }

+ 4 - 0
src/main/resources/mapper/PageMapper.xml

@@ -518,6 +518,10 @@
         from cm_svip_product csp
         left join product p on p.productID = csp.productId
         where p.validFlag = 2
+        order by -sort desc,addTime desc
+    </select>
+    <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
+        select userId from cm_svip_user where userId = #{userId} and delFlag = '0' and now() <![CDATA[ < ]]> endTime
     </select>
 
 </mapper>