Esempio n. 1
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;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 /**
  * 得到反馈信息列表
  *
  * @param xml
  * @return
  * @throws DocumentException
  */
 public static List<TradingFeedBackDetail> getFeedBackListElement(String xml) throws Exception {
   List<TradingFeedBackDetail> lifb = new ArrayList();
   Document document = formatStr2Doc(xml);
   Element rootElt = document.getRootElement();
   Element recommend = rootElt.element("FeedbackDetailArray");
   Iterator<Element> iter = recommend.elementIterator("FeedbackDetail");
   while (iter.hasNext()) {
     Element element = iter.next();
     TradingFeedBackDetail tfbd = new TradingFeedBackDetail();
     tfbd.setCommentinguser(element.elementText("CommentingUser"));
     tfbd.setCommentinguserscore(Long.parseLong(element.elementText("CommentingUserScore")));
     tfbd.setCommenttext(
         StringEscapeUtils.escapeXml(element.element("CommentText").getStringValue()));
     tfbd.setCommenttime(DateUtils.returnDate(element.elementText("CommentTime")));
     tfbd.setCommenttype(element.elementText("CommentType"));
     tfbd.setItemid(element.elementText("ItemID"));
     tfbd.setRole(element.elementText("Role"));
     tfbd.setFeedbackid(element.elementText("FeedbackID"));
     tfbd.setTransactionid(element.elementText("TransactionID"));
     tfbd.setOrderlineitemid(element.elementText("OrderLineItemID"));
     tfbd.setItemtitle(element.elementText("ItemTitle"));
     tfbd.setCreateTime(new Date());
     if (element.elementText("ItemPrice") != null) {
       tfbd.setItemprice(Double.parseDouble(element.elementText("ItemPrice")));
     }
     lifb.add(tfbd);
   }
   return lifb;
 }
Esempio n. 4
0
  /**
   * 定时从在线商品中同步数据下来,行成在线数据
   *
   * @param xml
   * @return
   * @throws DocumentException
   */
  public static List<TradingListingData> getItemListElememt(String xml, String ebayAccount)
      throws Exception {
    List li = new ArrayList();
    Document document = formatStr2Doc(xml);
    Element rootElt = document.getRootElement();
    Element recommend = rootElt.element("ItemArray");
    Iterator<Element> iter = recommend.elementIterator("Item");
    String listType = "";
    while (iter.hasNext()) {
      TradingListingData item = new TradingListingData();
      Element element = iter.next();
      item.setTitle(StringEscapeUtils.escapeXml(element.elementText("Title")));
      item.setItemId(element.elementText("ItemID"));
      item.setSite(element.elementText("Site"));
      item.setSku(element.elementText("SKU"));
      item.setEbayAccount(ebayAccount);
      if ("FixedPriceItem".equals(element.elementText("ListingType"))) {
        if (element.element("Variations") != null) {
          listType = "2";
        } else {
          listType = element.elementText("ListingType");
        }
      } else {
        listType = element.elementText("ListingType");
      }
      item.setListingType(listType);
      item.setPrice(
          Double.parseDouble(element.element("SellingStatus").elementText("CurrentPrice")));
      Element shippingdes = element.element("ShippingDetails");
      if (shippingdes != null) {
        List<Element> shippingit = shippingdes.elements("ShippingServiceOptions");
        Element shippingOption = shippingit.get(0);
        if (shippingOption != null) {
          Element option = shippingOption.element("ShippingServiceCost");
          if (option != null) {
            item.setShippingPrice(Double.parseDouble(option.getText()));
          } else {
            item.setShippingPrice(0.00);
          }
        } else {
          item.setShippingPrice(0.00);
        }
      } else {
        item.setShippingPrice(0.00);
      }
      item.setQuantity(
          Long.parseLong(element.elementText("Quantity"))
              - Long.parseLong(element.element("SellingStatus").elementText("QuantitySold")));
      item.setQuantitysold(
          Long.parseLong(element.element("SellingStatus").elementText("QuantitySold")));
      Element elflag = element.element("SellingStatus").element("ListingStatus");
      if (elflag != null) {
        if (elflag.getText().equals("Active")) {
          item.setIsFlag("0");
        } else {
          item.setIsFlag("1");
        }
      } else {
        item.setIsFlag("1");
      }
      item.setSubtitle("");
      item.setBuyitnowprice(
          Double.parseDouble(
              element.element("ListingDetails").elementText("ConvertedBuyItNowPrice")));
      item.setReserveprice(
          Double.parseDouble(
              element.element("ListingDetails").elementText("ConvertedReservePrice")));
      item.setListingduration(element.elementText("ListingDuration"));
      item.setStarttime(
          DateUtils.returnDate(element.element("ListingDetails").elementText("StartTime")));
      item.setEndtime(
          DateUtils.returnDate(element.element("ListingDetails").elementText("EndTime")));
      String url = element.element("PictureDetails").elementText("GalleryURL");

      // item.setPicUrl(url.substring(0,url.lastIndexOf("_")+1)+"14"+url.substring(url.lastIndexOf(".")));
      item.setPicUrl("http://thumbs.ebaystatic.com/pict/" + item.getItemId() + ".jpg");
      li.add(item);
    }
    return li;
  }