| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- package com.happy.service.impl;
- import com.happy.Model.Booking;
- import com.happy.Model.FileInfo;
- import com.happy.Model.Hotel;
- import com.happy.Model.House;
- import com.happy.Until.DateUtil;
- import com.happy.Until.Enum.PayEnum;
- import com.happy.Until.Func;
- import com.happy.Until.TimeExchange;
- import com.happy.dao.BookDao;
- import com.happy.dao.HouseDao;
- import com.happy.dao.impl.FileImplInfoDao;
- import com.happy.dto.IPage;
- import com.happy.service.*;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.*;
- @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;
- @Resource
- public AdminManagerService adminManagerService;
- @Resource
- public FileService fileService;
- @Override
- public IPage<Hotel> getHotelList(String queryValue,String hotel_township, int page, int rows) {
- StringBuilder strSql = new StringBuilder(" and hstatus=1 "); // 酒店正在营业中才显示
- if (!Func.checkNull(queryValue)){
- strSql.append(" and hname like '%").append(queryValue).append("%' ");
- }
- if (!Func.checkNull(hotel_township)){
- strSql.append(" and c.hotel_township = '").append(hotel_township).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 (hotel == null || Func.checkNull(String.valueOf(hotel.getManagerId())))
- return hotel;
- // 数据字典写入hotel
- Map dicMap = hotelService.queryHotelDicMap();
- if (!Func.checkNull(hotel.getHconfig()))
- {
- List<String> list = Arrays.asList(hotel.getHconfig().split(","));
- List hotelDicList = new ArrayList();
- for (String hotelDicId:list) {
- if (!dicMap.containsKey(Func.parseInt(hotelDicId)))
- continue;
- hotelDicList.add(dicMap.get(Func.parseInt(hotelDicId)));
- }
- hotel.setHconfigList(hotelDicList);
- }
- 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;
- // 数据字典写入hotel
- List<String> hlist = new ArrayList<>();
- List houseDicList = new ArrayList();
- for (House house:houseList) {
- if (house == null || Func.checkNull(Func.parseStr(house.getNumber())))
- continue;
- // “,”号分逗开来
- hlist = Arrays.asList(house.gethConfig().split(","));
- houseDicList = new ArrayList();
- for (String houseDicId:hlist) {
- if (!dicMap.containsKey(Func.parseInt(houseDicId)))
- continue;
- houseDicList.add(dicMap.get(Func.parseInt(houseDicId)));
- }
- house.sethConfigList(houseDicList);
- }
- // 判断是否有房间,对每个房型进行标识
- StringBuffer strSqlBook = new StringBuffer();
- strSqlBook.append(" and hotel_manager_id = '").append(hotel.getManagerId()).append(" ' ");
- if (!Func.checkNull(queryStartTime))
- strSqlBook.append(" and order_start_time >= '").append(queryStartTime).append(" 00:00:00 ' ");
- if (!Func.checkNull(queryEndTime))
- strSqlBook.append(" and order_end_time < '").append(queryEndTime).append(" 23:59:59 ' ");
- //1待支付,2已支付,3待入住,4已入住,5已消费,6支付超时,7已取消,8已退单,9已退款
- strSqlBook.append(" and ( order_status = '").append(PayEnum.待支付.getNum()).append("' ");
- strSqlBook.append(" or order_status = '").append(PayEnum.已支付.getNum()).append("' ");
- strSqlBook.append(" or order_status = '").append(PayEnum.待入住.getNum()).append("' ");
- strSqlBook.append(" or order_status = '").append(PayEnum.已入住.getNum()).append(" ' ) ");
- List<Booking> bookList = bookService.queryList(strSqlBook.toString());
- // 订房数据字典Map<houseid, 订房数量>
- 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);
- }else {
- houseBookingMap.put(booking.getHouseId(),booking.getHouseOrderNumber());
- }
- }
- }
- for (House house:houseList) {
- if (house == null)
- continue;
- // 将房间图片,写入房型对象中
- StringBuilder fileSqlx = new StringBuilder("");
- fileSqlx.append(" and link_id = '").append(house.getId()).append("'");
- List<FileInfo> fileInfoList = fileService.queryList(fileSqlx.toString());
- house.setFileInfoList(fileInfoList);
- // 进行累加数据,计算房型还剩余多少房间
- if (!houseBookingMap.containsKey(Func.parseStr(house.getId()))) {
- house.setRemainRooms(Func.parseStr(house.getNumber()));
- continue;
- }
- int i = Func.parseInt(house.getNumber()) - Func.parseInt(houseBookingMap.get(Func.parseStr(house.getId())));
- house.setRemainRooms(Func.parseStr(i));
- };
- hotel.setHouseList(houseList);
- return hotel;
- }
- }
|