yujian
2020-06-29 ec60e757d358636dcac1589c44a66f3e276fe58c
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -266,10 +266,10 @@
    */
   public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids) throws TaobaoGoodsDownException {
      List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.tbk.item.info.get");
      map.put("num_iids", ids + "");
      String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
      JSONObject data = JSONObject.fromObject(resultStr);
      // 商品下架
@@ -292,6 +292,63 @@
      }
      return goodsList;
   }
   public static List<TaoBaoGoodsBrief> getBatchGoodsInfo(List<Long> listId, String ip )
         throws TaoKeApiException, TaobaoGoodsDownException {
      if (listId == null || listId.size() == 0) {
         throw new TaobaoGoodsDownException(1, "淘宝商品ID不能为空");
      }
      if (listId.size() > 40) {
         throw new TaobaoGoodsDownException(1, "淘宝商品ID不能超过40个");
      }
      StringBuffer ids = new StringBuffer();
      for (Long id : listId) {
         ids.append(id + ",");
      }
      return getBatchGoodsInfos(ids.substring(0, ids.length() - 1), ip);
   }
   /**
    * 获取商品详情,简版
    *
    * @param id
    * @return
    */
   public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids, String ip) throws TaobaoGoodsDownException {
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.tbk.item.info.get");
      map.put("num_iids", ids + "");
      if (!StringUtil.isNullOrEmpty(ip)) {
         map.put("ip", ip);
      }
      String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
      JSONObject data = JSONObject.fromObject(resultStr);
      // 商品下架
      if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 15
            && data.optJSONObject("error_response").optInt("sub_code") == 50001) {
         throw new TaobaoGoodsDownException(data.optJSONObject("error_response").optInt("code"), "商品下架");
      }
      if (data.optJSONObject("tbk_item_info_get_response") == null)
         return null;
      List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
      JSONArray array = data.optJSONObject("tbk_item_info_get_response").optJSONObject("results")
            .optJSONArray("n_tbk_item");
      if (array != null && array.size() > 0) {
         for (int i = 0; i < array.size(); i++) {
            JSONObject item = array.optJSONObject(i);
            goodsList.add(parseSimpleGoodsInfo(item));
         }
      }
      return goodsList;
   }
   /**
    * 搜索商品详情-详细