Esempio n. 1
0
 /**
  * 修改单个房型日历价格方法
  *
  * @author chivalry
  * @param request
  * @return 2015-10-13
  */
 @SuppressWarnings("rawtypes")
 @PolicyJournal(accessLevel = AccessLevel.PRIVATE)
 @RequestMapping(
     value = "/do_hotelRoomPrice_edit",
     method = {RequestMethod.POST})
 @ResponseBody
 public Response do_hotelRoomPrice_edit(
     HttpServletRequest request,
     String hotelId,
     String roomId,
     String roomPrice,
     String calendarDate) {
   // 返回对象
   Response response = new Response();
   LoginUser user = LoginSessionUtil.getSystemSession(request);
   // 设置客房日历信息并更新数据
   HotelRoomCalendarBo hotelRoomCalendar = new HotelRoomCalendarBo();
   hotelRoomCalendar.setHotelId(hotelId);
   hotelRoomCalendar.setRoomId(roomId);
   hotelRoomCalendar.setRoomPrice(roomPrice);
   int results = 1;
   hotelRoomCalendar.setCalendarDate(calendarDate);
   hotelRoomCalendar.setUserbaseId(user.getId().toString());
   results = this.hotelRoomCalendarService.updateHotelRoomCalendar(hotelRoomCalendar);
   if (results == 1) {
     response.setSucceessMessage("修改成功");
   } else {
     response.setFailMessage("修改失败");
   }
   return response;
 }
Esempio n. 2
0
 /**
  * 查询生成单个房型日历价格方法
  *
  * @author chivalry
  * @param request
  * @return 2015-10-13
  */
 @SuppressWarnings("rawtypes")
 @PolicyJournal(accessLevel = AccessLevel.PRIVATE)
 @RequestMapping(
     value = "/to_hotelRoomPrice_add",
     method = {RequestMethod.POST})
 @ResponseBody
 public Response to_hotelRoomPrice_add(
     HttpServletRequest request, String hotelNameId, String hotelRoomId, String selectdate) {
   // 返回对象
   Response response = new Response();
   LoginUser user = LoginSessionUtil.getSystemSession(request);
   // 根据roomId查询room的默认价格
   Map<String, Object> roomMap = this.hotelRoomService.selectHotelRoomByPk(hotelRoomId);
   String defaultPrice = "1000.00";
   if (null != roomMap) {
     if (roomMap.get("price") != null) {
       defaultPrice = roomMap.get("price").toString();
     }
   }
   // 设置客房日历信息并批量插入数据
   List<HotelRoomCalendarBo> hotelRoomCalendarList = new ArrayList<HotelRoomCalendarBo>();
   HotelRoomCalendarBo hotelRoomCalendar = new HotelRoomCalendarBo();
   hotelRoomCalendar.setHotelId(hotelNameId);
   hotelRoomCalendar.setRoomId(hotelRoomId);
   hotelRoomCalendar.setRoomPrice(defaultPrice);
   int results = 1;
   hotelRoomCalendar.setCalendarDate(selectdate);
   // 先查询该日期下房型是否存在价格
   List<Map<String, Object>> roomPriceList =
       this.hotelRoomCalendarService.selectRoomPriceListByExample(hotelRoomCalendar);
   Map<String, Object> map = new HashMap<String, Object>();
   if (roomPriceList.size() == 0) {
     // 不存在价格日历插入数据
     //	    	results=this.hotelRoomCalendarService.insertHotelRoomCalendar(hotelRoomCalendar);
     hotelRoomCalendar.setUserbaseId(user.getId().toString());
     hotelRoomCalendarList.add(hotelRoomCalendar);
     if (hotelRoomCalendarList != null
         && hotelRoomCalendarList.size() > 0
         && hotelRoomCalendarList.get(0).getCalendarDate() != null
         && hotelRoomCalendarList.get(0).getCalendarDate() != "") {
       results = this.hotelRoomCalendarService.insertHotelRoomCalendar(hotelRoomCalendarList);
     }
     map.put("roomPrice", hotelRoomCalendar.getRoomPrice());
   } else {
     // 存在读取价格
     map.put("roomPrice", roomPriceList.get(0).get("roomPrice"));
   }
   if (results >= 1) {
     response.setSucceessMessage("执行成功");
     response.setRtData(map);
   } else {
     response.setFailMessage("读取价格失败");
   }
   return response;
 }
Esempio n. 3
0
  /**
   * 客房批量生成日历价格方法
   *
   * @author chivalry
   * @param request
   * @return 2015-10-13
   */
  @SuppressWarnings("rawtypes")
  @PolicyJournal(accessLevel = AccessLevel.PRIVATE)
  @RequestMapping(
      value = "/do_hotelRoomsPrice_add",
      method = {RequestMethod.POST})
  @ResponseBody
  public Response do_hotelRoomsPrice_add(
      HttpServletRequest request, String hotelNameId, String hotelRoomId) {
    // 返回对象
    Response response = new Response();
    LoginUser user = LoginSessionUtil.getSystemSession(request);
    // 根据roomId查询room的默认价格
    Map<String, Object> roomMap = this.hotelRoomService.selectHotelRoomByPk(hotelRoomId);
    String defaultPrice = "1000";
    if (null != roomMap) {
      if (roomMap.get("price") != null) {
        defaultPrice = roomMap.get("price").toString();
      }
    }
    // 设置客房日历信息并批量插入数据
    // 计算90天的所有时间批量插入数据
    int results = 1;
    Calendar c_begin = new GregorianCalendar();
    Calendar c_end = new GregorianCalendar();

    //	     DateFormatSymbols dfs = new DateFormatSymbols();
    //	     String[] weeks = dfs.getWeekdays();
    // 从当前时间开始
    Calendar systime = Calendar.getInstance();
    c_begin.set(
        systime.get(Calendar.YEAR),
        systime.get(Calendar.MONTH),
        systime.get(Calendar.DATE)); // Calendar的月从0-11
    c_end.set(
        systime.get(Calendar.YEAR),
        systime.get(Calendar.MONTH),
        systime.get(Calendar.DATE)); // Calendar的月从0-11
    // 获取90天后的时间
    c_end.add(Calendar.DAY_OF_YEAR, hotelRoom_generate_days);
    int count = 1;
    // 结束日期下滚一天是为了包含最后一天
    c_end.add(Calendar.DAY_OF_YEAR, 1);
    //	     System.out.println("开始时间是:"+new java.sql.Date(c_begin.getTime().getTime()));
    //	     System.out.println("结束时间是:"+new java.sql.Date(c_end.getTime().getTime()));
    List<HotelRoomCalendarBo> hotelRoomCalendarList = new ArrayList<HotelRoomCalendarBo>();
    while (c_begin.before(c_end)) {
      HotelRoomCalendarBo hotelRoomCalendar = new HotelRoomCalendarBo();
      hotelRoomCalendar.setHotelId(hotelNameId);
      hotelRoomCalendar.setRoomId(hotelRoomId);
      hotelRoomCalendar.setRoomPrice(defaultPrice);
      //	   System.out.println("**************"+new java.sql.Date(c_begin.getTime().getTime()));
      hotelRoomCalendar.setCalendarDate(new java.sql.Date(c_begin.getTime().getTime()).toString());
      // 先查询该日期下房型是否存在价格
      List<Map<String, Object>> roomPriceList =
          this.hotelRoomCalendarService.selectRoomPriceListByExample(hotelRoomCalendar);
      if (roomPriceList.size() == 0) {
        // 不存在价格日历插入数据
        hotelRoomCalendar.setUserbaseId(user.getId().toString());
        hotelRoomCalendarList.add(hotelRoomCalendar);
      }
      if (c_begin.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
        count++;
      }
      c_begin.add(Calendar.DAY_OF_YEAR, 1);
    }
    if (hotelRoomCalendarList != null
        && hotelRoomCalendarList.size() > 0
        && hotelRoomCalendarList.get(0).getCalendarDate() != null
        && hotelRoomCalendarList.get(0).getCalendarDate() != "") {
      results = this.hotelRoomCalendarService.insertHotelRoomCalendar(hotelRoomCalendarList);
    }
    if (results >= 1) {
      response.setSucceessMessage("执行成功");
    } else {
      response.setFailMessage("执行失败");
    }
    return response;
  }
Esempio n. 4
0
  /**
   * 批量修改价格
   *
   * @param request
   * @return 2015-10-31
   * @throws ParseException
   */
  @PolicyJournal(accessLevel = AccessLevel.PRIVATE)
  @RequestMapping("/do_hotelRoomPrices_edit")
  @ResponseBody
  public Response do_hotelRoomPrices_edit(HttpServletRequest request) throws ParseException {
    Response res = new Response();
    Calendar c_begin = new GregorianCalendar();
    Calendar c_end = new GregorianCalendar();
    String startDate = request.getParameter("startDate");
    String endDate = request.getParameter("endDate");
    String hotelRoomId = request.getParameter("hotelRoomId");
    String price = request.getParameter("price");
    String hotelNameId = request.getParameter("hotelNameId");
    LoginUser user = LoginSessionUtil.getSystemSession(request);
    // 从开始时间开始
    Calendar start = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date date1 = sdf.parse(startDate);
    start.setTime(date1);
    // 从结束时间结束
    Calendar end = Calendar.getInstance();
    Date date2 = sdf.parse(endDate);
    end.setTime(date2);

    c_begin.set(
        start.get(Calendar.YEAR),
        start.get(Calendar.MONTH),
        start.get(Calendar.DATE)); // Calendar的月从0-11
    c_end.set(
        end.get(Calendar.YEAR), end.get(Calendar.MONTH), end.get(Calendar.DATE)); // Calendar的月从0-11
    int count = 1;
    int results = 1;
    // 结束日期下滚一天是为了包含最后一天
    c_end.add(Calendar.DAY_OF_YEAR, 1);
    //	     System.out.println("开始时间是:"+new java.sql.Date(c_begin.getTime().getTime()));
    //	     System.out.println("结束时间是:"+new java.sql.Date(c_end.getTime().getTime()));
    List<HotelRoomCalendarBo> hotelRoomCalendarList = new ArrayList<HotelRoomCalendarBo>();
    while (c_begin.before(c_end)) {
      HotelRoomCalendarBo hotelRoomCalendar = new HotelRoomCalendarBo();
      hotelRoomCalendar.setHotelId(hotelNameId);
      hotelRoomCalendar.setRoomId(hotelRoomId);
      hotelRoomCalendar.setRoomPrice(price);
      //	   System.out.println("**************"+new java.sql.Date(c_begin.getTime().getTime()));
      hotelRoomCalendar.setCalendarDate(new java.sql.Date(c_begin.getTime().getTime()).toString());
      // 先查询该日期下房型是否存在价格
      List<Map<String, Object>> roomPriceList =
          this.hotelRoomCalendarService.selectRoomPriceListByExample(hotelRoomCalendar);
      if (roomPriceList.size() == 0) {
        // 不存在价格日历插入数据
        hotelRoomCalendar.setUserbaseId(user.getId().toString());
        hotelRoomCalendarList.add(hotelRoomCalendar);
      } else {
        // 存在就删除数据再插入
        int r = hotelRoomCalendarService.deleteByExample(hotelRoomCalendar);
        hotelRoomCalendar.setUserbaseId(user.getId().toString());
        hotelRoomCalendarList.add(hotelRoomCalendar);
      }
      if (c_begin.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
        count++;
      }
      c_begin.add(Calendar.DAY_OF_YEAR, 1);
    }
    if (hotelRoomCalendarList != null
        && hotelRoomCalendarList.size() > 0
        && hotelRoomCalendarList.get(0).getCalendarDate() != null
        && hotelRoomCalendarList.get(0).getCalendarDate() != "") {
      results = this.hotelRoomCalendarService.insertHotelRoomCalendar(hotelRoomCalendarList);
    }

    if (results >= 1) {
      res.setSucceessMessage("执行成功");
    } else {
      res.setFailMessage("执行失败");
    }
    return res;
  }