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 | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 50 insertions(+), 5 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 27d076a..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 @@ -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; @@ -62,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) { @@ -80,19 +79,28 @@ 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()); + if (sf.getGoodsIdList() != null) + map.put("goods_id_list", sf.getGoodsIdList().toString()); + + map.put("pid", PID_FANLI); String result = baseRequest(map); + 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); - int totalCount = json.optInt("total_count"); + + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type); + int totalCount = root.optInt("total_count"); return new PDDGoodsResult(totalCount, goodsList); } @@ -138,6 +146,17 @@ System.out.println(result); } + /** + * 鑾峰彇璁㈠崟 + * + * @param page + * -椤电爜 + * @param pageSize-姣忛〉鏁伴噺 + * @param startTime-寮�濮嬫椂闂� + * @param endTime-缁撴潫鏃堕棿 + * 涓庡紑濮嬫椂闂翠笉寰楀ぇ浜�24灏忔椂 + * @return + */ public static PDDOrderResult getOrders(int page, int pageSize, long startTime, long endTime) { Map<String, String> map = new HashMap<>(); map.put("type", "pdd.ddk.order.list.increment.get"); @@ -181,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