admin
2020-06-03 9129d51874b36943419994937af56c2f73aed1a0
fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java
@@ -140,6 +140,7 @@
      model.put("commodityStr", goodsCode + "-" + supplierCode);
      model.put("picWidth", 600);
      model.put("picHeight", 600);
      model.put("couponMark", 1);
      String key = "queryCommoditydetail";
      String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
@@ -150,6 +151,35 @@
         return new Gson().fromJson(array.optJSONObject(0).toString(), SuningGoodsInfo.class);
      }
      return null;
   }
   public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) {
      String sts = "";
      for (String st : list) {
         sts += st + "_";
      }
      if (sts.endsWith("_"))
         sts = sts.substring(0, sts.length() - 1);
      JSONObject model = new JSONObject();
      model.put("commodityStr", sts);
      model.put("picWidth", 300);
      model.put("picHeight", 300);
      model.put("couponMark", 1);
      List<SuningGoodsInfo> goodsList = new ArrayList<>();
      String key = "queryCommoditydetail";
      String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
      System.out.println(result);
      JSONObject resultJSON = JSONObject.fromObject(result);
      JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
      if (array != null && array.size() > 0) {
         for (int i = 0; i < array.size(); i++) {
            goodsList.add(new Gson().fromJson(array.optJSONObject(i).toString(), SuningGoodsInfo.class));
         }
      }
      return goodsList;
   }
   public static String convertLink(String productUrl, String quanUrl, String pid, String subUser) {
@@ -244,8 +274,43 @@
      String result = baseRequest("suning.netalliance.custompromotionurl.query", key, model);
      JSONObject resultJSON = JSONObject.fromObject(result);
      resultJSON = resultJSON.optJSONObject("sn_responseContent");
      String shortUrl = resultJSON.optJSONObject("sn_body").optJSONObject("queryCustompromotionurl").optString("shortUrl");
      String shortUrl = resultJSON.optJSONObject("sn_body").optJSONObject("queryCustompromotionurl")
            .optString("shortUrl");
      return URLDecoder.decode(shortUrl);
   }
   /**
    * 商品精选接口
    * @Title: getSelectRecommendGoods
    * @Description:
    * @param eliteId
    * @param page
    * @return
    * List<SuningGoodsInfo> 返回类型
    * @throws
    */
   public static List<SuningGoodsInfo> getSelectRecommendGoods(int eliteId, int page) {
      JSONObject model = new JSONObject();
      model.put("eliteId", eliteId);
      model.put("pageIndex", page);
      // model.put("picWidth", 320);
      // model.put("picHeight", 320);
      model.put("size", 10);
      model.put("couponMark", 1);
      String key = "querySelectrecommendcommodity";
      String result = baseRequest("suning.netalliance.selectrecommendcommodity.query", key, model);
      System.out.println(result);
      JSONObject resultJSON = JSONObject.fromObject(result);
      resultJSON = resultJSON.optJSONObject("sn_responseContent");
      JSONArray array = resultJSON.optJSONObject("sn_body").optJSONObject(key).optJSONArray("commodityList");
      if (array != null) {
         Type type = new TypeToken<ArrayList<SuningGoodsInfo>>() {
         }.getType();
         List<SuningGoodsInfo> goodsList = new Gson().fromJson(array.toString(), type);
         return goodsList;
      }
      return null;
   }
}