예제 #1
0
 // 解析价格跟踪
 public static List<TradingPriceTracking> getPriceTrackingItemByItemId(String res)
     throws Exception {
   List<TradingPriceTracking> priceTrackings = new ArrayList<TradingPriceTracking>();
   Document document = formatStr2Doc(res);
   Element rootElt = document.getRootElement();
   Iterator items = rootElt.elementIterator("Item");
   while (items.hasNext()) {
     TradingPriceTracking priceTracking = new TradingPriceTracking();
     Element item = (Element) items.next();
     priceTracking.setItemid(SamplePaseXml.getSpecifyElementText(item, "ItemID"));
     priceTracking.setTitle(SamplePaseXml.getSpecifyElementText(item, "Title"));
     priceTracking.setCurrentprice(
         SamplePaseXml.getSpecifyElementText(item, "ConvertedCurrentPrice"));
     priceTracking.setBidcount(SamplePaseXml.getSpecifyElementText(item, "BidCount"));
     Element ConvertedCurrentPrice = item.element("ConvertedCurrentPrice");
     String endtime = SamplePaseXml.getSpecifyElementText(item, "EndTime");
     if (StringUtils.isNotBlank(endtime)) {
       priceTracking.setEndtime(DateUtils.returnDate(endtime));
     }
     String currencyId1 = "";
     if (ConvertedCurrentPrice != null) {
       Attribute currencyId = ConvertedCurrentPrice.attribute("currencyId");
       if (currencyId != null) {
         currencyId1 = currencyId.getValue();
       }
     }
     priceTracking.setCurrencyid(currencyId1);
     priceTrackings.add(priceTracking);
   }
   return priceTrackings;
 }
예제 #2
0
 public static List<TradingPriceTracking> getPriceTrackingItem(String res, String title)
     throws Exception {
   List<TradingPriceTracking> list = new ArrayList<TradingPriceTracking>();
   Document document = formatStr2Doc(res);
   Element rootElt = document.getRootElement();
   Element searchResult = rootElt.element("searchResult");
   Iterator items = searchResult.elementIterator("item");
   while (items.hasNext()) {
     TradingPriceTracking priceTracking = new TradingPriceTracking();
     Element item = (Element) items.next();
     priceTracking.setItemid(SamplePaseXml.getSpecifyElementText(item, "itemId"));
     priceTracking.setCategoryid(
         SamplePaseXml.getSpecifyElementText(item, "primaryCategory", "categoryId"));
     priceTracking.setCategoryname(
         SamplePaseXml.getSpecifyElementText(item, "primaryCategory", "categoryName"));
     priceTracking.setCurrentprice(
         SamplePaseXml.getSpecifyElementText(item, "sellingStatus", "currentPrice"));
     priceTracking.setSellerusername(
         SamplePaseXml.getSpecifyElementText(item, "sellerInfo", "sellerUserName"));
     priceTracking.setTitle(SamplePaseXml.getSpecifyElementText(item, "title"));
     priceTracking.setBidcount(
         SamplePaseXml.getSpecifyElementText(item, "sellingStatus", "bidCount"));
     priceTracking.setPictureurl(SamplePaseXml.getSpecifyElementText(item, "galleryURL"));
     String starttime = SamplePaseXml.getSpecifyElementText(item, "listingInfo", "startTime");
     String endtime = SamplePaseXml.getSpecifyElementText(item, "listingInfo", "endTime");
     if (StringUtils.isNotBlank(starttime)) {
       priceTracking.setStarttime(DateUtils.returnDate(starttime));
     }
     if (StringUtils.isNotBlank(endtime)) {
       priceTracking.setEndtime(DateUtils.returnDate(endtime));
     }
     Element sellingStatus = item.element("sellingStatus");
     String currencyId1 = "";
     if (sellingStatus != null) {
       Element currentPrice = sellingStatus.element("currentPrice");
       if (currentPrice != null) {
         Attribute currencyId = currentPrice.attribute("currencyId");
         if (currencyId != null) {
           currencyId1 = currencyId.getValue();
         }
       }
     }
     priceTracking.setCurrencyid(currencyId1);
     Element shippingInfo = item.element("shippingInfo");
     if (shippingInfo != null) {
       Element shippingServiceCost = shippingInfo.element("shippingServiceCost");
       if (shippingServiceCost != null) {
         Attribute shippingcurrencyId = shippingServiceCost.attribute("currencyId");
         if (shippingcurrencyId != null) {
           priceTracking.setShippingcurrencyid(shippingcurrencyId.getValue());
         }
         priceTracking.setShippingservicecost(shippingServiceCost.getTextTrim());
       }
     }
     priceTracking.setQuerytitle(title);
     list.add(priceTracking);
   }
   return list;
 }