Jelajahi Sumber

医美机构商品可见度

chao 3 tahun lalu
induk
melakukan
d5a325a80a

+ 1 - 1
src/main/java/com/caimei365/commodity/mapper/CouponMapper.java

@@ -43,7 +43,7 @@ public interface CouponMapper {
      * @param source   来源 : 1 网站 ; 2 小程序
      * @return
      */
-    List<ProductItemVo> findCouponProduct(@Param("couponId") Integer couponId, @Param("source") Integer source);
+    List<ProductItemVo> findCouponProduct(@Param("couponId") Integer couponId, @Param("source") Integer source, @Param("identity") Integer identity);
 
     /**
      * 查询可以领取的券

+ 13 - 1
src/main/java/com/caimei365/commodity/service/impl/CouponServiceImpl.java

@@ -3,6 +3,7 @@ package com.caimei365.commodity.service.impl;
 import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.mapper.CouponMapper;
 import com.caimei365.commodity.mapper.PageMapper;
+import com.caimei365.commodity.mapper.PriceMapper;
 import com.caimei365.commodity.mapper.ShopMapper;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.dto.CollarCouponsDto;
@@ -39,6 +40,8 @@ public class CouponServiceImpl implements CouponService {
     @Resource
     private PageMapper pageMapper;
     @Resource
+    private PriceMapper priceMapper;
+    @Resource
     private PriceUtilService priceUtilService;
 
     /**
@@ -96,8 +99,17 @@ public class CouponServiceImpl implements CouponService {
         if (coupon == null) {
             return ResponseJson.error("活动已失效", null);
         }
+        // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
+        Integer identity = priceMapper.getIdentityByUserId(userId);
+        // 会员机构类型:1医美,2生美
+        if (null != identity && identity == 2) {
+            Integer clubType = priceMapper.getClubTypeById(userId);
+            if (null != clubType && clubType == 1){
+                identity = 5;
+            }
+        }
         PageHelper.startPage(pageNum, pageSize);
-        List<ProductItemVo> productList = couponMapper.findCouponProduct(couponId, source);
+        List<ProductItemVo> productList = couponMapper.findCouponProduct(couponId, source, identity);
         productList.forEach(p -> {
             p.setCouponsLogo(true);
             priceUtilService.setProductDetails(userId, p,2);

+ 17 - 0
src/main/resources/mapper/CouponMapper.xml

@@ -96,6 +96,23 @@
         <if test="source == 2">
             AND a.appletsStatus = 1
         </if>
+        <choose>
+            <when test="identity == 1">
+                AND p.validFlag IN (2,3,9)
+            </when>
+            <when test="identity == 5">
+                AND p.validFlag = 2
+            </when>
+            <when test="identity == 2">
+                AND p.visibility IN (1,2,3) AND p.validFlag = 2
+            </when>
+            <when test="identity == 4">
+                AND p.visibility IN (2,3) AND p.validFlag = 2
+            </when>
+            <otherwise>
+                AND p.visibility = 3 AND p.validFlag = 2
+            </otherwise>
+        </choose>
         ORDER BY
         -a.sort DESC
     </select>