From cdd852f8e8eff7eb2e8f7c3fceaa955b9fc3f9d3 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期一, 29 七月 2019 10:46:32 +0800 Subject: [PATCH] 订单商品类型处理 --- fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java | 93 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 93 insertions(+), 0 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 01b0b1c..538ab6a 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 @@ -421,6 +421,7 @@ jdPinGouInfo.setTotalCount(pinGouInfoJson.optLong("totalCount")); jdPinGouInfo.setPingouEndTime(pinGouInfoJson.optLong("pingouEndTime")); jdPinGouInfo.setPingouStartTime(pinGouInfoJson.optLong("pingouStartTime")); + goods.setPinGouInfo(jdPinGouInfo); } } @@ -476,6 +477,12 @@ commissionInfo.setCommission(MoneyBigDecimalUtil .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100))); + String isFreeShipping = json.optString("isFreeShipping"); + if (!StringUtil.isNullOrEmpty(isFreeShipping)) { + goods.setIsFreeShipping(Integer.parseInt(isFreeShipping)); + } + + goods.setCommissionInfo(commissionInfo); goods.setCouponInfo(null); goods.setGoodCommentsShare(null); @@ -499,6 +506,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