From 8579b9ea8205a2bcea72d2c9a843fdad1ed2e665 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 18 七月 2019 12:09:33 +0800 Subject: [PATCH] 淘宝授权失败添加账号消息 --- fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java index 6c70940..c82ffa5 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java @@ -22,6 +22,7 @@ import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; +import com.yeshi.fanli.exception.taobao.TaoBaoAuthException; import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.log.LogHelper; @@ -1646,7 +1647,7 @@ return null; } - public static String getRelationId(String accessToken, String appKey, String appSecret) { + public static String getRelationId(String accessToken, String appKey, String appSecret) throws TaoBaoAuthException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.sc.publisher.info.save"); map.put("session", accessToken); @@ -1662,14 +1663,19 @@ return resultJSON.optJSONObject("tbk_sc_publisher_info_save_response").optJSONObject("data") .optString("relation_id"); } catch (TaoKeApiException e) { - e.printStackTrace(); - LogHelper.error("娓犻亾ID鐢宠鍑洪敊:" + e.getMsg()); + JSONObject errorJSON = JSONObject.fromObject(e.getMsg()).optJSONObject("error_response"); + if (errorJSON.optInt("code") == 15 && errorJSON.optInt("sub_code") == 1)// 鏈疄鍚� + { + throw new TaoBaoAuthException(TaoBaoAuthException.CODE_NOT_REAL_NAME, errorJSON.optString("sub_msg")); + } else { + e.printStackTrace(); + LogHelper.error("娓犻亾ID鐢宠鍑洪敊:" + e.getMsg()); + throw new TaoBaoAuthException(TaoBaoAuthException.CODE_OTHER, errorJSON.optString("sub_msg")); + } } - - return null; } - public static String getSpecialId(String accessToken, String appKey, String appSecret) { + public static String getSpecialId(String accessToken, String appKey, String appSecret) throws TaoBaoAuthException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.sc.publisher.info.save"); map.put("session", accessToken); @@ -1685,11 +1691,16 @@ return resultJSON.optJSONObject("tbk_sc_publisher_info_save_response").optJSONObject("data") .optString("special_id"); } catch (TaoKeApiException e) { - e.printStackTrace(); - LogHelper.error("浼氬憳杩愯惀ID鐢宠鍑洪敊:" + resultJSON); + JSONObject errorJSON = JSONObject.fromObject(e.getMsg()).optJSONObject("error_response"); + if (errorJSON.optInt("code") == 15 && errorJSON.optInt("sub_code") == 1)// 鏈疄鍚� + { + throw new TaoBaoAuthException(TaoBaoAuthException.CODE_NOT_REAL_NAME, errorJSON.optString("sub_msg")); + } else { + e.printStackTrace(); + LogHelper.error("浼氬憳杩愯惀ID鐢宠鍑洪敊:" + e.getMsg()); + throw new TaoBaoAuthException(TaoBaoAuthException.CODE_OTHER, errorJSON.optString("sub_msg")); + } } - - return null; } public static void specialConvertItem(Long auctionId, TaoKeAppInfo app) { -- Gitblit v1.8.0