From 824d003d330a25b1f5b1e9ed30e4ad868868c2ab Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期一, 01 六月 2020 16:49:32 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeBaseUtil.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 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 e123c72..80c2c1c 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 @@ -69,6 +69,63 @@ reValid(app.getAppKey()); return data; } + + + /** + * 鏈嶅姟鍟嗚姹� + * @Title: baseScRequest + * @Description: + * @param param + * @param session + * @return + * @throws TaoKeApiException + * JSONObject 杩斿洖绫诲瀷 + * @throws + */ + public static JSONObject baseScRequest(Map<String, String> param,TaoKeAppInfo app, String session,String targetAppKey) throws TaoKeApiException { + // 澶嶅埗params + Map<String, String> params = new HashMap<>(); + if (param != null) { + Iterator<String> its = param.keySet().iterator(); + while (its.hasNext()) { + String key = its.next(); + params.put(key, param.get(key)); + } + } + + if (app == null) + throw new TaoKeApiException(TaoKeApiException.CODE_NO_USE, "鏃燼ppkey鍙敤"); + // 绛惧悕 + params.put("app_key", app.getAppKey()); + params.put("sign_method", "md5"); + params.put("v", "2.0"); + params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + params.put("format", "json"); + params.put("session", session); +// params.put("target_app_key", targetAppKey); + 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 + && "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; + } public static JSONObject baseRequest(Map<String, String> param, TaoKeAppInfo app) throws TaoKeApiException { // 澶嶅埗params -- Gitblit v1.8.0