| | |
| | | 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;
|
| | |
| | | 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);
|
| | |
| | | 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"));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("渠道ID申请出错:" + (resultJSON != null ? resultJSON.toString() : "未知错误"));
|
| | | }
|
| | |
|
| | | 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);
|
| | |
| | | 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"));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("会员运营ID申请出错:" + (resultJSON != null ? resultJSON.toString() : "未知错误"));
|
| | | }
|
| | |
|
| | | return null;
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static void getCouponByAuctionId(Long auctionId) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.itemid.coupon.get");
|
| | | map.put("platform", 2 + "");
|
| | | map.put("pid", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | map.put("num_iids", auctionId + "");
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | | System.out.print(json);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | class QuanInfo {
|