@RequestMapping(value = "/dflights/cityLowPrice", method = { RequestMethod.GET }, headers = "Accept=application/json")
 public CommResponse searchCityLowPrice(
   @RequestParam(value = "depCity", required = true) String depCity,
   @RequestParam(value = "qDays", defaultValue = "30") int qDays,
   @RequestParam(value = "qLines", defaultValue = "10") int qLines,
   @RequestParam(value = "daysPerLine", defaultValue = "1") int daysPerLine) {

  CommResponse ret;

  List<LowPriceContent> list;
  try {
   this.verify(depCity, qDays, qLines, daysPerLine);

   list = lowPriceService.getCityLowPrice(depCity, qDays, qLines,
     daysPerLine);
   List<LowPriceODT> lowPrices = new ArrayList<LowPriceODT>();

   for (LowPriceContent lowPriceContent : list) {
    LowPriceODT odt = new LowPriceODT();

    odt.setCfcsdm(lowPriceContent.getDepartCity());
    String searchItem = baseInfoService
      .getAviationCityNameByCode(lowPriceContent
        .getDepartCity());
    if (searchItem != null) {
     odt.setCfcs(searchItem);
    }

    odt.setDdcsdm(lowPriceContent.getArrivelCity());
    searchItem = baseInfoService
      .getAviationCityNameByCode(lowPriceContent
        .getArrivelCity());
    if (searchItem != null) {
     odt.setDdcs(searchItem);
    }

    odt.setCfrq(lowPriceContent.getDate());
    odt.setGj(CurrencyUtil.convertFen2YuanText(lowPriceContent
      .getPrice()));
    odt.setZk(lowPriceContent.getDiscountRate());
    lowPrices.add(odt);
   }
   CommResponseWithArray<LowPriceODT> response = new CommResponseWithArray<LowPriceODT>();
   response.setIsSuccess("Y");
   response.setFailReason("");
   response.setData(lowPrices);
   ret = response;

  } catch (ServiceException e) {
   ret = new CommResponse();
   ret.setIsSuccess("N");
   ret.setFailReason(e.getMsg());
  }
  return ret;
 }

 

posted on 2015-06-04 17:27  iduojia  阅读(407)  评论(0编辑  收藏  举报