Commit 2214de02 by wuwenlong

room status bugfix;

parent 88b3b5b1
......@@ -87,47 +87,68 @@ public class RoomStatusServiceImpl implements RoomStatusService {
//设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单)
private void setTimeHourStatus(RoomStatusVo vo,Date timeHourDate, SStore store, List<SOrder> orderList, String day, String finalNowTime, Boolean isToday, Integer orderType){
vo.setStatus(RoomStatusEnum.FREE.getValue());
checkTimeHourToSysDate(vo,timeHourDate,day,finalNowTime,isToday);
checkTimeHourToBusiness(vo,timeHourDate,store,day);
checkTimeHourToOrder(vo,timeHourDate,orderList,orderType);
}
private void changeEndHoldTime(RoomStatusVo vo, Date date){
if(vo.getEndHoldTime().compareTo(date)<0){
vo.setEndHoldTime(date);
}
}
private void changeStartHoldTime(RoomStatusVo vo, Date date){
if(vo.getStartHoldTime().compareTo(date)>0){
vo.setStartHoldTime(date);
}
}
private void checkTimeHourToBusiness(RoomStatusVo vo,Date timeHourDate, SStore store, String day){
//门店存在营业时间
if(StringUtils.isNotBlank(store.getOpenStartTime())) {
//当前时段小于营业开始时间
if (timeHourDate.compareTo(DateUtils.parseDate(day + " " + store.getOpenStartTime())) == -1) {
vo.setStatus(RoomStatusEnum.HOLD.getValue());
vo.setStartHoldTime(timeHourDate);
changeStartHoldTime(vo,timeHourDate);
//判断是否是同一个小时,如果是同一个小时,占用结束时间为营业开始时间
if (timeHourDate.compareTo(DateUtils.parseDate(day + " " + store.getOpenStartTime().split(":")[0])) == 0) {
vo.setEndHoldTime(DateUtils.parseDate(day + " " + store.getOpenStartTime()));
changeEndHoldTime(vo,DateUtils.parseDate(day + " " + store.getOpenStartTime()));
} else {
//占用结束时间为当前时段59分59秒
vo.setEndHoldTime(DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
}
//当前时段大于营业结束时间
if (timeHourDate.compareTo(DateUtils.parseDate(day + " " + store.getOpenEndTime())) == 1 && !StringUtils.equals(store.getOpenStartTime(),"00:00")) {
vo.setStatus(RoomStatusEnum.HOLD.getValue());
//占用结束时间为当前时段59分59秒
vo.setEndHoldTime(DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
//判断是否是同一个小时,如果是同一个小时,占用开始时间为营业结束时间
if (timeHourDate.compareTo(DateUtils.parseDate(day + " " + store.getOpenEndTime().split(":")[0])) == 0) {
vo.setStartHoldTime(DateUtils.parseDate(day + " " + store.getOpenEndTime()));
changeStartHoldTime(vo,DateUtils.parseDate(day + " " + store.getOpenEndTime()));
} else {
//占用开始时间为当前时段0分0秒
vo.setStartHoldTime(timeHourDate);
changeStartHoldTime(vo,timeHourDate);
}
}
}
}
private void checkTimeHourToSysDate(RoomStatusVo vo,Date timeHourDate, String day, String finalNowTime, Boolean isToday){
//当前时段小于当前时间
if(isToday && timeHourDate.compareTo(DateUtils.parseDate(day+" "+ finalNowTime))==-1){
vo.setStatus(RoomStatusEnum.HOLD.getValue());
vo.setStartHoldTime(timeHourDate);
changeStartHoldTime(vo,timeHourDate);
//判断是否是同一个小时,如果是同一个小时,占用结束时间为当前时间
if(timeHourDate.compareTo(DateUtils.parseDate(day+" "+finalNowTime.split(":")[0])) == 0){
vo.setEndHoldTime(DateUtils.parseDate(day+" "+finalNowTime));
changeEndHoldTime(vo,DateUtils.parseDate(day+" "+finalNowTime));
}else {
//占用结束时间为当前时段59分59秒
vo.setEndHoldTime(DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
}
checkTimeHourToOrder(vo,timeHourDate,orderList,orderType);
}
private void checkTimeHourToOrder(RoomStatusVo vo,Date timeHourDate, List<SOrder> orderList, Integer orderType){
......@@ -149,18 +170,18 @@ public class RoomStatusServiceImpl implements RoomStatusService {
//判断订单开始时间是否是同一个小时,如果是同一个小时,占用开始时间为订单开始时间
if(StringUtils.equals(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH,timeHourDate)
,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH,orderStartDate))){
vo.setStartHoldTime(orderStartDate);
changeStartHoldTime(vo,orderStartDate);
}else {
//占用开始时间为当前时段0分0秒
vo.setStartHoldTime(timeHourDate);
changeStartHoldTime(vo,timeHourDate);
}
//判断订单结束时间是否是同一个小时,如果是同一个小时,占用结束时间为订单结束时间
if(StringUtils.equals(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH,timeHourDate)
,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH,orderEndDate))){
vo.setEndHoldTime(orderEndDate);
changeEndHoldTime(vo,orderEndDate);
}else {
//占用结束时间为当前时段59分59秒
vo.setEndHoldTime(DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment