From db88b87df461820152d68d3d55a28f30c2da83e6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 20 九月 2019 17:54:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java |   76 +++++++++++++++++++++++++++++++++-----
 1 files changed, 66 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 9f6bbe8..da0f5f8 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;
@@ -25,7 +26,9 @@
 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.exception.tlj.TaoLiJinCreateException;
 import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.log.TLJLogHelper;
 import com.yeshi.fanli.log.TaoKeLogHelper;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.MoneyBigDecimalUtil;
@@ -124,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
@@ -187,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;
@@ -1241,6 +1250,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
@@ -1903,7 +1960,7 @@
 	// 娣樼ぜ閲戝垱寤�
 	public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum,
 			Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app)
-			throws 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]);
@@ -1945,21 +2002,20 @@
 				// 鎺ュ彛杩斿洖寮傚父
 				String msgCode = root.optJSONObject("result").optString("msg_code");
 				if (!StringUtil.isNullOrEmpty(msgCode)) {
+					TLJLogHelper.info(auctionId, root.toString());// 娣樼ぜ閲戝紓甯镐俊鎭褰�
 					switch (msgCode) {
 					case "FAIL_BIZ_ITEM_FORBIDDEN":
-						throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_FORBIDDEN, "璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖�");
+						throw new TaoLiJinCreateException(TaoLiJinCreateException.CODE_TLJ_FORBIDDEN, "璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖�");
 					case "FAIL_BIZ_ACCOUNT_UN_PAID":
 					case "PRE_FREEZE_ASSET_ACCOUNT_ERROR":
-						throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_NO_MONEY, "瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻");
+						throw new TaoLiJinCreateException(TaoLiJinCreateException.CODE_TLJ_NO_MONEY, "瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻");
 					default:
-						return null;
+						throw new TaoKeApiException(Integer.parseInt(msgCode), root.toString());
 					}
 				}
 			}
 		} catch (TaoKeApiException e) {
 			throw e;
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
 		}
 
 		return null;

--
Gitblit v1.8.0