From ebce479a2d0634c90e5f80045e204248336b410d Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 30 五月 2019 09:42:37 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeBaseUtil.java | 36 +++++++++++++++++++++++++++++++-----
1 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeBaseUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeBaseUtil.java
index eb562d1..e123c72 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeBaseUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeBaseUtil.java
@@ -10,6 +10,7 @@
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.TaoKeLogHelper;
+import com.yeshi.fanli.util.EmergencyUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoHttpUtil;
import com.yeshi.fanli.util.TimeUtil;
@@ -49,16 +50,23 @@
String result = TaoBaoHttpUtil.taoKeGet(params);
JSONObject data = JSONObject.fromObject(result);
if (data != null) {
- if (data.optJSONObject("error_response") != null
- && data.optJSONObject("error_response").optInt("code") == 7) {
+ if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 7
+ && "accesscontrol.limited-by-app-access-count"
+ .equalsIgnoreCase(data.optJSONObject("error_response").optString("sub_code"))) {
reportAppInvalid(app.getAppKey());
TaoKeLogHelper.error(params, result);
+ try {
+ EmergencyUtil.baoJin("monitor-error-tb-app-limit-" + params.get("app_key"),
+ "娣樺疂APPKey璇锋眰闄愬埗銆�" + params.get("app_key") + "銆�", new String[] { "18581318252" });
+ } catch (Exception e1) {
+ }
throw new TaoKeApiException(TaoKeApiException.CODE_APPKEY_LIMIT, "娣樺疂璇锋眰闄愬埗:" + result, params);
} else if (data.optJSONObject("error_response") != null) {
throw new TaoKeApiException(TaoKeApiException.CODE_API_ERROR, result, params);
}
} else
throw new TaoKeApiException(TaoKeApiException.CODE_OTHER, ":" + result, params);
+ reValid(app.getAppKey());
return data;
}
@@ -82,13 +90,15 @@
params.put("v", "2.0");
params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
params.put("format", "json");
- params.put("adzone_id", app.getAdzoneId());
+ if (!StringUtil.isNullOrEmpty(app.getAdzoneId()))
+ params.put("adzone_id", app.getAdzoneId());
params.put("sign", getSign(params, "md5", app).toUpperCase());
String result = TaoBaoHttpUtil.taoKeGet(params);
JSONObject data = JSONObject.fromObject(result);
if (data != null) {
- if (data.optJSONObject("error_response") != null
- && data.optJSONObject("error_response").optInt("code") == 7) {
+ if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 7
+ && "accesscontrol.limited-by-app-access-count"
+ .equalsIgnoreCase(data.optJSONObject("error_response").optString("sub_code"))) {
reportAppInvalid(app.getAppKey());
throw new TaoKeApiException(TaoKeApiException.CODE_APPKEY_LIMIT, "娣樺疂璇锋眰闄愬埗:" + result, params);
} else if (data.optJSONObject("error_response") != null) {
@@ -96,6 +106,7 @@
}
} else
throw new TaoKeApiException(TaoKeApiException.CODE_OTHER, ":" + result, params);
+ reValid(app.getAppKey());
return data;
}
@@ -255,6 +266,8 @@
* @param appkey
*/
static void reportAppInvalid(String appkey) {
+ if (invalidMap == null)
+ return;
// 閿欒涓夋鍚庡啀鐪熸涓婃姤
if (invalidMap.get(appkey) == null)
invalidMap.put(appkey, 1);
@@ -268,6 +281,19 @@
lastTime = 0;
}
+ /**
+ * APPKey鎭㈠鍙敤
+ *
+ * @param appKey
+ */
+ static void reValid(String appKey) {
+ if (invalidMap == null)
+ return;
+ Integer count = invalidMap.get(appKey);
+ if (count != null && count > 0)
+ invalidMap.put(appKey, count - 1);
+ }
+
public static void setAppValid() {
HttpUtil.get("http://193.112.35.168:8091/tb/taoke/setappcanuse");
}
--
Gitblit v1.8.0