From 3ac30b4c17cf071ce9c66a59c069ab83efae6d2d Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 14 十月 2019 17:44:13 +0800
Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div

---
 fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java |   93 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 87 insertions(+), 6 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 f881d10..de75049 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
@@ -15,6 +15,7 @@
 import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport;
 import com.yeshi.fanli.entity.taobao.RelateGoods;
 import com.yeshi.fanli.entity.taobao.SearchFilter;
+import com.yeshi.fanli.entity.taobao.SearchShopFilter;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoHead;
 import com.yeshi.fanli.entity.taobao.TaoBaoProvince;
@@ -126,7 +127,7 @@
 		map.put("method", "taobao.tbk.item.info.get");
 		map.put("num_iids", id + "");
 		String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
-		// System.out.println(resultStr);
+		System.out.println(resultStr);
 		JSONObject data = JSONObject.fromObject(resultStr);
 		// 鍟嗗搧涓嬫灦
 		if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 15
@@ -189,9 +190,15 @@
 			if (item.optBoolean("free_shipment"))
 				goods.setFreeShipment(1);
 
-			if (!StringUtil.isNullOrEmpty(item.optString("material_lib_type")))
-				goods.setMaterialLibType(item.optInt("material_lib_type"));
-			else
+			if (!StringUtil.isNullOrEmpty(item.optString("material_lib_type"))) {
+				try {
+					String materialLibType = item.optString("material_lib_type");
+					goods.setMaterialLibType(Integer.parseInt(materialLibType.split(",")[0]));
+				} catch (Exception e) {
+					goods.setMaterialLibType(0);
+				}
+
+			} else
 				goods.setMaterialLibType(0);
 
 			return goods;
@@ -341,6 +348,7 @@
 					g.setId(goods.getAuctionId());
 					g.setCreatetime(new Date());
 					g.setMaterialLibType(goods.getMaterialLibType());
+					g.setProvcity(goods.getProvcity());
 					return g;
 				}
 			}
@@ -409,6 +417,7 @@
 					}
 					g.setCreatetime(new Date());
 					g.setMaterialLibType(goods.getMaterialLibType());
+					g.setProvcity(goods.getProvcity());
 					return g;
 				}
 			}
@@ -910,6 +919,7 @@
 		goods.setSellerId(item.optLong("seller_id"));
 		goods.setShopTitle(item.optString("shop_title"));
 		goods.setTitle(item.optString("title"));
+		goods.setProvcity(item.optString("provcity"));
 
 		if (!StringUtil.isNullOrEmpty(item.optString("level_one_category_id"))) {
 			goods.setRootCatId(item.optInt("level_one_category_id"));
@@ -1243,6 +1253,54 @@
 	}
 
 	/**
+	 * 搴楅摵鎼滅储
+	 * 
+	 * @param key
+	 *            -搴楅摵鍚嶇О
+	 * @param page
+	 *            -椤电爜
+	 * @return
+	 */
+	public static List<TaoBaoShopInfo> searchShop(SearchShopFilter filter) {
+		if (StringUtil.isNullOrEmpty(filter.getKey()))
+			return new ArrayList<>();
+		List<TaoBaoShopInfo> list = new ArrayList<>();
+		Map<String, String> map = new HashMap<>();
+		map.put("method", "taobao.tbk.shop.get");
+		map.put("fields", "user_id,shop_title,shop_type,seller_nick,pict_url,shop_url");
+		map.put("q", filter.getKey());
+		map.put("page_size", filter.getPageSize() + "");
+		map.put("page_no", filter.getPage() + "");
+
+		if (!StringUtil.isNullOrEmpty(filter.getSort()))
+			map.put("sort", filter.getSort());
+
+		if (filter.getTmall() != null)
+			map.put("is_tmall", filter.getTmall() + "");
+
+		String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
+		JSONObject resultDate = JSONObject.fromObject(resultStr);
+		if (resultDate.optJSONObject("tbk_shop_get_response") != null
+				&& resultDate.optJSONObject("tbk_shop_get_response").optJSONObject("results") != null) {
+			JSONArray array = resultDate.optJSONObject("tbk_shop_get_response").optJSONObject("results")
+					.optJSONArray("n_tbk_shop");
+			if (array != null)
+				for (int i = 0; i < array.size(); i++) {
+					JSONObject item = array.optJSONObject(i);
+					TaoBaoShopInfo info = new TaoBaoShopInfo();
+					info.setPictureUrl(item.optString("pict_url"));
+					info.setSellerNick(item.optString("seller_nick"));
+					info.setShopTitle(item.optString("shop_title"));
+					info.setShopType(item.optString("shop_type"));
+					info.setShopUrl(item.optString("shop_url"));
+					info.setUserId(item.optLong("user_id"));
+					list.add(info);
+				}
+		}
+		return list;
+	}
+
+	/**
 	 * 鍝佺墝鍒歌幏鍙�
 	 * 
 	 * @param pageNo
@@ -1447,9 +1505,13 @@
 		Map<String, String> map = new HashMap<>();
 		map.put("method", "taobao.tbk.item.click.extract");
 		map.put("click_url", link + "");
+
+		TaoKeAppInfo app = new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
+				TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
 		JSONObject resultJSON = null;
 		try {
-			resultJSON = TaoKeBaseUtil.baseRequest(map, true);
+			resultJSON = TaoKeBaseUtil.baseRequest(map, app);
+			System.out.println(resultJSON);
 		} catch (TaoKeApiException e) {
 			e.printStackTrace();
 		}
@@ -1779,6 +1841,7 @@
 		goods.setSellerId(item.optLong("seller_id"));
 		goods.setShopTitle(item.optString("shop_title"));
 		goods.setTitle(item.optString("title"));
+		goods.setProvcity(item.optString("provcity"));
 
 		if (!StringUtil.isNullOrEmpty(item.optString("level_one_category_id"))) {
 			goods.setRootCatId(item.optInt("level_one_category_id"));
@@ -1905,7 +1968,7 @@
 	// 娣樼ぜ閲戝垱寤�
 	public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum,
 			Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app)
-			throws TaoLiJinCreateException,TaoKeApiException {
+			throws TaoLiJinCreateException, TaoKeApiException {
 		Map<String, String> map = new HashMap<>();
 		map.put("method", "taobao.tbk.dg.vegas.tlj.create");
 		map.put("adzone_id", app.getPid().split("_")[3]);
@@ -2026,6 +2089,24 @@
 			e.printStackTrace();
 		}
 	}
+
+	/**
+	 * 鑾峰彇娣樺疂绯荤粺鏃堕棿
+	 * 
+	 * @return
+	 */
+	public static Date getTaoBaoSystemTime() {
+		Map<String, String> map = new HashMap<>();
+		map.put("method", "taobao.time.get");
+		try {
+			JSONObject json = TaoKeBaseUtil.baseRequest(map, false);
+			String time = json.optJSONObject("time_get_response").optString("time");
+			return new Date(TimeUtil.convertToTimeTemp(time, "yyyy-MM-dd HH:mm:ss"));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
 }
 
 class QuanInfo {

--
Gitblit v1.8.0