admin
2021-01-27 e1a62ec62e7331d97af9302e90e1ce44af8235eb
fanli/src/main/java/com/yeshi/fanli/util/suning/SuningApiUtil.java
@@ -22,7 +22,7 @@
import com.yeshi.fanli.dto.suning.SuningQueryModel;
import com.yeshi.fanli.entity.suning.SuningOrderInfo;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import org.yeshi.utils.TimeUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -34,6 +34,7 @@
   public final static String PID_SHARE = "666527";
   public final static String PID_BUY = "666526";
   public final static String PID_COUPON = "666528";
   private static String post(String url, String entity, Map<String, String> headers) {
      String charset = "utf-8";
@@ -122,7 +123,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 +140,6 @@
      return null;
   }
   /**
    * 查询商品
    * @Title: searchGoods
@@ -156,23 +158,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);
@@ -181,14 +183,19 @@
      String result = baseRequest("suning.netalliance.commoditydetail.query", key, model);
      System.out.println(result);
      JSONObject resultJSON = JSONObject.fromObject(result);
      if( resultJSON.optJSONObject("sn_responseContent")==null)
         return null;
      if(resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body")==null)
         return null;
      JSONArray array = resultJSON.optJSONObject("sn_responseContent").optJSONObject("sn_body").optJSONArray(key);
      if (array != null && array.size() > 0) {
         return new Gson().fromJson(array.optJSONObject(0).toString(), SuningGoodsInfo.class);
      }
      return null;
   }
   /**
    * 查询关联商品
    * @Title: searchGoods
@@ -204,7 +211,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 +226,6 @@
      }
      return null;
   }
   public static List<SuningGoodsInfo> getGoodsDetailList(List<String> list) {
      String sts = "";
@@ -280,7 +286,7 @@
    * @param startTime
    * @param endTime
    * @param page
    * @param orderLineStatus
    * @param orderLineStatus  (0:全部状态;1:等待付款;2:支付完成;3:退款;4:订单已取消;5:确认收货)
    * @return 
    * SuningOrderQueryResultDTO 返回类型
    * @throws
@@ -297,7 +303,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>>() {