Browse Source

fixed 商品可用平台查询条件优化

fushengqian 3 weeks ago
parent
commit
1904f0351f

+ 11 - 8
fuint-application/src/main/java/com/fuint/common/enums/PlatformTypeEnum.java

@@ -9,32 +9,35 @@ package com.fuint.common.enums;
 public enum PlatformTypeEnum {
 
     /**
-     * PC
+     * 微信小程序
      */
-    PC("PC", "PC端"),
+    MP_WEIXIN("MP-WEIXIN", "微信小程序", 1),
 
     /**
-     * H5
+     * PC
      */
-    H5("H5", "H5端"),
+    PC("PC", "PC端", 2),
 
     /**
-     * 微信小程序
+     * H5
      */
-    MP_WEIXIN("MP-WEIXIN", "微信小程序"),
+    H5("H5", "H5端", 3),
 
     /**
      * App客户端
      */
-    APP("APP", "App客户端");
+    APP("APP", "App客户端", 4);
 
     private String code;
 
     private String value;
 
-    PlatformTypeEnum(String code, String value) {
+    private Integer num;
+
+    PlatformTypeEnum(String code, String value, Integer num) {
         this.code = code;
         this.value = value;
+        this.num = num;
     }
 
     public String getCode() {

+ 13 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -146,10 +146,21 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
         }
         String platform = paginationRequest.getSearchParams().get("platform") == null ? "" : paginationRequest.getSearchParams().get("platform").toString();
         if (StringUtils.isNotBlank(platform)) {
-            if (platform.equals(PlatformTypeEnum.H5.getCode()) || platform.equals(PlatformTypeEnum.MP_WEIXIN.getCode()) || platform.equals("1")) {
+            if (platform.equals(PlatformTypeEnum.H5.getCode()) || platform.equals(PlatformTypeEnum.MP_WEIXIN.getCode())) {
+                // 会员端
                 lambdaQueryWrapper.in(MtGoods::getPlatform, new ArrayList<>(Arrays.asList("0", "1")));
-            } else if(platform.equals(PlatformTypeEnum.PC.getCode()) || platform.equals("2")) {
+            } else if(platform.equals(PlatformTypeEnum.PC.getCode())) {
+                // PC端
                 lambdaQueryWrapper.in(MtGoods::getPlatform, new ArrayList<>(Arrays.asList("0", "2")));
+            } else if(platform.equals("0")) {
+                // 不限制
+                lambdaQueryWrapper.eq(MtGoods::getPlatform, 0);
+            } else if(platform.equals("1")) {
+                // 仅会员端
+                lambdaQueryWrapper.eq(MtGoods::getPlatform, 1);
+            } else if (platform.equals("2")) {
+                // 仅PC端
+                lambdaQueryWrapper.eq(MtGoods::getPlatform, 2);
             }
         }
         String sortType = paginationRequest.getSearchParams().get("sortType") == null ? "" : paginationRequest.getSearchParams().get("sortType").toString();