From 2366d2ada9e67f915a06b51b3c5be08a00847f0c Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 22 一月 2019 10:47:06 +0800 Subject: [PATCH] 用户邀请码激活 --- fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java | 85 ++++++++++++++++++++++++++++++++++++------ 1 files changed, 72 insertions(+), 13 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 a19d1b0..043a5f9 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 @@ -25,6 +25,7 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; +import org.fanli.TaoKeTest; import org.yeshi.utils.taobao.TbImgUtil; import net.sf.json.JSONArray; @@ -158,6 +159,7 @@ map.put("method", "taobao.tbk.item.info.get"); map.put("num_iids", id + ""); String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); +// System.out.println(resultStr); JSONObject data = JSONObject.fromObject(resultStr); // 鍟嗗搧涓嬫灦 if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 15 @@ -193,6 +195,7 @@ goods.setProvcity(item.optString("provcity")); goods.setPictUrl(item.optString("pict_url")); goods.setShopTitle(item.optString("nick")); + goods.setSellerId(item.optLong("seller_id")); String optString = item.optString("shop_dsr"); if (!StringUtil.isNullOrEmpty(optString)) { @@ -218,30 +221,31 @@ if (item.optBoolean("free_shipment")) goods.setFreeShipment(1); + + System.out.println(item.optString("material_lib_type")); return goods; } return null; } - - - public static List<TaoBaoGoodsBrief> getBatchGoodsInfo(List<Long> listId) throws TaoKeApiException,TaobaoGoodsDownException { + + public static List<TaoBaoGoodsBrief> getBatchGoodsInfo(List<Long> listId) + throws TaoKeApiException, TaobaoGoodsDownException { if (listId == null || listId.size() == 0) { - throw new TaobaoGoodsDownException(1,"娣樺疂鍟嗗搧ID涓嶈兘涓虹┖"); + throw new TaobaoGoodsDownException(1, "娣樺疂鍟嗗搧ID涓嶈兘涓虹┖"); } - - if ( listId.size() > 40) { - throw new TaobaoGoodsDownException(1,"娣樺疂鍟嗗搧ID涓嶈兘瓒呰繃40涓�"); + + if (listId.size() > 40) { + throw new TaobaoGoodsDownException(1, "娣樺疂鍟嗗搧ID涓嶈兘瓒呰繃40涓�"); } - + StringBuffer ids = new StringBuffer(); - for (Long id: listId) { + for (Long id : listId) { ids.append(id + ","); } - - return getBatchGoodsInfos(ids.substring(0, ids.length() -1)); + + return getBatchGoodsInfos(ids.substring(0, ids.length() - 1)); } - /** * 鑾峰彇鍟嗗搧璇︽儏锛岀畝鐗� @@ -322,7 +326,9 @@ if (item.optBoolean("free_shipment")) goods.setFreeShipment(1); - + + if("1".equalsIgnoreCase(item.optString("material_lib_type"))) + TaoKeTest.count++; goodsList.add(goods); } } @@ -1435,6 +1441,59 @@ return result; } + /** + * 浠庢窐瀹濋摼鎺ヤ腑瑙f瀽鍟嗗搧ID锛堥珮绾ф帴鍙o級 + * + * @param link + * @return + */ + public static String parseAuctionIdFromLink(String link) { + Map<String, String> map = new HashMap<>(); + map.put("method", "taobao.tbk.item.click.extract"); + map.put("click_url", link + ""); + JSONObject resultJSON = null; + try { + resultJSON = TaoKeBaseUtil.baseRequest(map, true); + } catch (TaoKeApiException e) { + e.printStackTrace(); + } + if (resultJSON == null) + return null; + + return null; + + } + + /** + * 娓犻亾閭�璇风爜 + * + * @param relationId + * @return + */ + public static String getInviteCode(Long relationId, String accessToken) { + Map<String, String> map = new HashMap<>(); + map.put("method", "taobao.tbk.sc.invitecode.get"); + map.put("session", accessToken); + map.put("relation_id", relationId + ""); + map.put("code_type", "2"); + map.put("relation_app", "杩斿埄鍒�"); + JSONObject resultJSON = null; + try { + TaoKeAppInfo app=new TaoKeAppInfo(); + app.setAppKey("24567001"); + app.setAppSecret("e26a8d0f8726883d44bf04742829b533"); + app.setAdzoneId("123123"); + resultJSON = TaoKeBaseUtil.baseRequest(map, app); + } catch (TaoKeApiException e) { + e.printStackTrace(); + } + if (resultJSON == null) + return null; + + return null; + + } + private static TaoBaoGoodsBrief parseWuLiaoItemFromMaterialId(JSONObject item) { TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); // 璁剧疆鎴�320*320鐨勫浘鐗囧昂瀵� -- Gitblit v1.8.0