yujian
2019-12-12 8c04d27e5cebb7e654c208533e9567c4df2c8acc
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -1844,6 +1844,12 @@
      return url;
   }
   /**
    * 获取淘宝的商品详情
    *
    * @param actionId
    * @return
    */
   public static TaoBaoGoodsBrief getSimpleGoodsBrief(Long actionId) {
      JSONObject data = new JSONObject();
      data.put("itemNumId", actionId + "");
@@ -1855,6 +1861,7 @@
      } catch (UnsupportedEncodingException e) {
         e.printStackTrace();
      }
      HttpClient client = new HttpClient();
      GetMethod gm = new GetMethod(url);
      String result = null;
@@ -1879,25 +1886,30 @@
      JSONObject resultOBJ = JSONObject.fromObject(result);
      if (resultOBJ.optJSONObject("data") != null) {
         data = resultOBJ.optJSONObject("data");
         JSONObject item = data.optJSONObject("item");
         JSONObject seller = data.optJSONObject("seller");
         TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
         goods.setTitle(item.optString("title"));
         goods.setAuctionId(item.optLong("itemId"));
         goods.setTitle(item.optString("title"));
         if (item.optJSONArray("images") != null && item.optJSONArray("images").size() > 0) {
            String picture = item.optJSONArray("images").optString(0);
            goods.setPictUrl(picture.startsWith("http") ? picture : "https:" + picture);
         if (data != null) {
            JSONObject item = data.optJSONObject("item");
            if (item != null) {
               JSONObject seller = data.optJSONObject("seller");
               TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
               goods.setTitle(item.optString("title"));
               goods.setAuctionId(item.optLong("itemId"));
               goods.setTitle(item.optString("title"));
               if (item.optJSONArray("images") != null && item.optJSONArray("images").size() > 0) {
                  String picture = item.optJSONArray("images").optString(0);
                  goods.setPictUrl(picture.startsWith("http") ? picture : "https:" + picture);
               }
               if (seller != null) {
                  goods.setSellerId(seller.optLong("shopId"));
                  String shopType = seller.optString("shopType");
                  if ("B".equalsIgnoreCase(shopType)) {
                     goods.setUserType(1);
                  } else
                     goods.setUserType(0);
                  goods.setShopTitle(seller.optString("shopName"));
               }
               return goods;
            }
         }
         goods.setSellerId(seller.optLong("shopId"));
         String shopType = seller.optString("shopType");
         if ("B".equalsIgnoreCase(shopType)) {
            goods.setUserType(1);
         } else
            goods.setUserType(0);
         goods.setShopTitle(seller.optString("shopName"));
         return goods;
      }
      return null;
   }