From e97b71caed03d1f1aa3ae21b1ea0deac4dd9ffe0 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期五, 16 八月 2019 14:28:38 +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/jd/JDApiUtil.java |   80 +++++++++++----------------------------
 1 files changed, 23 insertions(+), 57 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
index a1042a3..294a3b6 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -37,44 +37,19 @@
 import net.sf.json.JSONObject;
 
 public class JDApiUtil {
-	public static String APP_ID = "1774659094";
-	public static String APP_KEY = "7ba8e06b7d6fde3d6bd5db4b0026ecd7";
-	public static String SECRET_KEY = "fb49bc6ecac5458ba5394fc2969d7c56";
+	public static String APP_ID = "1864778416";
+	public static String APP_KEY = "388f5133d13a5ea290aa5c44f3ebcc00";
+	public static String SECRET_KEY = "e22367fc866746d98b50d47b4c521781";
 	private static String SERVER_URL = "https://router.jd.com/api";
 
-	public static long POSITION_FANLI = 1834339426L;
-	public static long POSITION_SHARE = 1834289924L;
-	public static long POSITION_COUPON = 1859510742L;
+	public static long POSITION_FANLI = 1869704794L;
+	public static long POSITION_SHARE = 1869542990L;
+	public static long POSITION_COUPON = 1869704796L;
 
 	// 璁㈠崟鏌ヨ绫诲瀷
 	public static int ORDER_TYPE_CREATETIME = 1;// 涓嬪崟鏃堕棿
 	public static int ORDER_TYPE_FINISHTIME = 2;// 瀹屾垚鏃堕棿
 	public static int ORDER_TYPE_UPDATETIME = 3;// 鏇存柊鏃堕棿
-
-	private static String post(String url, Map<String, String> params) {
-		String baseUrl = url;
-		List<String> paramsList = new ArrayList<>();
-		if (params != null)
-			for (Iterator<String> its = params.keySet().iterator(); its.hasNext();) {
-				String key = its.next();
-				try {
-					paramsList.add(key + "=" + URLEncoder.encode(params.get(key), "UTF-8"));
-				} catch (UnsupportedEncodingException e) {
-					e.printStackTrace();
-				}
-			}
-		baseUrl += "?" + StringUtil.concat(paramsList, "&");
-		HttpClient client = new HttpClient();
-		PostMethod pm = new PostMethod(baseUrl);
-		try {
-			client.executeMethod(pm);
-			String result = pm.getResponseBodyAsString();
-			return new String(result.getBytes("ISO-8859-1"), "UTF-8");
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
 
 	private static String post2(String url, Map<String, String> params) {
 		String baseUrl = url;
@@ -116,22 +91,6 @@
 		return StringUtil.Md5(SECRET_KEY + str + SECRET_KEY).toUpperCase();
 	}
 
-	private static String baseRequest(String method, String accessToken, JSONObject params) {
-		Map<String, String> baseMap = new HashMap<String, String>();
-		baseMap.put("param_json", params.toString());
-		baseMap.put("app_key", APP_KEY);
-		baseMap.put("method", method);
-		if (accessToken != null)
-			baseMap.put("access_token", accessToken);
-		baseMap.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
-		baseMap.put("format", "json");
-		baseMap.put("v", "1.0");
-		baseMap.put("sign_method", "md5");
-		baseMap.put("sign", getSign(baseMap));
-		String result = post(SERVER_URL, baseMap);
-		return result;
-	}
-
 	private static String baseRequest2(String method, String accessToken, JSONObject params) {
 		Map<String, String> baseMap = new HashMap<String, String>();
 		baseMap.put("param_json", params.toString());
@@ -168,7 +127,7 @@
 		JSONObject root = new JSONObject();
 		root.put("promotionCodeReq", json);
 
-		String result = baseRequest("jd.union.open.promotion.common.get", null, root);
+		String result = baseRequest2("jd.union.open.promotion.common.get", null, root);
 
 		JSONObject resultJson = JSONObject.fromObject(result);
 		result = resultJson.optJSONObject("jd_union_open_promotion_common_get_response").optString("result");
@@ -211,6 +170,19 @@
 				return list.get(0);
 		}
 		return null;
+	}
+
+	/**
+	 * 閫氳繃鍟嗗搧鎼滅储鎺ュ彛鎵归噺鑾峰彇璇︽儏
+	 * 
+	 * @param skuIds
+	 * @return
+	 */
+	public static List<JDGoods> listGoodsDetail(List<Long> skuIds) {
+		JDFilter filter = new JDFilter();
+		filter.setListId(skuIds);
+		JDSearchResult result = queryByKey(filter);
+		return result.getGoodsList();
 	}
 
 	/**
@@ -463,7 +435,7 @@
 		List<JDGoods> list = new ArrayList<>();
 		JSONObject json = new JSONObject();
 		json.put("skuIds", StringUtil.concat(skuIdList, ","));
-		String result = baseRequest("jd.union.open.goods.promotiongoodsinfo.query", null, json);
+		String result = baseRequest2("jd.union.open.goods.promotiongoodsinfo.query", null, json);
 		JSONObject resultJson = JSONObject.fromObject(result);
 		resultJson = resultJson.optJSONObject("jd_union_open_goods_promotiongoodsinfo_query_response");
 		if (resultJson.optInt("code") == 0) {
@@ -645,18 +617,12 @@
 
 		json.put("orderReq", orderReq);
 		String result = baseRequest2("jd.union.open.order.query", null, json);
-		try {
-			System.out.println(new String(result.getBytes("GBK"), "UTF-8"));
-			System.out.println(new String(result.getBytes("ISO-8859-1"), "UTF-8"));
-		} catch (UnsupportedEncodingException e) {
-			e.printStackTrace();
-		}
-
 		JSONObject root = JSONObject.fromObject(result).optJSONObject("jd_union_open_order_query_response");
 		if (root.optInt("code") == 0) {
 			boolean hasMore = root.optBoolean("hasMore");
 			root = JSONObject.fromObject(root.optString("result"));
-			if (root.optInt("code") == 200) {
+			if (root.optInt("code") == 200 && root.optJSONArray("data") != null) {
+
 				String date = root.optJSONArray("data").toString();
 				Type typeToken = new TypeToken<List<JDOrder>>() {
 				}.getType();

--
Gitblit v1.8.0