Commit 34df0466 by 吕明尚

修改房间状态接口

parent c713844a
......@@ -58,14 +58,10 @@ public class RoomStatusServiceImpl implements RoomStatusService {
SStore store = storeService.getById(storeId);
// 通过门店及房间查询指定日期T+1的订单
List<SOrder> orderList = orderService.listByRoomInfo(storeId,new ArrayList<Long>(){{add(roomId);}},day);
//去掉ID为orderId的订单
if (CollectionUtils.isNotEmpty(orderList) && Objects.nonNull(orderId)) {
orderList = orderList.stream().filter(order -> order.getId().compareTo(orderId) != 0).collect(Collectors.toList());
}
SCleanRecords cleanRecords = cleanRecordsService.lastCleanByRoomId(roomId);
SRoom room = roomService.getById(roomId);
List<RoomStatusVo> voList = generatorRoomStatusList(store,room,orderList,cleanRecords,day,orderType, user);
voList.addAll(generatorRoomStatusList(store,room,orderList,cleanRecords,DateUtils.addDays(day,1),orderType, user));
List<RoomStatusVo> voList = generatorRoomStatusList(store, room, orderList, cleanRecords, day, orderType, user, orderId);
voList.addAll(generatorRoomStatusList(store, room, orderList, cleanRecords, DateUtils.addDays(day, 1), orderType, user, orderId));
return voList;
}
......@@ -89,16 +85,14 @@ public class RoomStatusServiceImpl implements RoomStatusService {
List<RoomStatusVo> voList = new ArrayList<>();
Map<Long, SCleanRecords> finalCleanRecordMap = cleanRecordMap;
roomList.stream().forEach(room -> {
voList.addAll(generatorRoomStatusList(store, room, orderMap.get(room.getId()), finalCleanRecordMap.get(room.getId()), day, OrderTypeEnum.RESERVER.getCode(), user));
voList.addAll(generatorRoomStatusList(store, room, orderMap.get(room.getId()), finalCleanRecordMap.get(room.getId()), DateUtils.addDays(day, 1), OrderTypeEnum.RESERVER.getCode(), user));
voList.addAll(generatorRoomStatusList(store, room, orderMap.get(room.getId()), finalCleanRecordMap.get(room.getId()), day, OrderTypeEnum.RESERVER.getCode(), user, null));
voList.addAll(generatorRoomStatusList(store, room, orderMap.get(room.getId()), finalCleanRecordMap.get(room.getId()), DateUtils.addDays(day, 1), OrderTypeEnum.RESERVER.getCode(), user, null));
});
return voList;
}
private List<RoomStatusVo> generatorRoomStatusList(SStore store,SRoom room,List<SOrder> orderList,SCleanRecords cleanRecords,Date day, Integer orderType, SConsumer user){
private List<RoomStatusVo> generatorRoomStatusList(SStore store, SRoom room, List<SOrder> orderList, SCleanRecords cleanRecords, Date day, Integer orderType, SConsumer user, Long orderId) {
String nowTime = "00:00";
Boolean isAvailable = false;
if (orderType.equals(OrderTypeEnum.RENEW.getCode())) {
......@@ -151,20 +145,20 @@ public class RoomStatusServiceImpl implements RoomStatusService {
vo.setTimeHour(timeHour);
vo.setIsAvailable(finalIsAvailable);
Date timeHourDate = DateUtils.parseDate(timeHour);
setTimeHourStatus(vo, timeHourDate, store, room, finalOrderList, cleanRecords, dayStr, finalNowTime, isToday, orderType, user);
setTimeHourStatus(vo, timeHourDate, store, room, finalOrderList, cleanRecords, dayStr, finalNowTime, isToday, orderType, user, orderId);
voList.add(vo);
});
return voList;
}
//设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单)
private void setTimeHourStatus(RoomStatusVo vo,Date timeHourDate, SStore store, SRoom room, List<SOrder> orderList, SCleanRecords cleanRecords, String day, String finalNowTime, Boolean isToday, Integer orderType, SConsumer user){
private void setTimeHourStatus(RoomStatusVo vo, Date timeHourDate, SStore store, SRoom room, List<SOrder> orderList, SCleanRecords cleanRecords, String day, String finalNowTime, Boolean isToday, Integer orderType, SConsumer user, Long orderId) {
vo.setStatus(RoomStatusEnum.FREE.getValue());
if(checkRoomUpShelf(vo,timeHourDate,room)) {
checkIsDirtyRoom(vo, timeHourDate, store, cleanRecords, day);
checkTimeHourToSysDate(vo, timeHourDate, day, finalNowTime, isToday);
checkTimeHourToBusiness(vo, timeHourDate, store, day);
checkTimeHourToOrder(vo, timeHourDate, orderList, cleanRecords, orderType, user);
checkTimeHourToOrder(vo, timeHourDate, orderList, cleanRecords, orderType, user, orderId);
}
}
......@@ -284,7 +278,7 @@ public class RoomStatusServiceImpl implements RoomStatusService {
}
}
private void checkTimeHourToOrder(RoomStatusVo vo,Date timeHourDate, List<SOrder> orderList, SCleanRecords cleanRecords, Integer orderType, SConsumer user){
private void checkTimeHourToOrder(RoomStatusVo vo, Date timeHourDate, List<SOrder> orderList, SCleanRecords cleanRecords, Integer orderType, SConsumer user, Long orderId) {
// SConsumer user = consumerService.getInfo();
if(CollectionUtils.isNotEmpty(orderList)){
orderList.stream().forEach(order -> {
......@@ -301,7 +295,13 @@ public class RoomStatusServiceImpl implements RoomStatusService {
orderEndDate = cleanRecords.getEndDate();
}
}else{
orderEndDate = DateUtils.addMinutes(orderEndDate, Constants.ROOM_LOCK_DELAY_MINUTE);
if (!ObjectUtils.isEmpty(orderId)) {
if (!order.getId().equals(orderId)) {
orderEndDate = DateUtils.addMinutes(orderEndDate, Constants.ROOM_LOCK_DELAY_MINUTE);
}
} else {
orderEndDate = DateUtils.addMinutes(orderEndDate, Constants.ROOM_LOCK_DELAY_MINUTE);
}
}
orderStartDate = DateUtils.addMinutes(orderStartDate, -Constants.ROOM_LOCK_DELAY_MINUTE);
}
......
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