From 0ddd2ceac4f4f818d86b8f900df0c708e7b2f77d Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 16 七月 2019 16:09:30 +0800
Subject: [PATCH] 优化

---
 fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 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 ea8ce84..f5e9516 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
@@ -13,6 +13,7 @@
 import org.yeshi.utils.HttpUtil;
 
 import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
 import com.google.gson.reflect.TypeToken;
 import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
 import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
@@ -80,18 +81,30 @@
 			map.put("sort_type", sf.getSortType() + "");
 		if (sf.getHasCoupon() != null)
 			map.put("with_coupon", sf.getHasCoupon() + "");
+		if (sf.getIsBrand() != null)
+			map.put("is_brand_goods", sf.getIsBrand() + "");
 		if (sf.getCatId() != null)
 			map.put("cat_id", sf.getCatId() + "");
 		if (sf.getKw() != null)
 			map.put("keyword", sf.getKw());
 		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");
 		Type type = new TypeToken<List<PDDGoodsDetail>>() {
 		}.getType();
-		List<PDDGoodsDetail> goodsList = new Gson().fromJson(array.toString(), type);
+		
+		Gson gson = new GsonBuilder().disableHtmlEscaping().create();
+		List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
 		int totalCount = json.optInt("total_count");
 		return new PDDGoodsResult(totalCount, goodsList);
 	}

--
Gitblit v1.8.0