@RequestMapping("/ajax/addCompetitorsInformation.do")
 @ResponseBody
 public void addCompetitorsInformation(CommonParmVO commonParmVO, HttpServletRequest request)
     throws Exception {
   String id = request.getParameter("itemid");
   if (StringUtils.isNotBlank(id)) {
     TradingListingData data = iTradingListingData.selectById(Long.valueOf(id));
     String sku = data.getSku();
     TradingPriceTrackingAutoPricing autoPricing =
         iTradingPriceTrackingAutoPricing.selectPriceTrackingAutoPricingByListingDateId(
             Long.valueOf(id));
     if (autoPricing != null) {
       List<TradingPriceTrackingPricingRule> rules =
           iTradingPriceTrackingPricingRule.selectTradingPriceTrackingPricingRuleByAutoPricingId(
               autoPricing.getId());
       List<Map> list = new ArrayList<Map>();
       Map map = new HashMap();
       if (rules.get(0).getRuletype().contains("price")) {
         map.put("price", rules.get(0));
       }
       if (rules.get(0).getRuletype().contains("rank")) {
         map.put("rank", rules.get(0));
       }
       map.put("rules", rules);
       list.add(map);
       AjaxSupport.sendSuccessText("", list);
     } else {
       AjaxSupport.sendFailText("fail", "无自动调价");
     }
   } else {
     AjaxSupport.sendFailText("fail", "SKU为空");
   }
 }
 // 调价
 @RequestMapping("/ajax/saveAutoPriceListingDate.do")
 @ResponseBody
 public void saveAutoPriceListingDate(CommonParmVO commonParmVO, HttpServletRequest request)
     throws Exception {
   String itemIds = request.getParameter("itemIds");
   String id = request.getParameter("itemId");
   String competitorPrice = request.getParameter("competitorPrice");
   String competitorPriceAdd = request.getParameter("competitorPriceAdd");
   String competitorPriceInput = request.getParameter("competitorPriceInput");
   String competitorPriceSymbol = request.getParameter("competitorPriceSymbol");
   if (StringUtils.isNotBlank(id)) {
     TradingListingData data = iTradingListingData.selectById(Long.valueOf(id));
     String sku = data.getSku();
     if ("0".equals(competitorPrice)) {
       AjaxSupport.sendFailText("fail", "请先添加规则");
       return;
     }
     if (!StringUtils.isNotBlank(itemIds)) {
       AjaxSupport.sendFailText("fail", "请添加竞争对手");
       return;
     }
     TradingPriceTrackingAutoPricing pricing =
         iTradingPriceTrackingAutoPricing.selectPriceTrackingAutoPricingByListingDateId(
             Long.valueOf(id));
     TradingPriceTrackingAutoPricing autoPricing = new TradingPriceTrackingAutoPricing();
     if (pricing != null) {
       autoPricing.setId(pricing.getId());
     }
     autoPricing.setSku(sku);
     autoPricing.setListingdateId(Long.valueOf(id));
     iTradingPriceTrackingAutoPricing.savePriceTrackingAutoPricing(autoPricing);
     List<TradingPriceTrackingPricingRule> rules =
         iTradingPriceTrackingPricingRule.selectTradingPriceTrackingPricingRuleByAutoPricingId(
             autoPricing.getId());
     if (rules != null && rules.size() > 0) {
       for (TradingPriceTrackingPricingRule pricingRule : rules) {
         iTradingPriceTrackingPricingRule.deleteTradingPriceTrackingPricingRule(pricingRule);
       }
     }
     String[] itemids1 = itemIds.split(",");
     for (String itemid : itemids1) {
       TradingPriceTrackingPricingRule rule = new TradingPriceTrackingPricingRule();
       if ("1".equals(competitorPrice)) {
         rule.setRuletype("priceLowerType");
       }
       if ("2".equals(competitorPrice)) {
         rule.setRuletype("priceHigherType");
       }
       rule.setAutopricingId(autoPricing.getId());
       rule.setIncreaseordecrease(competitorPriceAdd);
       rule.setSign(competitorPriceSymbol);
       rule.setInputvalue(competitorPriceInput);
       rule.setCompetitoritemid(itemid);
       iTradingPriceTrackingPricingRule.saveTradingPriceTrackingPricingRule(rule);
     }
     AjaxSupport.sendSuccessText("", "添加成功");
   } else {
     AjaxSupport.sendFailText("fail", "SKU为空,请先输入SKU");
   }
 }
Ejemplo n.º 3
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;
  }