// 解析价格跟踪 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; }
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; }
// 指定物品号来跟踪 @RequestMapping("/ajax/saveItemPrice.do") @ResponseBody public void saveItemPrice(HttpServletRequest request) throws Exception { String itemId = request.getParameter("itemId"); if (StringUtils.isNotBlank(itemId)) { // TradingPriceTracking tracking=new TradingPriceTracking(); List<TradingPriceTracking> trackings = iTradingPriceTracking.selectPriceTrackingByItemId(itemId); if (trackings != null && trackings.size() > 0) { AjaxSupport.sendFailText("fail", "物品号已存在"); } else { TradingPriceTracking tracking = new TradingPriceTracking(); tracking.setItemid(itemId); iTradingPriceTracking.savePriceTracking(tracking); AjaxSupport.sendSuccessText("", "保存成功"); } } else { AjaxSupport.sendFailText("fail", "物品号为空"); } }
@RequestMapping("/ajax/savepriceTracking.do") @ResponseBody public void savepriceTracking(HttpServletRequest request) throws Exception { String itemid = request.getParameter("itemid"); String sellerusername = request.getParameter("sellerusername"); String currentprice = request.getParameter("currentprice"); String currencyid = request.getParameter("currencyid"); String title = request.getParameter("title"); String queryTitle = request.getParameter("queryTitle"); String bidcount = request.getParameter("bidcount"); String starttime = request.getParameter("starttime"); String endtime = request.getParameter("endtime"); String shippingServiceCost = request.getParameter("shippingServiceCost"); String shippingCurrencyId = request.getParameter("shippingCurrencyId"); String pictureurl = request.getParameter("pictureurl"); TradingPriceTracking tracking = new TradingPriceTracking(); if (StringUtils.isNotBlank(itemid)) { tracking.setItemid(itemid); } if (StringUtils.isNotBlank(starttime)) { tracking.setStarttime(DateUtils.parseDateTime(starttime)); } if (StringUtils.isNotBlank(endtime)) { tracking.setEndtime(DateUtils.parseDateTime(endtime)); } if (StringUtils.isNotBlank(sellerusername)) { tracking.setSellerusername(sellerusername); } if (StringUtils.isNotBlank(currentprice)) { tracking.setCurrentprice(currentprice); } if (StringUtils.isNotBlank(currencyid)) { tracking.setCurrencyid(currencyid); } if (StringUtils.isNotBlank(title)) { tracking.setTitle(title); } if (StringUtils.isNotBlank(queryTitle)) { tracking.setQuerytitle(queryTitle); } if (StringUtils.isNotBlank(bidcount)) { tracking.setBidcount(bidcount); } if (StringUtils.isNotBlank(shippingServiceCost)) { tracking.setShippingservicecost(shippingServiceCost); } if (StringUtils.isNotBlank(shippingCurrencyId)) { tracking.setShippingcurrencyid(shippingCurrencyId); } if (StringUtils.isNotBlank(pictureurl)) { tracking.setPictureurl(pictureurl); } SessionVO sessionVO = SessionCacheSupport.getSessionVO(); List<TradingPriceTracking> trackings = iTradingPriceTracking.selectPriceTrackingByItemId(itemid); if (trackings != null && trackings.size() > 0) { tracking.setId(trackings.get(0).getId()); } iTradingPriceTracking.savePriceTracking(tracking); Map map = new HashMap(); map.put("message", "保存成功"); map.put("itemid", itemid); AjaxSupport.sendSuccessText("", map); }