From de10879ac00f9c94dc02cada9a8a6117a8d81caf Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期五, 19 七月 2019 15:40:01 +0800
Subject: [PATCH] 拼多多 京东分享模板兼容

---
 fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 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..3579529 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
@@ -90,13 +90,6 @@
 		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");
 		JSONArray array = root.optJSONArray("goods_list");
@@ -205,5 +198,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