Explorar o código

fix 是否需要过滤特殊ip商品

zoujiajian hai 8 meses
pai
achega
2f4c55c1e4

+ 33 - 29
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -100,7 +100,7 @@ public class GoodsDonController {
      * 获取平台商品分类
      */
     @GetMapping("/get/category")
-    public Result<List<GoodsDonCategoryFrontView>> getCategory(String customId) {
+    public Result<List<GoodsDonCategoryFrontView>> getCategory(String customId, Boolean isFilter) {
 	    Long yhsId = null;
 	    if (StrUtil.isNotBlank(customId)) {
 		    yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
@@ -110,7 +110,7 @@ public class GoodsDonController {
 		    key += ":yhShop:" + yhsId;
 	    }
 	    Long fUid = StpUserUtil.getUserIdAfterLogin();
-	    Boolean filterGoodsIds = isFilterGoodsIds(fUid);
+	    Boolean filterGoodsIds = isFilterGoodsIds(fUid, isFilter);
 	    if (filterGoodsIds) {
 		    key += ":filter-ip";
 	    }
@@ -303,13 +303,13 @@ public class GoodsDonController {
      * h5 银河首页平台展示
      */
     @GetMapping("/get/homePage")
-    public Result<? extends Object> getGoodsHomePage(String customId) {
+    public Result<? extends Object> getGoodsHomePage(String customId, Boolean isFilter) {
 	    if (StrUtil.isNotBlank(customId)) {
 		    Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
 		    return shopGoods;
 	    }
 	    Long fUid = StpUserUtil.getUserIdAfterLogin();
-	    Boolean filterGoodsIds = isFilterGoodsIds(fUid);
+	    Boolean filterGoodsIds = isFilterGoodsIds(fUid, isFilter);
 	    String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
 	    if (filterGoodsIds) {
 		    h5CacheKey += ":filter-ip";
@@ -621,7 +621,7 @@ public class GoodsDonController {
 	 * 获取首页配置列表
 	 */
 	@GetMapping("/get/homeManage")
-	public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage(String customId, String dsCode, BigDecimal discount) {
+	public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage(String customId, String dsCode, BigDecimal discount, Boolean isFilter) {
 		String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage";
 		Long yhsId = null;
 		if (StrUtil.isNotBlank(customId)) {
@@ -629,7 +629,7 @@ public class GoodsDonController {
 			key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getName() + yhsId + ":homeManage";
 		}
 		Long fUid = StpUserUtil.getUserIdAfterLogin();
-		Boolean isFilterGoodsIds = isFilterGoodsIds(fUid);
+		Boolean isFilterGoodsIds = isFilterGoodsIds(fUid, isFilter);
 		AtomicBoolean isRemoveRg = new AtomicBoolean(false);
 		if (isFilterGoodsIds) {
 			key += ":filter-ip";
@@ -710,11 +710,15 @@ public class GoodsDonController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
-	public Boolean isFilterGoodsIds(Long userIdAfLogin) {
-        List<Long> filter_goodsIds = null;
-	    //获取当前ip地址
-	    String newestIpAddress = StringUtil.getNewestIpAddress(ServletUtil.getClientIP(request));
-	    if (newestIpAddress.contains("杭州") || newestIpAddress.contains("北京")) {
+	public Boolean isFilterGoodsIds(Long userIdAfLogin, Boolean isFilter) {
+		//是否需要过滤特殊ip
+		if (isFilter != null && !isFilter) {
+			return false;
+		}
+		List<Long> filter_goodsIds = null;
+		//获取当前ip地址
+		String newestIpAddress = StringUtil.getNewestIpAddress(ServletUtil.getClientIP(request));
+		if (newestIpAddress.contains("杭州") || newestIpAddress.contains("北京")) {
 //		    //过滤杭州Ai ChatGPT平台
 //		    SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
 //				    .eq(SysConfig::getSysKey, Constant.LOCATION_FOR_GOODS_IDS).last("limit 1"));
@@ -724,21 +728,21 @@ public class GoodsDonController {
 //			    } catch (Exception e) {
 //			    }
 //		    }
-		    if (userIdAfLogin == null) {
-			    //未登录 直接过滤
-			    return true;
-		    }
-		    if (userIdAfLogin != null) {
+			if (userIdAfLogin == null) {
+				//未登录 直接过滤
+				return true;
+			}
+			if (userIdAfLogin != null) {
 				//是否购买过AI产品
-			    Integer count = orderDonMapper.hasPaymentAiGoods(userIdAfLogin);
-			    if (count == 0) {
-				    //未购买 直接过滤
-				    return true;
-			    }
-		    }
-	    }
-        return false;
-    }
+				Integer count = orderDonMapper.hasPaymentAiGoods(userIdAfLogin);
+				if (count == 0) {
+					//未购买 直接过滤
+					return true;
+				}
+			}
+		}
+		return false;
+	}
 
 	public Boolean isHzIp() {
 		if (StringUtil.getRealAddressByIP(ServletUtil.getClientIP(request)).contains("无锡")) {
@@ -1096,7 +1100,7 @@ public class GoodsDonController {
 	 * 根据分类获取对应平台
 	 */
 	@GetMapping("/get/categoryGoods")
-	public Result<? extends Object> getGoodsByCategory(Long cgy, String customId, String dsCode, BigDecimal discount) {
+	public Result<? extends Object> getGoodsByCategory(Long cgy, String customId, String dsCode, BigDecimal discount, Boolean isFilter) {
 		if (StrUtil.isNotBlank(customId)) {
 			Result<List<YhShopGoodsFrontCategoryView>> shopGoods = getShopCategoryGoods(yhShopFrontService.getYhsIdByCustomId(customId), cgy);
 			return shopGoods;
@@ -1106,7 +1110,7 @@ public class GoodsDonController {
 		if (cgy != null) {
 			categoryGoodsKey += ":" + cgy;
 		}
-		Boolean isFilterGoodsIds = isFilterGoodsIds(fUid);
+		Boolean isFilterGoodsIds = isFilterGoodsIds(fUid, isFilter);
 		if (isFilterGoodsIds) {
 			categoryGoodsKey += ":filter-ip";
 		}
@@ -1343,10 +1347,10 @@ public class GoodsDonController {
 	 * 补贴规格列表
 	 */
 	@GetMapping("/get/subsidy")
-	public Result<List<GoodsDonSkuSubsidyFrontView>> getSubsidyGoods() {
+	public Result<List<GoodsDonSkuSubsidyFrontView>> getSubsidyGoods(Boolean isFilter) {
 		String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "subsidy";
 		Long fUid = StpUserUtil.getUserIdAfterLogin();
-		Boolean filterGoodsIds = isFilterGoodsIds(fUid);
+		Boolean filterGoodsIds = isFilterGoodsIds(fUid, isFilter);
 		if (filterGoodsIds) {
 			key += ":filter-ip";
 		}