From a39422f2a8ce45dd6cf65701ed5f9e65391c46c1 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 23 七月 2019 11:03:35 +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/pinduoduo/PinDuoDuoApiUtil.java |   43 ++++++++++++++++++++++++++++++++-----------
 1 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
index f5e9516..64f2852 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -63,9 +63,7 @@
 		}
 		if (url.endsWith("&"))
 			url = url.substring(0, url.length() - 1);
-
-		String result = HttpUtil.post(url);
-		return result;
+		return HttpUtil.postSimple(url);
 	}
 
 	public static PDDGoodsResult searchGoods(PDDSearchFilter sf) {
@@ -87,15 +85,12 @@
 			map.put("cat_id", sf.getCatId() + "");
 		if (sf.getKw() != null)
 			map.put("keyword", sf.getKw());
+		if (sf.getGoodsIdList() != null)
+			map.put("goods_id_list", sf.getGoodsIdList().toString());
+		
+		
 		map.put("pid", PID_FANLI);
 		String result = baseRequest(map);
-		
-		try {
-			result = new String(result.getBytes("GBK"),"UTF-8");
-//			result = new String(result.getBytes("GBK"),"ISO-8859-1");
-		} catch (UnsupportedEncodingException e) {
-			e.printStackTrace();
-		}
 		
 		JSONObject json = JSONObject.fromObject(result);
 		JSONObject root = json.optJSONObject("goods_search_response");
@@ -105,7 +100,7 @@
 		
 		Gson gson = new GsonBuilder().disableHtmlEscaping().create();
 		List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
-		int totalCount = json.optInt("total_count");
+		int totalCount = root.optInt("total_count");
 		return new PDDGoodsResult(totalCount, goodsList);
 	}
 
@@ -205,5 +200,31 @@
 			return goodsList.get(0);
 		return null;
 	}
+	
+	
+	/**
+	 * 鑾峰彇鍟嗗搧璇︽儏
+	 * 
+	 * @param goodsId
+	 */
+	public static String createGenerate(Long goodsId) {
+		JSONArray array = new JSONArray();
+		array.add(goodsId);
+		Map<String, String> map = new HashMap<>();
+		map.put("type", "pdd.ddk.phrase.generate");
+		map.put("goods_id_list", array.toString());
+		map.put("p_id", PID_FANLI);
+		String result = baseRequest(map);
+		JSONObject resultJson = JSONObject.fromObject(result);
+		System.out.println(result);
+		JSONObject root = resultJson.optJSONObject("ddk_phrase_generate_response");
+		if (root != null) {
+			array = root.optJSONArray("promotion_phrase_list");
+			JSONObject phraseObject = JSONObject.fromObject( array.get(0));
+			return phraseObject.optString("phrase");
+		}
+		
+		return null;
+	}
 
 }

--
Gitblit v1.8.0