From 52bc8ff0de3c7538d1401423c1cba9615c0c2082 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期四, 18 六月 2020 17:22:24 +0800 Subject: [PATCH] 发圈商品来源修改 + 云发单规则调整 --- fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java | 37 ++++++++++++++++++++++--------------- 1 files changed, 22 insertions(+), 15 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java index dcdaf34..6582967 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java @@ -122,7 +122,9 @@ model.setPicHeight(320); String key = "querySearchcommoditynew"; String json = new Gson().toJson(model); - //String result = baseRequest("suning.netalliance.searchcommoditynew.query", key, JSONObject.fromObject(json)); + // String result = + // baseRequest("suning.netalliance.searchcommoditynew.query", key, + // JSONObject.fromObject(json)); String result = baseRequest("suning.netalliance.searchcommoditynew.query", key, JSONObject.fromObject(json)); JSONObject resultJSON = JSONObject.fromObject(result); JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key) @@ -137,7 +139,6 @@ return null; } - /** * 鏌ヨ鍟嗗搧 * @Title: searchGoods @@ -156,23 +157,23 @@ JSONObject resultJSON = JSONObject.fromObject(result); JSONObject responseContent = resultJSON.optJSONObject("sn_responseContent"); if (responseContent != null) { - JSONObject snBody = responseContent.optJSONObject("sn_body"); - if (snBody != null) { - JSONArray array = snBody.optJSONArray(key); - if (array != null) { + JSONObject snBody = responseContent.optJSONObject("sn_body"); + if (snBody != null) { + JSONArray array = snBody.optJSONArray(key); + if (array != null) { Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() { }.getType(); List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type); return goodsList; } - } + } } return null; } - + public static SuningGoodsInfo getGoodsDetail(String goodsCode, String supplierCode) { JSONObject model = new JSONObject(); - model.put("commodityStr", goodsCode + "-" + supplierCode); + model.put("commodityStr", goodsCode + "-" +SuningUtil.getFullSupplierCode( supplierCode)); model.put("picWidth", 600); model.put("picHeight", 600); model.put("couponMark", 1); @@ -187,8 +188,7 @@ } return null; } - - + /** * 鏌ヨ鍏宠仈鍟嗗搧 * @Title: searchGoods @@ -204,7 +204,7 @@ model.put("supplierCode", supplierCode); model.put("picWidth", 320); model.put("picHeight", 320); - + String key = "getMorerecommend"; String json = new Gson().toJson(model); String result = baseRequest("suning.netalliance.morerecommend.get", key, JSONObject.fromObject(json)); @@ -219,7 +219,6 @@ } return null; } - public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) { String sts = ""; @@ -280,7 +279,7 @@ * @param startTime * @param endTime * @param page - * @param orderLineStatus + * @param orderLineStatus 锛�0锛氬叏閮ㄧ姸鎬侊紱1锛氱瓑寰呬粯娆撅紱2锛氭敮浠樺畬鎴愶紱3锛氶��娆撅紱4锛氳鍗曞凡鍙栨秷锛�5锛氱‘璁ゆ敹璐э級 * @return * SuningOrderQueryResultDTO 杩斿洖绫诲瀷 * @throws @@ -297,7 +296,15 @@ String result = baseRequest("suning.netalliance.order.query", key, model); JSONObject resultJSON = JSONObject.fromObject(result); resultJSON = resultJSON.optJSONObject("sn_responseContent"); - JSONArray array = resultJSON.optJSONObject("sn_body").optJSONArray(key); + JSONObject snBody = resultJSON.optJSONObject("sn_body"); + if (snBody == null) + return null; + + JSONArray array = snBody.optJSONArray(key); + + if (array == null) + return null; + Gson gson = new Gson(); Type type = new TypeToken<ArrayList<SuningOrderInfo>>() { -- Gitblit v1.8.0