| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- package com.happy.service.impl;
- import com.happy.Model.Booking;
- import com.happy.Model.Hotel;
- import com.happy.Model.House;
- import com.happy.Until.DateUtil;
- import com.happy.Until.Func;
- import com.happy.Until.TimeExchange;
- import com.happy.dao.BookDao;
- import com.happy.dao.HouseDao;
- import com.happy.dto.IPage;
- import com.happy.service.AppHomePageService;
- import com.happy.service.BookService;
- import com.happy.service.HotelService;
- import com.happy.service.HouseService;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- @Service("AppHomePageService")
- public class AppHomePageImplService implements AppHomePageService {
- @Resource
- public BookDao bookDao;
- @Resource
- public HouseDao houseDao;
- @Resource
- public HouseService houseService;
- @Resource
- public HotelService hotelService;
- @Resource
- public BookService bookService;
- @Override
- public IPage<Hotel> getHotelList(String queryValue, int page, int rows) {
- IPage<Hotel> iPage = new IPage();
- StringBuilder strSql = new StringBuilder("");
- if (!Func.checkNull(queryValue)){
- strSql.append(" and hname like '%").append(queryValue).append("%' ");
- }
- return hotelService.queryPagePrice(strSql.toString(),page,rows);
- }
- @Override
- public int getHotelTotal(String queryValue) {
- return 0;
- }
- @Override
- public Hotel getHotelAndHouseByHotelId(String hotelId, String queryStartTime, String queryEndTime) {
- if (Func.checkNull(hotelId))
- return new Hotel();
- Hotel hotel = hotelService.getById(Func.parseInt(hotelId));
- if (Func.checkNull(hotel.getManagerId()))
- return hotel;
- System.out.println(hotel.getManagerId());// 需求确定使用商户id关联房型
- StringBuffer strSql = new StringBuffer();
- strSql.append(" and manager_id = '").append(hotel.getManagerId()).append("' ");
- List<House> houseList = houseService.queryList(strSql.toString());
- if (houseList == null )
- return hotel;
- // Map<String, House> houseMap = new HashMap();
- // houseList.forEach((House house) ->{
- // if (house.getId() == 0)
- // return;
- // houseMap.put(Func.parseStr(house.getId()),house);
- // });
- // 判断是否有房间,对每个房型进行标识
- StringBuffer strSqlBook = new StringBuffer();
- strSqlBook.append(" and hotel_manager_id = '").append(hotel.getManagerId()).append("' ");
- strSqlBook.append(" and order_start_time >= '").append(queryStartTime).append("' ");
- strSqlBook.append(" and order_end_time < '").append(queryEndTime).append("' ");
- List<Booking> bookList = bookService.queryList(strSqlBook.toString());
- Map<String, Integer> houseBookingMap = new HashMap();
- if (bookList != null && bookList.size() > 0)
- {
- Integer numberTemp = new Integer(0);
- for (Booking booking: bookList) {
- if (Func.checkNull(booking.getHouseId()))
- continue;
- if (houseBookingMap.containsKey(booking.getHouseId()))
- {
- numberTemp = houseBookingMap.get(booking.getHouseId());
- int i = Func.parseInt(numberTemp) + booking.getHouseOrderNumber();
- houseBookingMap.put(booking.getHouseId(),i);
- continue;
- }
- houseBookingMap.put(booking.getHouseId(),booking.getHouseOrderNumber());
- }
- }
- houseList.forEach((House house) ->{
- if (!houseBookingMap.containsKey(Func.parseStr(house.getId())))
- return;
- int i = Func.parseInt(house.getNumber()) - Func.parseInt(houseBookingMap.get(house.getId()));
- house.setRemainRooms(Func.parseStr(i));
- });
- hotel.setHouseList(houseList);
- return hotel;
- }
- }
|