From 0cc3b905e5945d1b4b02ee5f91a615bcfd8f08d6 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期四, 25 七月 2019 11:44:10 +0800 Subject: [PATCH] 京东兼容 --- fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java | 100 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 95 insertions(+), 5 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 faae43b..dbdaf48 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 @@ -151,19 +151,22 @@ * * @return */ - public static String convertLink(String materialId, String couponUrl, String pid) { + public static String convertLink(String materialId, String couponUrl, String positionId, String ext1) { JSONObject json = new JSONObject(); json.put("materialId", materialId); json.put("siteId", APP_ID); - if (couponUrl != null) + json.put("positionId", positionId); + + if (!StringUtil.isNullOrEmpty(couponUrl)) json.put("couponUrl", couponUrl); - // json.put("ext1", "437032_12"); - json.put("pid", pid); + + if (!StringUtil.isNullOrEmpty(ext1)) + json.put("ext1", ext1); JSONObject root = new JSONObject(); root.put("promotionCodeReq", json); - String result = baseRequest("jd.union.open.promotion.common.get", null, json); + String result = baseRequest("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"); resultJson = JSONObject.fromObject(result); @@ -418,6 +421,7 @@ jdPinGouInfo.setTotalCount(pinGouInfoJson.optLong("totalCount")); jdPinGouInfo.setPingouEndTime(pinGouInfoJson.optLong("pingouEndTime")); jdPinGouInfo.setPingouStartTime(pinGouInfoJson.optLong("pingouStartTime")); + goods.setPinGouInfo(jdPinGouInfo); } } @@ -496,6 +500,92 @@ return goods; } + + + public static JDSearchResult getJingFenGoods(int pageIndex, int eliteId) { + JDSearchResult searchResult = new JDSearchResult(); + List<JDGoods> list = new ArrayList<>(); + JSONObject json = new JSONObject(); + json.put("pageIndex", pageIndex); + json.put("pageSize", 20); + json.put("sortName", "inOrderCount30DaysSku"); + json.put("sort", "desc"); + json.put("eliteId", eliteId); + + JSONObject jsonDTO = new JSONObject(); + jsonDTO.put("goodsReq", json); + + + String result = baseRequest2("jd.union.open.goods.jingfen.query", null, jsonDTO); + System.out.println(result); + JSONObject resultJson = JSONObject.fromObject(result); + resultJson = resultJson.optJSONObject("jd_union_open_goods_jingfen_query_response"); + if (resultJson.optInt("code") == 0) { + result = resultJson.optString("result"); + resultJson = JSONObject.fromObject(result); + String message = resultJson.optString("message"); + if ("SUCCESS".equalsIgnoreCase(message)) { + JSONArray array = resultJson.optJSONArray("data"); + if (array != null) { + for (int i = 0; i < array.size(); i++) { + JDGoods goods = parseJDGoods(array.optJSONObject(i)); + if (goods != null) + list.add(goods); + } + } + } + + long totalCount = resultJson.optLong("totalCount"); + PageEntity pageEntity = new PageEntity(); + pageEntity.setTotalCount(totalCount); + + searchResult.setPageEntity(pageEntity); + } + searchResult.setGoodsList(list); + return searchResult; + } + + + public static JDSearchResult getGoodsClass() { + JDSearchResult searchResult = new JDSearchResult(); + List<JDGoods> list = new ArrayList<>(); + JSONObject json = new JSONObject(); + json.put("parentId", 0); + json.put("grade", 0); + + JSONObject jsonDTO = new JSONObject(); + jsonDTO.put("req", json); + + + String result = baseRequest2("jd.union.open.category.goods.get", null, jsonDTO); + System.out.println(result); + JSONObject resultJson = JSONObject.fromObject(result); + resultJson = resultJson.optJSONObject("jd_union_open_goods_jingfen_query_response"); + if (resultJson.optInt("code") == 0) { + result = resultJson.optString("result"); + resultJson = JSONObject.fromObject(result); + String message = resultJson.optString("message"); + if ("SUCCESS".equalsIgnoreCase(message)) { + JSONArray array = resultJson.optJSONArray("data"); + if (array != null) { + for (int i = 0; i < array.size(); i++) { + JDGoods goods = parseJDGoods(array.optJSONObject(i)); + if (goods != null) + list.add(goods); + } + } + } + + long totalCount = resultJson.optLong("totalCount"); + PageEntity pageEntity = new PageEntity(); + pageEntity.setTotalCount(totalCount); + + searchResult.setPageEntity(pageEntity); + } + searchResult.setGoodsList(list); + return searchResult; + } + public static JDGoods getGoodsDetail(Long skuId) { List<Long> skuIdList = new ArrayList<>(); -- Gitblit v1.8.0