|
|
@@ -1,7 +1,9 @@
|
|
|
package com.chuanghai.ihotel.service.impl;
|
|
|
|
|
|
+import com.chuanghai.ihotel.constant.TimeConstant;
|
|
|
import com.chuanghai.ihotel.controller.request.RoomTypeQueryRequest;
|
|
|
import com.chuanghai.ihotel.service.RoomRealtimeStatuService;
|
|
|
+import com.chuanghai.ihotel.util.CommonUtil;
|
|
|
import com.chuanghai.ihotel.vo.RoomTypeShortDescVO;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -19,6 +21,7 @@ import com.chuanghai.ihotel.dao.RoomTypeDao;
|
|
|
import com.chuanghai.ihotel.entity.RoomTypeEntity;
|
|
|
import com.chuanghai.ihotel.service.RoomTypeService;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -39,10 +42,12 @@ public class RoomTypeServiceImpl extends ServiceImpl<RoomTypeDao, RoomTypeEntity
|
|
|
return new PageUtils(page);
|
|
|
}
|
|
|
|
|
|
- @Cacheable(value = {"roomType"}, key = "#root.method.name + '-' + #request.startTime + '-' + #request.endTime")
|
|
|
+ @Cacheable(value = {"roomType"}, key = "#root.method.name + '-' + #request.startDate + '-' + #request.endDate")
|
|
|
@Override
|
|
|
public List<RoomTypeShortDescVO> listForClientIndex(RoomTypeQueryRequest request) {
|
|
|
List<RoomTypeEntity> all = this.list();
|
|
|
+ LocalDateTime startTime = CommonUtil.localDateToTime(request.getStartDate(), TimeConstant.INTO_TIME);
|
|
|
+ LocalDateTime endTime = CommonUtil.localDateToTime(request.getEndDate(), TimeConstant.OUT_TIME);
|
|
|
List<RoomTypeShortDescVO> vos = all.stream().map(e -> {
|
|
|
RoomTypeShortDescVO vo = new RoomTypeShortDescVO();
|
|
|
BeanUtils.copyProperties(e, vo);
|
|
|
@@ -52,7 +57,7 @@ public class RoomTypeServiceImpl extends ServiceImpl<RoomTypeDao, RoomTypeEntity
|
|
|
vo.setMasterImage(masterImage);
|
|
|
|
|
|
// 获取当前时间繁忙状态的房间数量
|
|
|
- int num = roomRealtimeStatuService.getBusyNum(e.getId(), request.getStartTime(), request.getEndTime());
|
|
|
+ int num = roomRealtimeStatuService.getBusyNum(e.getId(), startTime, endTime);
|
|
|
int enableNum = e.getRoomNum() - num;
|
|
|
vo.setEnableNum(enableNum >= 0 ? enableNum : 0);
|
|
|
return vo;
|