|
|
@@ -1,25 +1,28 @@
|
|
|
package com.happy.service.impl;
|
|
|
|
|
|
-import com.happy.Model.AdminManager;
|
|
|
import com.happy.Model.Booking;
|
|
|
+import com.happy.Model.HotelDict;
|
|
|
+import com.happy.Model.HouseNumber;
|
|
|
+import com.happy.Model.HouseNumberStatus;
|
|
|
import com.happy.Until.DateUtil;
|
|
|
-import com.happy.Until.Enum.OrderEnum;
|
|
|
import com.happy.Until.Enum.PayEnum;
|
|
|
import com.happy.Until.Func;
|
|
|
-import com.happy.common.http.Message;
|
|
|
-import com.happy.common.http.Message2;
|
|
|
+import com.happy.Until.HttpUtils;
|
|
|
import com.happy.dao.BookDao;
|
|
|
import com.happy.dto.BookTypeEto;
|
|
|
import com.happy.dto.IPage;
|
|
|
-import com.happy.service.AdminManagerService;
|
|
|
-import com.happy.service.BookService;
|
|
|
-import com.happy.service.BookinglogService;
|
|
|
+import com.happy.service.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.awt.print.Book;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
@Service("BookService")
|
|
|
public class BookImplService implements BookService {
|
|
|
@@ -31,6 +34,18 @@ public class BookImplService implements BookService {
|
|
|
@Resource
|
|
|
public AdminManagerService adminManagerService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ public HotelDictService hotelDictService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ public HouseNumberService houseNumberService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ public HouseNumberStatusService houseNumberStatusService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HttpServletRequest request;
|
|
|
+
|
|
|
@Override
|
|
|
public int insertBooking(Booking book) {
|
|
|
return bookDao.insertBooking(book);
|
|
|
@@ -159,5 +174,70 @@ public class BookImplService implements BookService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int updateBookStatus() {
|
|
|
+ HotelDict respTime = hotelDictService.getById(1997956735);//响应时间 状态1为10分、2为20分、3为30分
|
|
|
+ String times = String.valueOf(respTime.getCode() * 10);
|
|
|
+ HotelDict operate = hotelDictService.getById(1997956736);//响应时间 1自动接单 2自动拒单
|
|
|
+ String sqlx = " and create_time <= DATE_SUB(NOW(), INTERVAL " + times + " MINUTE) and order_status = 2 ";
|
|
|
+ List<Booking> bookings = bookDao.queryList(sqlx);
|
|
|
+ List<HouseNumberStatus> list = new ArrayList<>();
|
|
|
+ if (operate.getCode() == 1){
|
|
|
+ bookings.forEach(booking -> {
|
|
|
+ //不可入住的房间
|
|
|
+ List<HouseNumber> houseNumbers = houseNumberService.queryHouseStatus(booking);
|
|
|
+ //所有房间
|
|
|
+ List<HouseNumber> houseNumberList = houseNumberService.queryByHouseId(booking.getHouseId());
|
|
|
+ AtomicInteger i = new AtomicInteger();
|
|
|
+ List<String> Ids = new ArrayList<>();
|
|
|
+ if (houseNumbers != null){
|
|
|
+ houseNumberList.forEach(houseNumber -> {
|
|
|
+ //添加的房间不在不可添加的房间当中并且数量小于订房总数
|
|
|
+ if (!houseNumbers.contains(houseNumber) && i.get() < booking.getHouseOrderNumber()){
|
|
|
+ Ids.add(houseNumber.getId());
|
|
|
+ i.getAndIncrement();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime str = LocalDateTime.parse(booking.getOrderStartTime(), inputFormatter);
|
|
|
+ LocalDateTime end = LocalDateTime.parse(booking.getOrderEndTime(), inputFormatter);
|
|
|
+ String a = str.format(formatter);
|
|
|
+ String B = end.format(formatter);
|
|
|
+ LocalDate strDate = LocalDate.parse(a, formatter);
|
|
|
+ LocalDate endDate = LocalDate.parse(B, formatter);
|
|
|
+ Date now = null;
|
|
|
+ try {
|
|
|
+ now = DateUtil.formateDate(DateUtil.getCurrentDate(), DateUtil.Time_Formatter_Second);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ for (String number : Ids){
|
|
|
+ for (LocalDate date = strDate; !date.isAfter(endDate.minusDays(1)); date = date.plusDays(1)){
|
|
|
+ HouseNumberStatus houseNumberStatus = new HouseNumberStatus();
|
|
|
+ houseNumberStatus.setNumberId(number);
|
|
|
+ houseNumberStatus.setId(String.valueOf(UUID.randomUUID()));
|
|
|
+ houseNumberStatus.setCreateDate(now);
|
|
|
+ houseNumberStatus.setModifyDate(now);
|
|
|
+ houseNumberStatus.setRemark("");
|
|
|
+ houseNumberStatus.setBookingId(String.valueOf(booking.getId()));
|
|
|
+ houseNumberStatus.setSetDate(date.format(formatter));
|
|
|
+ houseNumberStatus.setStatus(5);//状态(0删除 1.正常 2.关房 3.脏房 4.净房 5.预定 6.入住)
|
|
|
+ list.add(houseNumberStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ return houseNumberStatusService.saveBatch(list);
|
|
|
+ }else {
|
|
|
+ request.getServerName();
|
|
|
+
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|