Ver Fonte

Merge remote-tracking branch 'origin/developer' into developer

Aslee há 3 anos atrás
pai
commit
a6c4f7b4a7
31 ficheiros alterados com 325 adições e 198 exclusões
  1. 6 0
      backup.sql
  2. 23 18
      src/main/java/com/caimei365/commodity/components/PriceUtilService.java
  3. 21 12
      src/main/java/com/caimei365/commodity/components/SearchOpenService.java
  4. 28 40
      src/main/java/com/caimei365/commodity/controller/ProductPageApi.java
  5. 6 9
      src/main/java/com/caimei365/commodity/controller/ProductPriceApi.java
  6. 1 1
      src/main/java/com/caimei365/commodity/controller/ProductShopApi.java
  7. 1 1
      src/main/java/com/caimei365/commodity/controller/PromotionsApi.java
  8. 5 5
      src/main/java/com/caimei365/commodity/controller/SearchProductApi.java
  9. 1 1
      src/main/java/com/caimei365/commodity/controller/SearchQueryApi.java
  10. 1 1
      src/main/java/com/caimei365/commodity/mapper/CouponMapper.java
  11. 4 0
      src/main/java/com/caimei365/commodity/mapper/PriceMapper.java
  12. 4 0
      src/main/java/com/caimei365/commodity/mapper/PromotionsMapper.java
  13. 1 1
      src/main/java/com/caimei365/commodity/model/vo/PriceVo.java
  14. 1 1
      src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java
  15. 4 2
      src/main/java/com/caimei365/commodity/model/vo/PromotionsVo.java
  16. 1 1
      src/main/java/com/caimei365/commodity/model/vo/SecondDetailVo.java
  17. 9 9
      src/main/java/com/caimei365/commodity/service/PageService.java
  18. 2 2
      src/main/java/com/caimei365/commodity/service/PriceService.java
  19. 14 2
      src/main/java/com/caimei365/commodity/service/impl/CouponServiceImpl.java
  20. 74 55
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  21. 4 4
      src/main/java/com/caimei365/commodity/service/impl/PriceServiceImpl.java
  22. 7 3
      src/main/java/com/caimei365/commodity/service/impl/PromotionsServiceImpl.java
  23. 34 16
      src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java
  24. 3 3
      src/main/java/com/caimei365/commodity/service/impl/SellerServiceImpl.java
  25. 10 7
      src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java
  26. 1 1
      src/main/java/com/caimei365/commodity/service/impl/UserLikeServiceImpl.java
  27. 17 0
      src/main/resources/mapper/CouponMapper.xml
  28. 3 0
      src/main/resources/mapper/PriceMapper.xml
  29. 29 2
      src/main/resources/mapper/PromotionsMapper.xml
  30. 7 1
      src/main/resources/mapper/SearchMapper.xml
  31. 3 0
      src/main/resources/mapper/SecondHandMapper.xml

+ 6 - 0
backup.sql

@@ -17,3 +17,9 @@ CREATE TABLE `cm_svip_product_adsimage` (
     COMMENT = '超级会员优惠商品宣传图';
 INSERT INTO `cm_svip_product_adsimage` (`id`) VALUES ('1');
 -- =================================== 2021年9月 超级会员S_VIP end =====================================
+
+-- 商品增加“仅医美机构可见”的可见度
+ALTER TABLE product
+    MODIFY COLUMN priceFlag char(2) default '0' null comment '是否公开机构价:0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开',
+    MODIFY COLUMN visibility char(2) default '3' not null comment '商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见' AFTER priceFlag;
+

+ 23 - 18
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -85,26 +85,31 @@ public class PriceUtilService {
      * @param price  商品价格类
      * @param userId 用户Id
      */
-    public void setPriceByUserId(PriceVo price, Integer userId, Integer flag) {
-        // 根据用户Id查询用户身份
+    public void setPriceByUserId(PriceVo price, Integer userId) {
+        // 根据用户Id查询用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构
         Integer identity = priceMapper.getIdentityByUserId(userId);
+        if (null == identity) {identity = 0;}
+        // priceFlag: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
+        Integer priceFlag = null != price.getPriceFlag() ? price.getPriceFlag() : 0;
+        // 会员机构类型:1医美,2生美
+        Integer clubType = 0;
+        if (identity == 2) {
+            clubType = priceMapper.getClubTypeById(userId);
+            if (null == clubType) {clubType = 0;}
+        }
         // 根据用户Id查询超级会员id
         Integer svipUserId = priceMapper.getSvipUserIdByUserId(userId);
         // 超级会员标识
-        boolean svipUserFlag = null != svipUserId;
-        // 根据商品id查询商品活动
-        PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(price.getProductId());
-        // 如果身份不是机构,并且促销活动不可见,直接把促销置空
-        if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && flag == 1) {
-            promotions = null;
-        }else if (promotions != null && promotions.getSeen() != null && identity!=null && promotions.getSeen() == 2 && identity == 1) {
-            promotions = null;
-        }
+        boolean isSuperVip = null != svipUserId;
+        // 根据商品id,用户身份 查询商品活动
+        PromotionsVo promotions = promotionsMapper.getPricePromotions(price.getProductId(), identity);
         price.setRepurchaseFlag(0);
         price.setActStatus(0);
-        if (null != identity && identity > 0) {
-            // 用户身份: 2-会员机构, 4-普通机构
-            price.setUserIdentity(identity);
+        // 用户身份: 2-会员机构, 4-普通机构
+        price.setUserIdentity(identity);
+        // 设置价格标志(协销|价格公开|仅对医美机构公开|仅对会员机构公开)
+        boolean setFlag = identity == 1 || priceFlag == 0 || (priceFlag == 3 && clubType == 1) || (priceFlag == 2 && (identity == 2 || isSuperVip));
+        if (setFlag) {
             // 设置划线价
             price.setOriginalPrice(price.getPrice());
             //税费标志
@@ -117,14 +122,14 @@ public class PriceUtilService {
                 if (1 == price.getSvipPriceType()) {
                     // 折扣价
                     price.setSvipPriceTag(MathUtil.div(price.getSvipDiscount(), 10, 1) + "折");
-                    if (svipUserFlag) {
+                    if (isSuperVip) {
                         // 超级会员用户设置优惠价
                         svipDiscountPrice = MathUtil.div(MathUtil.mul(price.getPrice(), price.getSvipDiscount()), 100, 2);
                         price.setPrice(svipDiscountPrice.doubleValue());
                     }
                 } else if (2 == price.getSvipPriceType()) {
                     // 直接优惠价
-                    if (svipUserFlag) {
+                    if (isSuperVip) {
                         // 超级会员用户设置优惠价
                         price.setPrice(svipDiscountPrice.doubleValue());
                     }
@@ -207,7 +212,7 @@ public class PriceUtilService {
      * @param userId  用户Id
      * @param product ProductItemVo
      */
-    public void setProductDetails(Integer userId, ProductItemVo product, Integer flag) {
+    public void setProductDetails(Integer userId, ProductItemVo product) {
         // 设置图片
         product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
         // 设置价格等级
@@ -215,7 +220,7 @@ public class PriceUtilService {
         // 数据库获取基本价格信息
         PriceVo price = priceMapper.getDetailPrice(product.getProductId());
         // 根据用户id设置详细价格
-        setPriceByUserId(price, userId, flag);
+        setPriceByUserId(price, userId);
         // 设置价格
         product.setActStatus(price.getActStatus());
         product.setPrice(price.getPrice());

+ 21 - 12
src/main/java/com/caimei365/commodity/components/SearchOpenService.java

@@ -237,15 +237,18 @@ public class SearchOpenService {
         searchParams.setQuery(queryStr);
 
         String thisFilter = StringUtils.isNotEmpty(filter) ? (filter + " AND ") : "";
-        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
+        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构
         // p_valid:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
-        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
+        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
         if (identity == 1) {
             // 协销 | 综合供应商
             thisFilter += "(p_valid=2 OR p_valid=3 OR p_valid=9) AND p_type=1";
+        } else if (identity == 5) {
+            // 医美机构
+            thisFilter += "p_valid=2 AND p_type=1";
         } else if (identity == 2) {
             // 会员机构
-            thisFilter += "p_valid=2 AND p_type=1";
+            thisFilter += "(p_visibility=1 OR p_visibility=2 OR p_visibility=3) ANDp_valid=2 AND p_type=1";
         } else if (identity == 4) {
             // 普通机构
             thisFilter += "(p_visibility=2 OR p_visibility=3) AND p_valid=2 AND p_type=1";
@@ -254,7 +257,6 @@ public class SearchOpenService {
             thisFilter += "p_visibility=3 AND p_valid=2 AND p_type=1";
         }
         searchParams.setFilter(thisFilter);
-
         // 设置聚合打散子句
         Distinct dist = new Distinct();
         // 设置dist_key
@@ -336,16 +338,19 @@ public class SearchOpenService {
         // 设置查询子句,若需多个索引组合查询,需要setQuery处合并,否则若设置多个setQuery后面的会替换前面查询
         searchParams.setQuery(queryStr);
 
-        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
-        // p_valid:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
-        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
         String thisFilter = "";
+        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构
+        // p_valid:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
+        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
         if (identity == 1) {
             // 协销 | 综合供应商
             thisFilter += "(p_valid=2 OR p_valid=3 OR p_valid=9) AND p_type=1";
+        } else if (identity == 5) {
+            // 医美机构
+            thisFilter += "p_valid=2 AND p_type=1";
         } else if (identity == 2) {
             // 会员机构
-            thisFilter += "p_valid=2 AND p_type=1";
+            thisFilter += "(p_visibility=1 OR p_visibility=2 OR p_visibility=3) ANDp_valid=2 AND p_type=1";
         } else if (identity == 4) {
             // 普通机构
             thisFilter += "(p_visibility=2 OR p_visibility=3) AND p_valid=2 AND p_type=1";
@@ -464,16 +469,20 @@ public class SearchOpenService {
         SearchParams searchParams = new SearchParams(config);
         // 设置查询子句,若需多个索引组合查询,需要setQuery处合并,否则若设置多个setQuery后面的会替换前面查询
         searchParams.setQuery(queryStr);
-        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
-        // p_valid:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
-        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
+
         String thisFilter = "";
+        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构
+        // p_valid:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
+        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
         if (identity == 1) {
             // 协销 | 综合供应商
             thisFilter += "(p_valid=2 OR p_valid=3 OR p_valid=9) AND p_type=1";
+        } else if (identity == 5) {
+            // 医美机构
+            thisFilter += "p_valid=2 AND p_type=1";
         } else if (identity == 2) {
             // 会员机构
-            thisFilter += "p_valid=2 AND p_type=1";
+            thisFilter += "(p_visibility=1 OR p_visibility=2 OR p_visibility=3) ANDp_valid=2 AND p_type=1";
         } else if (identity == 4) {
             // 普通机构
             thisFilter += "(p_visibility=2 OR p_visibility=3) AND p_valid=2 AND p_type=1";

+ 28 - 40
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -57,16 +57,14 @@ public class ProductPageApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "pageId", value = "页面信息id"),
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
     })
     @GetMapping("/classify/product")
-    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source,
-                                                             @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source) {
         if (pageId == null) {
             return ResponseJson.error("参数异常", null);
         }
-        return pageService.getClassifyData(pageId, userId, source, flag);
+        return pageService.getClassifyData(pageId, userId, source);
     }
 
     /**
@@ -78,13 +76,11 @@ public class ProductPageApi {
     @ApiOperation("首页楼层数据(旧:/home/data)")
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
     })
     @GetMapping("/home/floor")
-    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source,
-                                                         @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
-        return pageService.getHomeData(userId, source, flag);
+    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source) {
+        return pageService.getHomeData(userId, source);
     }
 
     /**
@@ -147,13 +143,11 @@ public class ProductPageApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "pageId", value = "页面id"),
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
     })
     @GetMapping("/page/beauty")
-    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source,
-                                                               @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
-        return pageService.getPageBeautyData(pageId, userId, source,flag);
+    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source) {
+        return pageService.getPageBeautyData(pageId, userId, source);
     }
 
     /**
@@ -167,13 +161,11 @@ public class ProductPageApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "floorId", value = "楼层id"),
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
     })
     @GetMapping("/page/floor/details")
-    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source,
-                                                              @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
-        return pageService.getPageFloorData(floorId, userId, source, flag);
+    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source) {
+        return pageService.getPageFloorData(floorId, userId, source);
     }
 
     /**
@@ -187,13 +179,11 @@ public class ProductPageApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "centreId", value = "分页详情楼层id"),
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
     })
     @GetMapping("/page/floor/centre")
-    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source,
-                                                               @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
-        return pageService.getPageCentreData(centreId, userId, source, flag);
+    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source) {
+        return pageService.getPageCentreData(centreId, userId, source);
     }
 
     /**
@@ -205,12 +195,11 @@ public class ProductPageApi {
     @ApiOperation("商品详情页(旧:/product/details)")
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-            @ApiImplicitParam(required = false, name = "productId", value = "商品Id"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = false, name = "productId", value = "商品Id")
     })
     @GetMapping("/product/details")
-    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId, @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
-        return pageService.getProductDetails(productId, userId, flag);
+    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId) {
+        return pageService.getProductDetails(productId, userId);
     }
 
     /**
@@ -221,16 +210,14 @@ public class ProductPageApi {
     @ApiOperation("再次购买商品列表(旧:/repeat/buyAgain)")
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/product/repeat")
     public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId,
-                                                                         @RequestParam(value = "flag", defaultValue = "2") Integer flag,
                                                                          @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                          @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        return pageService.getBuyAgainProducts(userId, flag, pageNum, pageSize);
+        return pageService.getBuyAgainProducts(userId, pageNum, pageSize);
     }
 
 
@@ -238,11 +225,14 @@ public class ProductPageApi {
      * 项目仪器详情页
      */
     @ApiOperation("项目仪器详情页(旧:/equipment/recommend)")
-    @ApiImplicitParam(required = false, name = "equipmentId", value = "项目仪器Id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "equipmentId", value = "项目仪器Id")
+    })
     @GetMapping("/equipment/details")
     @ResponseBody
-    public ResponseJson<PageDetailVo> getEquipmentDetails(Integer equipmentId) {
-        return pageService.getEquipmentDetails(equipmentId);
+    public ResponseJson<PageDetailVo> getEquipmentDetails(Integer equipmentId, Integer userId) {
+        return pageService.getEquipmentDetails(equipmentId, userId);
     }
 
 
@@ -346,18 +336,16 @@ public class ProductPageApi {
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
             @ApiImplicitParam(required = false, name = "source", value = "来源 : 1 网站 ; 2 小程序"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/svip/product/page")
     public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
-                                                                @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+                                                                @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         if (null == userId || source == null) {
             return ResponseJson.error("参数错误", null);
         }
-        return pageService.getSvipProductPage(userId, source, pageNum, pageSize, flag);
+        return pageService.getSvipProductPage(userId, source, pageNum, pageSize);
     }
 
     /**

+ 6 - 9
src/main/java/com/caimei365/commodity/controller/ProductPriceApi.java

@@ -38,15 +38,14 @@ public class ProductPriceApi {
     @ApiOperation("获取商品详情价格(旧:/product/detail/price)(注意:supplierId更改为shopId)")
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
-            @ApiImplicitParam(required = true, name = "productId", value = "商品Id"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
     })
     @GetMapping("/detail")
-    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId, @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId) {
         if (null == userId || null == productId) {
             return ResponseJson.error("参数错误", null);
         }
-        return priceService.getDetailPrice(userId, productId, flag);
+        return priceService.getDetailPrice(userId, productId);
     }
 
     /**
@@ -59,16 +58,14 @@ public class ProductPriceApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
             @ApiImplicitParam(required = true, name = "productIds", value = "商品Ids,逗号拼接"),
-            @ApiImplicitParam(required = true, name = "source", value = "来源 : 1 网站 ; 2 小程序"),
-            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
+            @ApiImplicitParam(required = true, name = "source", value = "来源 : 1 网站 ; 2 小程序")
     })
     @GetMapping("/list")
-    public ResponseJson<List<PriceVo>> getProductPrice(Integer userId, String productIds, Integer source,
-                                                       @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+    public ResponseJson<List<PriceVo>> getProductPrice(Integer userId, String productIds, Integer source) {
         if (null == userId || StringUtils.isEmpty(productIds) || source == null) {
             return ResponseJson.error("参数错误", null);
         }
-        return priceService.getListPrice(userId, productIds, source, flag);
+        return priceService.getListPrice(userId, productIds, source);
     }
 
     /**

+ 1 - 1
src/main/java/com/caimei365/commodity/controller/ProductShopApi.java

@@ -37,7 +37,7 @@ public class ProductShopApi {
     @ApiOperation("供应商-主推商品(旧:/supplier/home/products)")
     @ApiImplicitParams({
         @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id(旧:supplierId)"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份:1协销,2会员机构,3供应商,4普通机构")
+        @ApiImplicitParam(required = false, name = "identity", value = "用户身份:1协销,2会员机构,3供应商,4普通机构,5医美机构")
     })
     @GetMapping("/product/main")
     public ResponseJson<List<ProductListVo>> getSupplierMainProducts(Integer shopId, @RequestParam(value = "identity", defaultValue = "0") Integer identity) {

+ 1 - 1
src/main/java/com/caimei365/commodity/controller/PromotionsApi.java

@@ -70,7 +70,7 @@ public class PromotionsApi {
     @ApiOperation("获取促销活动凑单商品(旧:/product/promotion/products)")
     @ApiImplicitParams({
         @ApiImplicitParam(required = true, name = "promotionsId", value = "促销活动Id"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构"),
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })

+ 5 - 5
src/main/java/com/caimei365/commodity/controller/SearchProductApi.java

@@ -41,7 +41,7 @@ public class SearchProductApi {
             @ApiImplicitParam(required = false, name = "newFlag", value = "查询新品标记,默认0,新品1"),
             @ApiImplicitParam(required = false, name = "promotionFlag", value = "查询促销标记,默认0,促销1"),
             @ApiImplicitParam(required = false, name = "idType", value = "id类型:1一级分类,2二级分类,3三级分类"),
-            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构")
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构")
     })
     @GetMapping("/brand")
     public ResponseJson<Set<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType,
@@ -63,7 +63,7 @@ public class SearchProductApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
             @ApiImplicitParam(required = false, name = "brandIds", value = "品牌id字符串,逗号隔开"),
-            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构"),
             @ApiImplicitParam(required = false, name = "newFlag", value = "查询新品标记,默认0,新品1"),
             @ApiImplicitParam(required = false, name = "promotionFlag", value = "查询促销标记,默认0,促销1"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
@@ -95,7 +95,7 @@ public class SearchProductApi {
             @ApiImplicitParam(required = true, name = "id", value = "bigTypeID/smallTypeID/tinyTypeID"),
             @ApiImplicitParam(required = true, name = "idType", value = "id类型:1一级分类,2二级分类,3三级分类"),
             @ApiImplicitParam(required = false, name = "brandIds", value = "品牌id字符串,逗号隔开"),
-            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构"),
             @ApiImplicitParam(required = false, name = "newFlag", value = "查询新品标记,默认0,新品1"),
             @ApiImplicitParam(required = false, name = "promotionFlag", value = "查询促销标记,默认0,促销1"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
@@ -125,7 +125,7 @@ public class SearchProductApi {
     @ApiOperation("根据小程序运营分类Id搜索商品")
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "id", value = "运营级分类Id"),
-            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
             @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
@@ -152,7 +152,7 @@ public class SearchProductApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "id", value = "供应商Id"),
             @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
-            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
             @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),

+ 1 - 1
src/main/java/com/caimei365/commodity/controller/SearchQueryApi.java

@@ -99,7 +99,7 @@ public class SearchQueryApi {
     @ApiOperation("根据关键词搜索供应商")
     @ApiImplicitParams({
         @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构"),
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })

+ 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);
 
     /**
      * 查询可以领取的券

+ 4 - 0
src/main/java/com/caimei365/commodity/mapper/PriceMapper.java

@@ -61,4 +61,8 @@ public interface PriceMapper {
     void insertProductSales(ProductSalesVo salesVo);
 
     void updateProductSales(ProductSalesVo salesVo);
+    /**
+     * 会员机构类型:1医美,2生美
+     */
+    Integer getClubTypeById(Integer userId);
 }

+ 4 - 0
src/main/java/com/caimei365/commodity/mapper/PromotionsMapper.java

@@ -25,6 +25,10 @@ public interface PromotionsMapper {
      * 通过商品Id获取促销信息
      */
     PromotionsVo getPromotionsByProductId(Integer productId);
+    /**
+     * 通过商品Id与用户身份获取促销信息
+     */
+    PromotionsVo getPricePromotions(Integer productId, Integer identity);
     /**
      * 获取促销赠品
      */

+ 1 - 1
src/main/java/com/caimei365/commodity/model/vo/PriceVo.java

@@ -43,7 +43,7 @@ public class PriceVo implements Serializable {
      */
     private Integer maxBuyNumber;
     /**
-     * 是否公开机构价 0公开价格 1不公开价格
+     * 是否公开机构价: 0公开价格,1不公开价格,2仅对会员机构公开,3仅对医美机构公开
      */
     private Integer priceFlag;
     /**

+ 1 - 1
src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java

@@ -56,7 +56,7 @@ public class ProductItemVo implements Serializable {
      */
     private Integer priceGrade;
     /**
-     * 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见
+     * 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
      */
     private String visibility;
     /**

+ 4 - 2
src/main/java/com/caimei365/commodity/model/vo/PromotionsVo.java

@@ -16,8 +16,6 @@ import java.util.List;
 @Data
 public class PromotionsVo implements Serializable {
     private static final long serialVersionUID = 1L;
-
-    private Integer seen;
     private Integer id;
     /**
      * 促销名称
@@ -27,6 +25,10 @@ public class PromotionsVo implements Serializable {
      * 促销描述
      */
     private String description;
+    /**
+     * 活动可见度, 1所有人,2仅对机构
+     */
+    private Integer seen;
     /**
      * 分类: 1单品促销,2凑单促销,3店铺促销
      */

+ 1 - 1
src/main/java/com/caimei365/commodity/model/vo/SecondDetailVo.java

@@ -142,7 +142,7 @@ public class SecondDetailVo implements Serializable {
      */
     private String contactMobile;
     /**
-     * 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见
+     * 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
      */
     private Integer visibility;
 

+ 9 - 9
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -30,7 +30,7 @@ public interface PageService {
      * @param userId 用户id
      * @param source 来源:1网站,2小程序
      */
-    ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source, Integer flag);
+    ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source);
 
     /**
      * 首页楼层数据
@@ -38,7 +38,7 @@ public interface PageService {
      * @param userId 用户id
      * @param source 来源:1网站,2小程序
      */
-    ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source, Integer flag);
+    ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source);
 
     /**
      * 首页基础数据(小程序)
@@ -74,7 +74,7 @@ public interface PageService {
      * @param userId 用户id
      * @param source 来源 : 1 网站 ; 2 小程序
      */
-    ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source, Integer flag);
+    ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source);
 
     /**
      * 楼层详情
@@ -83,7 +83,7 @@ public interface PageService {
      * @param userId  用户id
      * @param source  来源 : 1 网站 ; 2 小程序
      */
-    ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source, Integer flag);
+    ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source);
 
     /**
      * 分页详情楼层详情
@@ -92,7 +92,7 @@ public interface PageService {
      * @param userId   用户id
      * @param source   来源 : 1 网站 ; 2 小程序
      */
-    ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source, Integer flag);
+    ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source);
 
     /**
      * 商品详情页
@@ -100,21 +100,21 @@ public interface PageService {
      * @param productId 商品Id
      * @param userId    用户Id
      */
-    ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId, Integer flag);
+    ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId);
 
     /**
      * 再次购买商品列表
      *
      * @param userId 用户Id
      */
-    ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, Integer flag, int pageNum, int pageSize);
+    ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, int pageNum, int pageSize);
 
     /**
      * 项目仪器详情页
      *
      * @param equipmentId 项目仪器Id
      */
-    ResponseJson<PageDetailVo> getEquipmentDetails(Integer equipmentId);
+    ResponseJson<PageDetailVo> getEquipmentDetails(Integer equipmentId, Integer userId);
 
     /**
      * 商品详情页-图片
@@ -185,7 +185,7 @@ public interface PageService {
      * @param pageSize 每页数量
      * @return
      */
-    ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize, Integer flag);
+    ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize);
 
     /**
      * 充值商品详情

+ 2 - 2
src/main/java/com/caimei365/commodity/service/PriceService.java

@@ -20,7 +20,7 @@ public interface PriceService {
      * @param productId 商品Id
      * @return PriceVo
      */
-    ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId, Integer flag);
+    ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId);
 
     /**
      * 获取商品列表价格
@@ -30,7 +30,7 @@ public interface PriceService {
      * @param source     来源 : 1 网站 ; 2 小程序
      * @return List<PriceVo>
      */
-    ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source, Integer flag);
+    ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source);
 
     /**
      * 获取阶梯价格

+ 14 - 2
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,11 +99,20 @@ 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);
+            priceUtilService.setProductDetails(userId, p);
         });
         PageInfo<ProductItemVo> pageInfo = new PageInfo<>(productList);
         map.put("coupon", coupon);

+ 74 - 55
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -106,7 +106,7 @@ public class PageServiceImpl implements PageService {
      */
     @Override
     @Cacheable(value = "insCommodityData", key = "#pageId+'-'+#userId+'-'+#source", unless = "#result == null")
-    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source, Integer flag) {
+    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source) {
         source = source == null ? 1 : source;
         Map<String, Object> map = new HashMap<>(3);
         Integer typeSort = pageMapper.getPageTypeSort(pageId);
@@ -117,7 +117,7 @@ public class PageServiceImpl implements PageService {
             setFloorLinkType(floorContent);
             floor.setFloorContent(floorContent);
             List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
-            setFloorImageProduct(userId, floorImageList, source, flag);
+            setFloorImageProduct(userId, floorImageList, source);
             floor.setFloorImageList(floorImageList);
         }
         map.put("typeSort", typeSort);
@@ -134,7 +134,7 @@ public class PageServiceImpl implements PageService {
      */
     @Cacheable(value = "getHomeCommodityData", key = "#userId +'-'+ #source", unless = "#result == null")
     @Override
-    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source, Integer flag) {
+    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source) {
         Map<String, Object> map = new HashMap<>(2);
         //楼层管理
         source = source == null ? 1 : source;
@@ -150,7 +150,7 @@ public class PageServiceImpl implements PageService {
                 floorIterator.remove();
                 continue;
             }
-            setFloorImageProduct(userId, floorImageList, source, flag);
+            setFloorImageProduct(userId, floorImageList, source);
             floor.setFloorImageList(floorImageList);
         }
         map.put("homePageFloor", homePageFloor);
@@ -352,7 +352,7 @@ public class PageServiceImpl implements PageService {
      */
     @Cacheable(value = "getPageBeautyData", key = "#userId +'-'+ #pageId +'-'+ #source", unless = "#result == null")
     @Override
-    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source, Integer flag) {
+    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source) {
         if (pageId == null) {
             return ResponseJson.error("参数异常: 页面id不能为空!", null);
         }
@@ -375,7 +375,7 @@ public class PageServiceImpl implements PageService {
             } else {
                 setFloorLinkType(floorContent);
                 List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
-                setFloorImageProduct(userId, floorImageList, source, flag);
+                setFloorImageProduct(userId, floorImageList, source);
                 floor.setFloorImageList(floorImageList);
                 String templateTypeStr = floorContent.getTemplateType();
                 if (StringUtils.isNotEmpty(templateTypeStr)) {
@@ -426,14 +426,14 @@ public class PageServiceImpl implements PageService {
      * @param source  来源 : 1 网站 ; 2 小程序
      */
     @Override
-    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source, Integer flag) {
+    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source) {
         if (floorId == null) {
             return ResponseJson.error("参数异常: 页面id不能为空!", null);
         }
         FloorContentVo floorContent = pageMapper.getFloorContentById(floorId);
         setFloorLinkType(floorContent);
         List<FloorImageVo> floorImageList = pageMapper.getFloorImageById(floorId, source);
-        setFloorImageProduct(userId, floorImageList, source, flag);
+        setFloorImageProduct(userId, floorImageList, source);
         Map<String, Object> map = new HashMap<>(2);
         map.put("floorContent", floorContent);
         map.put("floorImageList", floorImageList);
@@ -448,7 +448,7 @@ public class PageServiceImpl implements PageService {
      * @param source   来源 : 1 网站 ; 2 小程序
      */
     @Override
-    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source, Integer flag) {
+    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source) {
         if (centreId == null) {
             return ResponseJson.error("参数异常: 分页详情楼层id不能为空!", null);
         }
@@ -471,7 +471,7 @@ public class PageServiceImpl implements PageService {
             }
         }
         List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(centreId, source);
-        setFloorImageProduct(userId, floorImageList, source, flag);
+        setFloorImageProduct(userId, floorImageList, source);
         Map<String, Object> map = new HashMap<>(2);
         map.put("floorContent", floorContent);
         map.put("floorImageList", floorImageList);
@@ -485,7 +485,7 @@ public class PageServiceImpl implements PageService {
      * @param userId    用户Id
      */
     @Override
-    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId, Integer flag) {
+    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId) {
         ProductDetailVo product = pageMapper.getProductDetails(productId);
         if (product == null) {
             //商品不存在
@@ -560,25 +560,33 @@ public class PageServiceImpl implements PageService {
             shop.setBusinessLicense(ImageUtils.getImageURL("shopLogo", shop.getBusinessLicense(), 0, domain));
             product.setShop(shop);
         }
-        // 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见
+        // 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
         Integer visibility = product.getVisibility();
         if (null != userId && userId > 0) {
             // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
             Integer identity = shopMapper.getUserIdentityById(userId);
+            // 会员机构类型:1医美,2生美
+            Integer clubType = 0;
+            if (null != identity && identity == 2) {
+                clubType = priceMapper.getClubTypeById(userId);
+            }
             // 超级会员用户id
-            Integer svipUserId = priceMapper.getSvipUserIdByUserId(userId);
-            // 超级会员
-            boolean pass1 = null != svipUserId;
-            // 协销 | 会员机构 | 综合供应商
-            boolean pass2 = null != identity && (identity == 1 || identity == 2);
+            Integer superVipId = priceMapper.getSvipUserIdByUserId(userId);
+            // 所有人可见
+            boolean pass1 = visibility == 3;
+            // 协销
+            boolean pass2 = null != identity && identity == 1;
+            // 医美机构
+            boolean pass3 = visibility == 4 && (null != clubType && clubType == 1);
+            // 会员机构 | 超级会员
+            boolean pass4 = visibility == 1 && (null != superVipId || (null != identity && identity == 2));
             // 普通机构
-            boolean pass3 = null != identity && (identity == 4 && (visibility == 2 || visibility == 3));
-            // 游客
-            boolean pass4 = visibility == 3;
-            if (!(pass1 || pass2 || pass3 || pass4)) {
+            boolean pass5 = visibility == 2 && (null != identity && (identity == 4 || identity == 2));
+            // 没有权限查看该商品
+            if (!(pass1 || pass2 || pass3 || pass4 || pass5)) {
                 return ResponseJson.success(1, "没有权限查看该商品", new ProductDetailVo());
             }
-        } else if (2 == visibility || 1 == visibility) {
+        } else if (2 == visibility || 1 == visibility || 4 == visibility) {
             return ResponseJson.success(1, "没有权限查看该商品,userId为空", new ProductDetailVo());
         }
         // 商品不处于已删除/待审核/审核未通过的状态
@@ -586,7 +594,7 @@ public class PageServiceImpl implements PageService {
             // 数据库获取基本价格信息
             PriceVo price = priceMapper.getDetailPrice(productId);
             // 根据用户id设置详细价格
-            priceUtilService.setPriceByUserId(price, userId, flag);
+            priceUtilService.setPriceByUserId(price, userId);
             // 设置价格
             product.setActStatus(price.getActStatus());
             product.setPrice(price.getPrice());
@@ -624,7 +632,7 @@ public class PageServiceImpl implements PageService {
      * @param pageSize
      */
     @Override
-    public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, Integer flag, int pageNum, int pageSize) {
+    public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, int pageNum, int pageSize) {
         if (null == userId) {
             return ResponseJson.error("参数错误:用户Id不能为空!", null);
         }
@@ -639,7 +647,7 @@ public class PageServiceImpl implements PageService {
             boolean state = (costFlag == 1 && MathUtil.compare(costPrice, discountPrice) >= 0) || MathUtil.compare(discountPrice, price) > 0;
             product.setRepurchasePriceState(state);
             // 设置商品主图及价格
-            priceUtilService.setProductDetails(userId, product, flag);
+            priceUtilService.setProductDetails(userId, product);
             //优惠券标识
             Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), 2);
             product.setCouponsLogo(couponsLogo);
@@ -654,9 +662,17 @@ public class PageServiceImpl implements PageService {
      * @param equipmentId 项目仪器Id
      */
     @Override
-    public ResponseJson<PageDetailVo> getEquipmentDetails(Integer equipmentId) {
-        if (equipmentId == null) {
-            return ResponseJson.error("参数异常:项目仪器Id不能为空!", null);
+    public ResponseJson<PageDetailVo> getEquipmentDetails(Integer equipmentId, Integer userId) {
+        // 项目仪器详情只针对资质机构开放
+        Integer identity = 0;
+        if (null != userId && userId > 0) {
+            // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
+            identity = shopMapper.getUserIdentityById(userId);
+            identity = null == identity ? 0 : identity;
+        }
+        boolean flag  = (identity == 1 || identity == 2 || identity == 3);
+        if (!flag) {
+            return ResponseJson.success(1, "没有权限查看该项目仪器", new PageDetailVo());
         }
         //仪器详情
         PageDetailVo equipment = pageMapper.getPageDetails(equipmentId, 2);
@@ -893,7 +909,7 @@ public class PageServiceImpl implements PageService {
     /**
      * 设置楼层相关图片的商品信息
      */
-    private void setFloorImageProduct(Integer userId, List<FloorImageVo> floorImageList, Integer source, Integer flag) {
+    private void setFloorImageProduct(Integer userId, List<FloorImageVo> floorImageList, Integer source) {
         Iterator<FloorImageVo> iterator = floorImageList.iterator();
         while (iterator.hasNext()) {
             FloorImageVo image = iterator.next();
@@ -903,36 +919,39 @@ public class PageServiceImpl implements PageService {
             image.setLinkParam(linkParam);
             // 超级会员标识
             Integer svipUserId = pageMapper.getSvipUserIdByUserId(userId);
-            boolean svipUserFlag = null != svipUserId;
+            boolean isSuperVip = null != svipUserId;
+            // 根据用户Id查询用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构
+            Integer identity = priceMapper.getIdentityByUserId(userId);
+            if (null == identity) {identity = 0;}
+            // 会员机构类型:1医美,2生美
+            Integer clubType = 0;
+            if (identity == 2) {
+                clubType = priceMapper.getClubTypeById(userId);
+                if (null == clubType) {clubType = 0;}
+            }
             if (image.getProductId() != null) {
                 // 获取商品及价格
                 ProductItemVo product = pageMapper.getProductItemById(image.getProductId());
                 if (product != null) {
-                    // 商品价格
-                    priceUtilService.setProductDetails(userId, product, flag);
-                    // 设置商品主图
-                    image.setListType(1);
-                    image.setName(product.getName());
-                    image.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
-                    image.setProduct(product);
-                    if (userId != null) {
-                        if (product.getUserIdentity() > 0) {
-                            if (!svipUserFlag && 4 == product.getUserIdentity() && "1".equals(product.getVisibility())) {
-                                iterator.remove();
-                            }
-                        } else {
-                            if ("1".equals(product.getVisibility()) || "2".equals(product.getVisibility())) {
-                                iterator.remove();
-                            }
-                        }
+                    // visibility  3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
+                    String visibility = product.getVisibility();
+                    boolean visibileFlag = "3".equals(visibility) || ("4".equals(visibility) && clubType == 1) || ("1".equals(visibility) && (isSuperVip || identity == 2))
+                            || ("2".equals(visibility) && (isSuperVip || identity == 2 || identity == 4));
+                    if (!visibileFlag) {
+                        iterator.remove();
                     } else {
-                        if ("1".equals(product.getVisibility()) || "2".equals(product.getVisibility())) {
-                            iterator.remove();
-                        }
+                        // 商品价格
+                        priceUtilService.setProductDetails(userId, product);
+                        // 设置商品主图
+                        image.setListType(1);
+                        image.setName(product.getName());
+                        image.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
+                        //优惠券标识
+                        Boolean couponsLogo = setCouponsLogo(userId, image.getProductId(), source);
+                        product.setCouponsLogo(couponsLogo);
+
+                        image.setProduct(product);
                     }
-                    //优惠券标识
-                    Boolean couponsLogo = setCouponsLogo(userId, image.getProductId(), source);
-                    product.setCouponsLogo(couponsLogo);
                 } else {
                     iterator.remove();
                 }
@@ -1146,13 +1165,13 @@ public class PageServiceImpl implements PageService {
     }
 
     @Override
-    public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize, Integer flag) {
+    public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize) {
         Map<String, Object> svipProductPageData = new HashMap<>(2);
         String adsImage = pageMapper.getSvipProductAdsImage(userId, source);
         PageHelper.startPage(pageNum, pageSize);
         List<ProductItemVo> svipProductList = pageMapper.getSvipProductList();
         svipProductList.forEach(svipProduct -> {
-            priceUtilService.setProductDetails(userId, svipProduct, flag);
+            priceUtilService.setProductDetails(userId, svipProduct);
             svipProduct.setImage(ImageUtils.getImageURL("product", svipProduct.getImage(), 0, domain));
         });
         PaginationVo<ProductItemVo> svipProductPage = new PaginationVo<>(svipProductList);

+ 4 - 4
src/main/java/com/caimei365/commodity/service/impl/PriceServiceImpl.java

@@ -49,11 +49,11 @@ public class PriceServiceImpl implements PriceService {
      * @return PriceVo
      */
     @Override
-    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId,Integer flag) {
+    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId) {
         // 数据库获取基本价格信息
         PriceVo price = priceMapper.getDetailPrice(productId);
         // 根据用户id设置详细价格
-        priceUtilService.setPriceByUserId(price, userId,flag);
+        priceUtilService.setPriceByUserId(price, userId);
         log.info(">>>读取商品价格,商品ID:" + productId + ",用户ID:" + userId);
         return ResponseJson.success(price);
     }
@@ -66,7 +66,7 @@ public class PriceServiceImpl implements PriceService {
      * @return List<PriceVo>
      */
     @Override
-    public ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source, Integer flag) {
+    public ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source) {
         List<Integer> productIdList = Lists.newArrayList();
         if (productIds.contains(",")) {
             String[] productArr = productIds.split(",");
@@ -83,7 +83,7 @@ public class PriceServiceImpl implements PriceService {
         List<PriceVo> priceList = priceMapper.getListPriceByProductIds(productIdList);
         for (PriceVo price : priceList) {
             // 根据用户id设置详细价格
-            priceUtilService.setPriceByUserId(price, userId, flag);
+            priceUtilService.setPriceByUserId(price, userId);
             Boolean couponsLogo = pageService.setCouponsLogo(userId, price.getProductId(), source);
             price.setCouponsLogo(couponsLogo);
         }

+ 7 - 3
src/main/java/com/caimei365/commodity/service/impl/PromotionsServiceImpl.java

@@ -90,10 +90,14 @@ public class PromotionsServiceImpl implements PromotionsService {
      */
     @Override
     public ResponseJson<PageInfo<ProductListVo>> getPromotionProduct(Integer promotionsId, Integer identity, int pageNum, int pageSize) {
-        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构 ||| visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
+        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构
+        // visibility:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
         List<Integer> visibilityList = new ArrayList<>();
-        if (identity == 1 || identity == 2) {
-            // 协销 | 会员机构 | 综合供应商
+        if (identity == 1 || identity == 5) {
+            // 协销 | 医美机构 | 综合供应商
+            visibilityList.addAll(Arrays.asList(1,2,3,4));
+        } else if (identity == 2) {
+            // 会员机构
             visibilityList.addAll(Arrays.asList(1,2,3));
         } else if (identity == 4) {
             // 普通机构

+ 34 - 16
src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java

@@ -1,7 +1,6 @@
 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;
@@ -44,9 +43,6 @@ public class SecondHandServiceImpl implements SecondHandService {
     private RedisService redisService;
     @Resource
     private PriceMapper priceMapper;
-    @Resource
-    private PageMapper pageMapper;
-
 
     /**
      * 二手商品列表
@@ -65,6 +61,13 @@ public class SecondHandServiceImpl implements SecondHandService {
         Integer userIdentity = 0;
         if (userId != null && userId > 0) {
             userIdentity = priceMapper.getIdentityByUserId(userId);
+            if (null != userIdentity && userIdentity == 2) {
+                // 会员机构类型:1医美,2生美
+                Integer clubType = priceMapper.getClubTypeById(userId);
+                if (null != clubType && clubType == 1){
+                    userIdentity = 5;
+                }
+            }
         }
         PageHelper.startPage(pageNum, pageSize);
         List<SecondListVo> secondList = secondHandMapper.getSeconHandList(userIdentity, secondHandType, instrumentType, name);
@@ -107,20 +110,35 @@ public class SecondHandServiceImpl implements SecondHandService {
      */
     @Override
     public ResponseJson<SecondDetailVo> getSecondHandDetail(Integer userId, Integer productId) {
-        //0游客,2会员机构,4普通机构
-        Integer userIdentity = 0;
-        if (userId != null && userId > 0) {
-            userIdentity = priceMapper.getIdentityByUserId(userId);
-        }
-        // 超级会员标识
-        Integer svipUserId = pageMapper.getSvipUserIdByUserId(userId);
-        boolean svipUserFlag = null != svipUserId;
         SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
+        // 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
         Integer visibility = second.getVisibility();
-        boolean b = userIdentity == 0 && (visibility == 1 || visibility == 2);
-        boolean a = userIdentity == 4 && visibility == 1 && !svipUserFlag;
-        if (b || a) {
-            return ResponseJson.error("无权限查看", null);
+        if (null != userId && userId > 0) {
+            // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
+            Integer identity = priceMapper.getIdentityByUserId(userId);
+            // 会员机构类型:1医美,2生美
+            Integer clubType = 0;
+            if (null != identity && identity == 2) {
+                clubType = priceMapper.getClubTypeById(userId);
+            }
+            // 超级会员用户id
+            Integer superVipId = priceMapper.getSvipUserIdByUserId(userId);
+            // 所有人可见
+            boolean pass1 = visibility == 3;
+            // 协销
+            boolean pass2 = null != identity && identity == 1;
+            // 医美机构
+            boolean pass3 = visibility == 4 && (null != clubType && clubType == 1);
+            // 会员机构 | 超级会员
+            boolean pass4 = visibility == 1 && (null != superVipId || (null != identity && identity == 2));
+            // 普通机构
+            boolean pass5 = visibility == 2 && (null != identity && (identity == 4 || identity == 2));
+            // 没有权限查看该商品
+            if (!(pass1 || pass2 || pass3 || pass4 || pass5)) {
+                return ResponseJson.success(1, "没有权限查看该商品", new SecondDetailVo());
+            }
+        } else if (2 == visibility || 1 == visibility || 4 == visibility) {
+            return ResponseJson.success(1, "没有权限查看该商品,userId为空", new SecondDetailVo());
         }
         // 优化地址信息
         String provinceCityDistrict = second.getProvinceCityDistrict();

+ 3 - 3
src/main/java/com/caimei365/commodity/service/impl/SellerServiceImpl.java

@@ -57,7 +57,7 @@ public class SellerServiceImpl implements SellerService {
         List<ProductItemVo> productList = sellerMapper.getSingleProductList(searchWord);
         productList.forEach(product -> {
             // 设置商品主图及价格
-            priceUtilService.setProductDetails(clubUserId, product, 1);
+            priceUtilService.setProductDetails(clubUserId, product);
         });
         PaginationVo<ProductItemVo> pageData = new PaginationVo<>(productList);
         return ResponseJson.success(pageData);
@@ -90,7 +90,7 @@ public class SellerServiceImpl implements SellerService {
                 product.setInitProductNum(0);
                 product.setTotalPrice(0d);
                 // 设置商品主图及价格
-                priceUtilService.setProductDetails(clubUserId, product, 1);
+                priceUtilService.setProductDetails(clubUserId, product);
                 //优惠券标识
                 Boolean couponsLogo = pageService.setCouponsLogo(clubUserId, product.getProductId(), 2);
                 product.setCouponsLogo(couponsLogo);
@@ -129,7 +129,7 @@ public class SellerServiceImpl implements SellerService {
             }
             productList.forEach(product -> {
                 // 设置商品主图及价格
-                priceUtilService.setProductDetails(userId, product, 2);
+                priceUtilService.setProductDetails(userId, product);
                 //优惠券标识
                 Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), source);
                 product.setCouponsLogo(couponsLogo);

+ 10 - 7
src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java

@@ -58,15 +58,18 @@ public class ShopServiceImpl implements ShopService {
         if (shopId == null) {
             return ResponseJson.error("参数异常:缺少供应商Id", null);
         }
-        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
-        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
+        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构,5医美机构
+        // visibility:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
         List<Integer> visibilityList = new ArrayList<>();
-        if (identity == 1 || identity == 2) {
-            // 协销 | 会员机构 | 综合供应商
-            visibilityList.addAll(Arrays.asList(1, 2, 3));
+        if (identity == 1 || identity == 5) {
+            // 协销 | 医美机构 | 综合供应商
+            visibilityList.addAll(Arrays.asList(1,2,3,4));
+        } else if (identity == 2) {
+            // 会员机构
+            visibilityList.addAll(Arrays.asList(1,2,3));
         } else if (identity == 4) {
             // 普通机构
-            visibilityList.addAll(Arrays.asList(2, 3));
+            visibilityList.addAll(Arrays.asList(2,3));
         } else {
             // 游客|所有人
             visibilityList.add(3);
@@ -112,7 +115,7 @@ public class ShopServiceImpl implements ShopService {
                 product.setIsChecked(false);
                 // 设置商品主图及价格
                 Integer userId = shopMapper.getUserIdByshopId(shopId);
-                priceUtilService.setProductDetails(userId, product, 3);
+                priceUtilService.setProductDetails(userId, product);
             }
         }
         PaginationVo<ProductItemVo> productPage = new PaginationVo<>(productList);

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

@@ -58,7 +58,7 @@ public class UserLikeServiceImpl implements UserLikeService {
         List<ProductItemVo> productList = likeMapper.findLikeList(userId);
         productList.forEach(product -> {
             // 设置商品主图及价格
-            priceUtilService.setProductDetails(userId, product, 2);
+            priceUtilService.setProductDetails(userId, product);
             //优惠券标识
             Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), 2);
             product.setCouponsLogo(couponsLogo);

+ 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>

+ 3 - 0
src/main/resources/mapper/PriceMapper.xml

@@ -137,4 +137,7 @@
             property=#{property}
         WHERE productId = #{productId}
     </update>
+    <select id="getClubTypeById" resultType="java.lang.Integer">
+        SELECT firstClubType FROM club WHERE userID = #{userId}
+    </select>
 </mapper>

+ 29 - 2
src/main/resources/mapper/PromotionsMapper.xml

@@ -36,8 +36,35 @@
         where (prp.productId = #{productId} or
                prp.supplierId = (select p.shopID from product p where p.productID = #{productId})
             )
-          and (pr.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
-          and pr.delFlag not in (1, 2)
+        and (pr.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
+        and pr.delFlag not in (1, 2)
+        order by pr.type desc
+        limit 1
+    </select>
+    <select id="getPricePromotions" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
+        select pr.id,
+            pr.name,
+            pr.description,
+            pr.type,
+            pr.mode,
+            pr.touchPrice,
+            pr.reducedPrice,
+            pr.beginTime,
+            pr.endTime,
+            pr.status,
+            prp.productId,
+            prp.supplierId as shopId,
+            pr.seen        as seen
+        from cm_promotions pr
+        left join cm_promotions_product prp on pr.id = prp.promotionsId
+        where (prp.productId = #{productId} or
+                prp.supplierId = (select p.shopID from product p where p.productID = #{productId})
+            )
+        and (pr.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
+        <if test="identity != 2 and identity != 4">
+            and pr.seen = 1
+        </if>
+        and pr.delFlag not in (1, 2)
         order by pr.type desc
         limit 1
     </select>

+ 7 - 1
src/main/resources/mapper/SearchMapper.xml

@@ -301,12 +301,18 @@
             <when test="identity == 1">
                 and p.validFlag in (2,3,9)
             </when>
-            <when test="identity == 2">
+            <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>
+            <when test="identity == 5">
+                and p.visibility in (1,2,3,4) and p.validFlag = 2
+            </when>
             <otherwise>
                 and p.visibility = 3 and p.validFlag = 2
             </otherwise>

+ 3 - 0
src/main/resources/mapper/SecondHandMapper.xml

@@ -73,6 +73,9 @@
         <if test="userIdentity == 4">
             AND p.visibility IN (2,3)
         </if>
+        <if test="userIdentity == 2">
+            AND p.visibility IN (1,2,3)
+        </if>
         order by cshd.onLineDate desc
     </select>
     <select id="getSecondHandDetail" resultType="com.caimei365.commodity.model.vo.SecondDetailVo">