yujian
2020-06-08 b3da9f82b7740d39742fef1a81a56c22fe1c8b9c
fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java
@@ -17,6 +17,7 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
import com.yeshi.fanli.dto.suning.SuningGoodsInfoRecommend;
import com.yeshi.fanli.dto.suning.SuningOrderQueryResultDTO;
import com.yeshi.fanli.dto.suning.SuningQueryModel;
import com.yeshi.fanli.entity.suning.SuningOrderInfo;
@@ -121,6 +122,7 @@
      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));
      JSONObject resultJSON = JSONObject.fromObject(result);
      JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
@@ -135,6 +137,39 @@
      return null;
   }
   /**
    * 查询商品
    * @Title: searchGoods
    * @Description:
    * @param model
    * @return
    * List<SuningGoodsInfo> 返回类型
    * @throws
    */
   public static List<SuningGoodsInfo> searchGoodsOld(SuningQueryModel model) {
      model.setPicWidth(320);
      model.setPicHeight(320);
      String key = "querySearchcommodity";
      String json = new Gson().toJson(model);
      String result = baseRequest("suning.netalliance.searchcommodity.query", key, JSONObject.fromObject(json));
      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) {
               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);
@@ -152,6 +187,39 @@
      }
      return null;
   }
   /**
    * 查询关联商品
    * @Title: searchGoods
    * @Description:
    * @param model
    * @return
    * List<SuningGoodsInfo> 返回类型
    * @throws
    */
   public static List<SuningGoodsInfoRecommend> getRecommendGoods(String goodsCode, String supplierCode) {
      JSONObject model = new JSONObject();
      model.put("commodityCode", goodsCode);
      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));
      JSONObject resultJSON = JSONObject.fromObject(result);
      JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONObject(key)
            .optJSONArray("commodityList");
      if (array != null) {
         Type type = new TypeToken<ArrayList<SuningGoodsInfoRecommend>>() {
         }.getType();
         List<SuningGoodsInfoRecommend> goodsList = new Gson().fromJson(array.toString(), type);
         return goodsList;
      }
      return null;
   }
   public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) {
      String sts = "";