From af0be3243ab0d75e38ae8213de461c4a584652f7 Mon Sep 17 00:00:00 2001
From: Administrator <1101184511@qq.com>
Date: 星期三, 05 三月 2025 01:10:18 +0800
Subject: [PATCH] 代理订单忽略

---
 src/main/java/com/taoke/autopay/controller/WebApiController.java |   38 +++++++++++++++++++++++++++++++-------
 1 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/controller/WebApiController.java b/src/main/java/com/taoke/autopay/controller/WebApiController.java
index 2ddcd2c..8a8b616 100644
--- a/src/main/java/com/taoke/autopay/controller/WebApiController.java
+++ b/src/main/java/com/taoke/autopay/controller/WebApiController.java
@@ -6,6 +6,7 @@
 import com.taoke.autopay.entity.KeyOrder;
 import com.taoke.autopay.entity.SystemConfigKeyEnum;
 import com.taoke.autopay.entity.WxUserInfo;
+import com.taoke.autopay.entity.agent.ChannelAgent;
 import com.taoke.autopay.exception.KeyOrderException;
 import com.taoke.autopay.exception.KeyVerifyException;
 import com.taoke.autopay.exception.WxOrderCountException;
@@ -13,6 +14,7 @@
 import com.taoke.autopay.service.KeyOrderService;
 import com.taoke.autopay.service.SystemConfigService;
 import com.taoke.autopay.service.WxUserService;
+import com.taoke.autopay.service.agent.ChannelAgentService;
 import com.taoke.autopay.utils.*;
 import com.taoke.autopay.vo.SubmitKeyInfo;
 import net.sf.json.JSONObject;
@@ -20,6 +22,7 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.util.AntPathMatcher;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.yeshi.utils.UrlUtils;
@@ -49,8 +52,11 @@
 
     @Resource
     private SystemConfigService systemConfigService;
-    @Autowired
+    @Resource
     private PayCountVerifyManager payCountVerifyManager;
+
+    @Resource
+    private ChannelAgentService channelAgentService;
 
 
     private KeyOrder addKey(SubmitKeyInfo keyInfo, Long wxUid) throws KeyVerifyException, KeyOrderException, WxOrderCountException {
@@ -146,12 +152,30 @@
         }
         keyInfo.setIpInfo(ipInfoMap.get(ip));
 
-        String citys = systemConfigService.getValueCache(SystemConfigKeyEnum.FORBIDDEN_SUBMIT_CITYS);
-        if (citys != null && ipInfoMap.get(ip) != null) {
-            List<String> cityList = Arrays.asList(citys.split(","));
-            if (cityList.contains(ipInfoMap.get(ip).getCity())) {
-                LogUtil.loggerDebug.warn("鍖哄煙灞忚斀锛歿}-{}", ip, new Gson().toJson(ipInfoMap.get(ip)));
-                return JsonUtil.loadFalseResult("鏆傛椂鏃犳硶涓婁紶鍙d护");
+        AntPathMatcher pathMatcher = new AntPathMatcher();
+
+        Map<String, String> paramsMap = HttpUtil.getPramsFromUrl(keyInfo.getReferer());
+        if (paramsMap.containsKey("a") && ipInfoMap.get(ip) != null) {
+            String alias = paramsMap.get("a");
+            ChannelAgent agent = channelAgentService.selectByAlias(alias);
+            if (!StringUtil.isNullOrEmpty(agent.getShieldedAreas())) {
+                String[] res = agent.getShieldedAreas().split(",");
+                String ipInfoStr = ipInfoMap.get(ip).getProvince() + "/" + ipInfoMap.get(ip).getCity();
+                boolean shield = false;
+                for (String pattern : res) {
+                    if (pathMatcher.match(pattern, ipInfoStr)) {
+                        shield = true;
+                        break;
+                    }
+                }
+                if (shield) {
+                    // 鍒ゆ柇鐢ㄦ埛鏄惁涓虹櫧鍚嶅崟
+                    if (user.getStatus() != WxUserInfo.STATUS_WHITE) {
+                        // 涓嶆槸鐧藉悕鍗曟墠闄愬埗
+                        LogUtil.loggerDebug.warn("鍖哄煙灞忚斀锛歿}-{}", ip, new Gson().toJson(ipInfoMap.get(ip)));
+                        return JsonUtil.loadFalseResult("鏆傛椂鏃犳硶涓婁紶鍙d护");
+                    }
+                }
             }
         }
 

--
Gitblit v1.8.0