Commit d2e4c813 by wuwenlong

open the door bugfix;

room status opt;
parent 9c6faff6
......@@ -4,6 +4,7 @@ import java.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -66,9 +67,13 @@ public class SRoomController extends BaseController {
*/
@ApiOperation(value = "房间状态(房间详情下单时段列表T+1天)")
@RequestMapping(value = "/roomStatus", method = RequestMethod.GET)
public R<List<RoomStatusVo>> getRoomStatus(@RequestParam("storeId") Long storeId
, @RequestParam("roomId") Long roomId, @RequestParam("day") Date day) {
return R.ok(roomStatusService.roomStatus(storeId, roomId, day));
public R<List<RoomStatusVo>> getRoomStatus(
@ApiParam(name="storeId",value="门店ID",required = true) @RequestParam("storeId") Long storeId
,@ApiParam(name="roomId",value="房间ID",required = true) @RequestParam("roomId") Long roomId
,@ApiParam(name="day",value="下单选择的日期",required = true) @RequestParam("day") Date day
,@ApiParam(name="orderType",value="订单类型 1:预约;2:续单",defaultValue = "1")
@RequestParam(value="orderType",defaultValue = "1") Integer orderType) {
return R.ok(roomStatusService.roomStatus(storeId, roomId, day,orderType));
}
/**
......
......@@ -15,8 +15,9 @@ public interface RoomStatusService {
* 通过门店ID,房间ID,日期查询房间T+1天时段状态
* @param storeId
* @param roomId
* @param orderType
* @return List<RoomStatusVo>
*/
List<RoomStatusVo> roomStatus(Long storeId, Long roomId, Date day);
List<RoomStatusVo> roomStatus(Long storeId, Long roomId, Date day, Integer orderType);
}
......@@ -4,6 +4,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.constant.Constants;
import share.common.enums.OrderTypeEnum;
import share.common.enums.RoomStatusEnum;
import share.common.utils.DateUtils;
import share.common.utils.StringUtils;
......@@ -39,7 +40,7 @@ public class RoomStatusServiceImpl implements RoomStatusService {
private SConsumerService consumerService;
@Override
public List<RoomStatusVo> roomStatus(Long storeId, Long roomId, Date day) {
public List<RoomStatusVo> roomStatus(Long storeId, Long roomId, Date day, Integer orderType) {
SConsumer user = consumerService.getInfo();
if(user!=null){
FrontTokenComponent.loginSConsumerEntryThreadLocal.set(user);
......@@ -48,12 +49,12 @@ public class RoomStatusServiceImpl implements RoomStatusService {
SStore store = storeService.getById(storeId);
// 通过门店及房间查询指定日期T+1的订单
List<SOrder> orderList = orderService.listByRoomInfo(storeId,roomId,day);
List<RoomStatusVo> voList = generatorRoomStatusList(store,roomId,orderList,day);
voList.addAll(generatorRoomStatusList(store,roomId,orderList,DateUtils.addDays(day,1)));
List<RoomStatusVo> voList = generatorRoomStatusList(store,roomId,orderList,day,orderType);
voList.addAll(generatorRoomStatusList(store,roomId,orderList,DateUtils.addDays(day,1),orderType));
return voList;
}
private List<RoomStatusVo> generatorRoomStatusList(SStore store,Long roomId,List<SOrder> orderList,Date day){
private List<RoomStatusVo> generatorRoomStatusList(SStore store,Long roomId,List<SOrder> orderList,Date day, Integer orderType){
String nowTime = "00:00";
String dayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day);
Boolean isToday = StringUtils.equals(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day)
......@@ -77,14 +78,14 @@ public class RoomStatusServiceImpl implements RoomStatusService {
vo.setRoomId(roomId);
vo.setTimeHour(timeHour);
Date timeHourDate = DateUtils.parseDate(timeHour);
setTimeHourStatus(vo,timeHourDate,store,orderList,dayStr,finalNowTime,isToday);
setTimeHourStatus(vo,timeHourDate,store,orderList,dayStr,finalNowTime,isToday,orderType);
voList.add(vo);
});
return voList;
}
//设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单)
private void setTimeHourStatus(RoomStatusVo vo,Date timeHourDate, SStore store, List<SOrder> orderList, String day, String finalNowTime, Boolean isToday){
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());
//门店存在营业时间
if(StringUtils.isNotBlank(store.getOpenStartTime())) {
......@@ -126,18 +127,19 @@ public class RoomStatusServiceImpl implements RoomStatusService {
vo.setEndHoldTime(DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
}
checkTimeHourToOrder(vo,timeHourDate,orderList);
checkTimeHourToOrder(vo,timeHourDate,orderList,orderType);
}
private void checkTimeHourToOrder(RoomStatusVo vo,Date timeHourDate, List<SOrder> orderList){
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
private void checkTimeHourToOrder(RoomStatusVo vo,Date timeHourDate, List<SOrder> orderList, Integer orderType){
SConsumer user = consumerService.getInfo();
if(CollectionUtils.isNotEmpty(orderList)){
orderList.stream().forEach(order -> {
Date orderStartDate = Objects.nonNull(order.getStartDate())?order.getStartDate():order.getPreStartDate();
Date orderEndDate = Objects.nonNull(order.getEndDate())?order.getEndDate():order.getPreEndDate();
//如果当前用户已登陆,并且在已下单的房间下单,不计算当前订单的保洁时间
//如果订单类型为预约,或者当前当前登陆用户为空,或者当前当前登陆用户ID为空,或者订单不属于当前用户,计算当前订单的保洁时间
//否则开始时间-30分钟保洁时间,结束时间+30分钟保洁时间
if(Objects.isNull(user)||Objects.isNull(user.getId())||order.getConsumerId().compareTo(user.getId())!=0){
if(OrderTypeEnum.RESERVER.getCode().compareTo(orderType)==0
||Objects.isNull(user)||Objects.isNull(user.getId())||order.getConsumerId().compareTo(user.getId())!=0){
orderEndDate = DateUtils.addMinutes(orderEndDate,Constants.ROOM_LOCK_DELAY_MINUTE);
orderStartDate = DateUtils.addMinutes(orderEndDate,-Constants.ROOM_LOCK_DELAY_MINUTE);
}
......
......@@ -891,8 +891,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
throw new BaseException("房间当前时段已被占用不可开门!");
}
//判断预约时间是否到达,可提前一个小时开门
if(DateUtils.addHours(sOrder.getPreStartDate(),-Constants.OPEN_DOOR_AHEAD_HOUR).compareTo(new Date())<0){
throw new BaseException("预约时间未到达,可提前"+Constants.OPEN_DOOR_AHEAD_HOUR+"进场,请耐心等候!");
if(DateUtils.addHours(sOrder.getPreStartDate(),Constants.OPEN_DOOR_AHEAD_HOUR).compareTo(new Date())<0){
throw new BaseException("预约时间未到达,可提前"+Constants.OPEN_DOOR_AHEAD_HOUR+"小时进场,请耐心等候!");
}
//更改订单状态,房间状态,开始时间,结束时间
sOrder.setStatus(OrderStatusEnum.INUSE.getCode());
......
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