|
@@ -4,9 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
import cn.hutool.core.lang.tree.TreeNode;
|
|
import cn.hutool.core.lang.tree.TreeNode;
|
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -16,10 +18,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.modules.business.entity.BusBookingRooms;
|
|
import org.jeecg.modules.business.entity.BusBookingRooms;
|
|
|
import org.jeecg.modules.business.entity.BusHotel;
|
|
import org.jeecg.modules.business.entity.BusHotel;
|
|
|
|
|
+import org.jeecg.modules.business.entity.BusRoomPayType;
|
|
|
import org.jeecg.modules.business.enums.BookingOrdersType;
|
|
import org.jeecg.modules.business.enums.BookingOrdersType;
|
|
|
import org.jeecg.modules.business.enums.CheckInTypeEnum;
|
|
import org.jeecg.modules.business.enums.CheckInTypeEnum;
|
|
|
import org.jeecg.modules.business.service.IBusBookingRoomsService;
|
|
import org.jeecg.modules.business.service.IBusBookingRoomsService;
|
|
@@ -27,10 +31,7 @@ import org.jeecg.modules.business.service.impl.BusHotelServiceImpl;
|
|
|
import org.jeecg.modules.rooms.DTO.*;
|
|
import org.jeecg.modules.rooms.DTO.*;
|
|
|
import org.jeecg.modules.rooms.Enum.CouponEnums;
|
|
import org.jeecg.modules.rooms.Enum.CouponEnums;
|
|
|
import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
|
|
import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
|
|
|
-import org.jeecg.modules.rooms.Vo.AlreadyUseLayoutNumberVo;
|
|
|
|
|
-import org.jeecg.modules.rooms.Vo.CanUseBuildingRoomsVo;
|
|
|
|
|
-import org.jeecg.modules.rooms.Vo.CanUseResultVo;
|
|
|
|
|
-import org.jeecg.modules.rooms.Vo.CesRoomsVo;
|
|
|
|
|
|
|
+import org.jeecg.modules.rooms.Vo.*;
|
|
|
import org.jeecg.modules.rooms.entity.*;
|
|
import org.jeecg.modules.rooms.entity.*;
|
|
|
import org.jeecg.modules.rooms.mapper.CesRoomsMapper;
|
|
import org.jeecg.modules.rooms.mapper.CesRoomsMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -54,13 +55,13 @@ import java.util.stream.Collectors;
|
|
|
public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> implements IService<CesRooms> {
|
|
public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> implements IService<CesRooms> {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
- private CesRoomsMapper roomsMapper;
|
|
|
|
|
|
|
+ private CesRoomsMapper roomsMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private BusHotelServiceImpl busHotelService;
|
|
private BusHotelServiceImpl busHotelService;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
- private CesRoomBuildingFloorServiceImpl buildingFloorService;
|
|
|
|
|
|
|
+ private CesRoomBuildingFloorServiceImpl buildingFloorService;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private CesRoomLayoutServiceImpl layoutService;
|
|
private CesRoomLayoutServiceImpl layoutService;
|
|
@@ -76,69 +77,71 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询房间
|
|
* 查询房间
|
|
|
|
|
+ *
|
|
|
* @param dto
|
|
* @param dto
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public Result list(CesRoomSearchDto dto){
|
|
|
|
|
|
|
+ public Result list(CesRoomSearchDto dto) {
|
|
|
|
|
|
|
|
QueryWrapper<CesRooms> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<CesRooms> queryWrapper = new QueryWrapper<>();
|
|
|
- if(!StringUtils.isBlank(dto.getBuildId())){
|
|
|
|
|
- queryWrapper.eq(CesRooms.BUILD_ID,dto.getBuildId());
|
|
|
|
|
|
|
+ if (!StringUtils.isBlank(dto.getBuildId())) {
|
|
|
|
|
+ queryWrapper.eq(CesRooms.BUILD_ID, dto.getBuildId());
|
|
|
}
|
|
}
|
|
|
- if(!StringUtils.isBlank(dto.getFloorId())){
|
|
|
|
|
- queryWrapper.eq(CesRooms.FLOOR_ID,dto.getFloorId());
|
|
|
|
|
|
|
+ if (!StringUtils.isBlank(dto.getFloorId())) {
|
|
|
|
|
+ queryWrapper.eq(CesRooms.FLOOR_ID, dto.getFloorId());
|
|
|
}
|
|
}
|
|
|
- if(!StringUtils.isBlank(dto.getHotelId())){
|
|
|
|
|
|
|
+ if (!StringUtils.isBlank(dto.getHotelId())) {
|
|
|
// List<String> hotelIds = Arrays.stream(dto.getHotelId().split(",")).collect(Collectors.toList());
|
|
// List<String> hotelIds = Arrays.stream(dto.getHotelId().split(",")).collect(Collectors.toList());
|
|
|
- queryWrapper.eq(CesRooms.HOTEL_ID, dto.getHotelId());
|
|
|
|
|
|
|
+ queryWrapper.eq(CesRooms.HOTEL_ID, dto.getHotelId());
|
|
|
}
|
|
}
|
|
|
- queryWrapper.eq(CesRooms.INVALID,false);
|
|
|
|
|
|
|
+ queryWrapper.eq(CesRooms.INVALID, false);
|
|
|
queryWrapper.orderByDesc(CesRooms.SORT, CesRooms.CREATEAT);
|
|
queryWrapper.orderByDesc(CesRooms.SORT, CesRooms.CREATEAT);
|
|
|
- IPage<CesRooms> dataPage = roomsMapper.selectPage(new Page<>(dto.getPageNo().intValue(),dto.getPageSize().intValue()),queryWrapper);
|
|
|
|
|
|
|
+ IPage<CesRooms> dataPage = roomsMapper.selectPage(new Page<>(dto.getPageNo().intValue(), dto.getPageSize().intValue()), queryWrapper);
|
|
|
List<CesRooms> records = dataPage.getRecords();
|
|
List<CesRooms> records = dataPage.getRecords();
|
|
|
- Map<String,Object> map = new HashedMap();
|
|
|
|
|
|
|
+ Map<String, Object> map = new HashedMap();
|
|
|
|
|
|
|
|
- if(!CollectionUtil.isEmpty(records)){
|
|
|
|
|
|
|
+ if (!CollectionUtil.isEmpty(records)) {
|
|
|
|
|
|
|
|
- List<String> hotelIds = records.stream().map(v -> v.getHotelId()).collect(Collectors.toList());
|
|
|
|
|
- List<String> buildIds = records.stream().map(v -> v.getBuildId()).collect(Collectors.toList());
|
|
|
|
|
- List<String> floorIds = records.stream().map(v -> v.getFloorId()).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<String> hotelIds = records.stream().map(v -> v.getHotelId()).collect(Collectors.toList());
|
|
|
|
|
+ List<String> buildIds = records.stream().map(v -> v.getBuildId()).collect(Collectors.toList());
|
|
|
|
|
+ List<String> floorIds = records.stream().map(v -> v.getFloorId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
- List<BusHotel> busHotels = busHotelService.findHotelsByIds(hotelIds);
|
|
|
|
|
- buildIds.addAll(floorIds);
|
|
|
|
|
- List<CesRoomBuildingFloor> buildingFloors = buildingFloorService.getBuildFloorsByIds(buildIds);
|
|
|
|
|
|
|
+ List<BusHotel> busHotels = busHotelService.findHotelsByIds(hotelIds);
|
|
|
|
|
+ buildIds.addAll(floorIds);
|
|
|
|
|
+ List<CesRoomBuildingFloor> buildingFloors = buildingFloorService.getBuildFloorsByIds(buildIds);
|
|
|
|
|
|
|
|
- List<CesRoomsVo> result = new ArrayList<>();
|
|
|
|
|
|
|
+ List<CesRoomsVo> result = new ArrayList<>();
|
|
|
|
|
|
|
|
- records.forEach(v -> {
|
|
|
|
|
- CesRoomsVo vo = new CesRoomsVo();
|
|
|
|
|
- BeanUtil.copyProperties(v,vo);
|
|
|
|
|
|
|
+ records.forEach(v -> {
|
|
|
|
|
+ CesRoomsVo vo = new CesRoomsVo();
|
|
|
|
|
+ BeanUtil.copyProperties(v, vo);
|
|
|
|
|
|
|
|
- Optional<BusHotel> hotelOptional = busHotels.stream().filter(h -> h.getId().equals(v.getHotelId())).findFirst();
|
|
|
|
|
- if (hotelOptional.isPresent()) vo.setHotelName(hotelOptional.get().getName());
|
|
|
|
|
|
|
+ Optional<BusHotel> hotelOptional = busHotels.stream().filter(h -> h.getId().equals(v.getHotelId())).findFirst();
|
|
|
|
|
+ if (hotelOptional.isPresent()) vo.setHotelName(hotelOptional.get().getName());
|
|
|
|
|
|
|
|
- Optional<CesRoomBuildingFloor> buildingOptional = buildingFloors.stream().filter(b -> b.getId().equals(v.getBuildId())).findFirst();
|
|
|
|
|
- if (buildingOptional.isPresent()) vo.setBuildName(buildingOptional.get().getName());
|
|
|
|
|
|
|
+ Optional<CesRoomBuildingFloor> buildingOptional = buildingFloors.stream().filter(b -> b.getId().equals(v.getBuildId())).findFirst();
|
|
|
|
|
+ if (buildingOptional.isPresent()) vo.setBuildName(buildingOptional.get().getName());
|
|
|
|
|
|
|
|
- Optional<CesRoomBuildingFloor> floorOptional = buildingFloors.stream().filter(b -> b.getId().equals(v.getFloorId())).findFirst();
|
|
|
|
|
- if (floorOptional.isPresent()) vo.setFloorName(floorOptional.get().getName());
|
|
|
|
|
|
|
+ Optional<CesRoomBuildingFloor> floorOptional = buildingFloors.stream().filter(b -> b.getId().equals(v.getFloorId())).findFirst();
|
|
|
|
|
+ if (floorOptional.isPresent()) vo.setFloorName(floorOptional.get().getName());
|
|
|
|
|
|
|
|
- result.add(vo);
|
|
|
|
|
- });
|
|
|
|
|
- map.put("records",result);
|
|
|
|
|
- }else{
|
|
|
|
|
- map.put("records",records);
|
|
|
|
|
- }
|
|
|
|
|
- map.put("total",dataPage.getTotal());
|
|
|
|
|
|
|
+ result.add(vo);
|
|
|
|
|
+ });
|
|
|
|
|
+ map.put("records", result);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ map.put("records", records);
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("total", dataPage.getTotal());
|
|
|
return Result.OK(map);
|
|
return Result.OK(map);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 创建房间
|
|
* 创建房间
|
|
|
|
|
+ *
|
|
|
* @param roomsDto
|
|
* @param roomsDto
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public Result create(CesRoomsDto roomsDto){
|
|
|
|
|
|
|
+ public Result create(CesRoomsDto roomsDto) {
|
|
|
roomsDto.setCreateAt(LocalDateTime.now());
|
|
roomsDto.setCreateAt(LocalDateTime.now());
|
|
|
roomsDto.setSort(99);
|
|
roomsDto.setSort(99);
|
|
|
roomsDto.setInvalid(false);
|
|
roomsDto.setInvalid(false);
|
|
@@ -148,10 +151,10 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public Result modify(CesRoomsDto roomsDto){
|
|
|
|
|
- CesRooms room = baseMapper.selectOne(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getId, roomsDto.getId()).eq(CesRooms::getInvalid,false));
|
|
|
|
|
- if(ObjectUtils.isEmpty(room)) return Result.ok("数据未找到!");
|
|
|
|
|
- BeanUtil.copyProperties(roomsDto,room, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
|
|
|
|
|
|
|
+ public Result modify(CesRoomsDto roomsDto) {
|
|
|
|
|
+ CesRooms room = baseMapper.selectOne(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getId, roomsDto.getId()).eq(CesRooms::getInvalid, false));
|
|
|
|
|
+ if (ObjectUtils.isEmpty(room)) return Result.ok("数据未找到!");
|
|
|
|
|
+ BeanUtil.copyProperties(roomsDto, room, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
|
|
|
room.setUpdateAt(LocalDateTime.now());
|
|
room.setUpdateAt(LocalDateTime.now());
|
|
|
roomsMapper.updateById(room);
|
|
roomsMapper.updateById(room);
|
|
|
return Result.ok("修改成功!");
|
|
return Result.ok("修改成功!");
|
|
@@ -159,21 +162,22 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 前端删除一个
|
|
* 前端删除一个
|
|
|
|
|
+ *
|
|
|
* @param id
|
|
* @param id
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public Result deleteOne(String id){
|
|
|
|
|
- CesRooms rooms = roomsMapper.selectOne(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getId,id).eq(CesRooms::getInvalid,false));
|
|
|
|
|
- if(ObjectUtils.isEmpty(rooms)) return Result.ok("删除成功!");
|
|
|
|
|
- rooms.setInvalid(true);
|
|
|
|
|
- rooms.setUpdateAt(LocalDateTime.now());
|
|
|
|
|
- roomsMapper.updateById(rooms);
|
|
|
|
|
- return Result.ok("删除成功!");
|
|
|
|
|
|
|
+ public Result deleteOne(String id) {
|
|
|
|
|
+ CesRooms rooms = roomsMapper.selectOne(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getId, id).eq(CesRooms::getInvalid, false));
|
|
|
|
|
+ if (ObjectUtils.isEmpty(rooms)) return Result.ok("删除成功!");
|
|
|
|
|
+ rooms.setInvalid(true);
|
|
|
|
|
+ rooms.setUpdateAt(LocalDateTime.now());
|
|
|
|
|
+ roomsMapper.updateById(rooms);
|
|
|
|
|
+ return Result.ok("删除成功!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Result delete(List<String> ids){
|
|
|
|
|
|
|
+ public Result delete(List<String> ids) {
|
|
|
List<CesRooms> rooms = roomsMapper.selectBatchIds(ids);
|
|
List<CesRooms> rooms = roomsMapper.selectBatchIds(ids);
|
|
|
- if(CollectionUtil.isEmpty(rooms)) return Result.ok("删除成功!");
|
|
|
|
|
|
|
+ if (CollectionUtil.isEmpty(rooms)) return Result.ok("删除成功!");
|
|
|
rooms.forEach(v -> {
|
|
rooms.forEach(v -> {
|
|
|
v.setUpdateAt(LocalDateTime.now());
|
|
v.setUpdateAt(LocalDateTime.now());
|
|
|
v.setInvalid(true);
|
|
v.setInvalid(true);
|
|
@@ -183,9 +187,9 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public Result removeAll(String hotelId){
|
|
|
|
|
- List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getHotelId, hotelId).eq(CesRooms::getInvalid,false));
|
|
|
|
|
- if(CollectionUtil.isEmpty(rooms)) return Result.ok("删除成功!");
|
|
|
|
|
|
|
+ public Result removeAll(String hotelId) {
|
|
|
|
|
+ List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getHotelId, hotelId).eq(CesRooms::getInvalid, false));
|
|
|
|
|
+ if (CollectionUtil.isEmpty(rooms)) return Result.ok("删除成功!");
|
|
|
rooms.forEach(v -> {
|
|
rooms.forEach(v -> {
|
|
|
v.setUpdateAt(LocalDateTime.now());
|
|
v.setUpdateAt(LocalDateTime.now());
|
|
|
v.setInvalid(true);
|
|
v.setInvalid(true);
|
|
@@ -197,13 +201,14 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 批量新增楼层房间
|
|
* 批量新增楼层房间
|
|
|
|
|
+ *
|
|
|
* @param batchRoomsDto
|
|
* @param batchRoomsDto
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
- public Result saveBatchRoom(BatchRoomsDto batchRoomsDto){
|
|
|
|
|
|
|
+ public Result saveBatchRoom(BatchRoomsDto batchRoomsDto) {
|
|
|
CesRoomBuildingFloor buildingFloor = buildingFloorService.getBuildFloorById(batchRoomsDto.getBuildId());
|
|
CesRoomBuildingFloor buildingFloor = buildingFloorService.getBuildFloorById(batchRoomsDto.getBuildId());
|
|
|
- if(ObjectUtils.isEmpty(buildingFloor)) return Result.error("楼栋不正确,请重新选择!");
|
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(buildingFloor)) return Result.error("楼栋不正确,请重新选择!");
|
|
|
List<BatchBuildFloorRoomDto> floorRoomsList = batchRoomsDto.getChildren();
|
|
List<BatchBuildFloorRoomDto> floorRoomsList = batchRoomsDto.getChildren();
|
|
|
List<CesRooms> rooms = new ArrayList<>();
|
|
List<CesRooms> rooms = new ArrayList<>();
|
|
|
floorRoomsList.forEach(v -> {
|
|
floorRoomsList.forEach(v -> {
|
|
@@ -234,78 +239,81 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据楼层获取房间数据
|
|
* 根据楼层获取房间数据
|
|
|
|
|
+ *
|
|
|
* @param floorId
|
|
* @param floorId
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public Result queryByFloorId(String floorId){
|
|
|
|
|
- List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getFloorId, floorId).eq(CesRooms::getInvalid,false));
|
|
|
|
|
|
|
+ public Result queryByFloorId(String floorId) {
|
|
|
|
|
+ List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getFloorId, floorId).eq(CesRooms::getInvalid, false));
|
|
|
return Result.OK(rooms);
|
|
return Result.OK(rooms);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据hotelId获取房间数据
|
|
* 根据hotelId获取房间数据
|
|
|
|
|
+ *
|
|
|
* @param hotelId
|
|
* @param hotelId
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public Result queryByHotelId(String hotelId){
|
|
|
|
|
- List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getHotelId, hotelId).eq(CesRooms::getInvalid,false));
|
|
|
|
|
|
|
+ public Result queryByHotelId(String hotelId) {
|
|
|
|
|
+ List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getHotelId, hotelId).eq(CesRooms::getInvalid, false));
|
|
|
return Result.OK(rooms);
|
|
return Result.OK(rooms);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<CesRooms> getByHotelId(String hotelId){
|
|
|
|
|
- List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getHotelId, hotelId).eq(CesRooms::getInvalid,false));
|
|
|
|
|
|
|
+ public List<CesRooms> getByHotelId(String hotelId) {
|
|
|
|
|
+ List<CesRooms> rooms = roomsMapper.selectList(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getHotelId, hotelId).eq(CesRooms::getInvalid, false));
|
|
|
return rooms;
|
|
return rooms;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取能使用的房间
|
|
* 获取能使用的房间
|
|
|
|
|
+ *
|
|
|
* @param param
|
|
* @param param
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public List<CanUseResultVo> getCanUseRooms(CanUseRequestParamDto param) {
|
|
public List<CanUseResultVo> getCanUseRooms(CanUseRequestParamDto param) {
|
|
|
// 获取房型
|
|
// 获取房型
|
|
|
- QueryWrapper<CesRoomLayout> wrappers = Wrappers.<CesRoomLayout>query().eq("hotel_id",param.getHotelId())
|
|
|
|
|
- .eq("invalid",false);
|
|
|
|
|
- if((param.getCancelLayout() == null || !param.getCancelLayout()) && param.getLayoutId() != null && !param.getLayoutId().isEmpty()) {
|
|
|
|
|
- wrappers.eq("id",param.getLayoutId());
|
|
|
|
|
|
|
+ QueryWrapper<CesRoomLayout> wrappers = Wrappers.<CesRoomLayout>query().eq("hotel_id", param.getHotelId())
|
|
|
|
|
+ .eq("invalid", false);
|
|
|
|
|
+ if ((param.getCancelLayout() == null || !param.getCancelLayout()) && param.getLayoutId() != null && !param.getLayoutId().isEmpty()) {
|
|
|
|
|
+ wrappers.eq("id", param.getLayoutId());
|
|
|
}
|
|
}
|
|
|
- List<CesRoomLayout> layouts = layoutService.list(wrappers);
|
|
|
|
|
- List<CesRooms> allRooms = baseMapper.canUseRooms(param.getHotelId(),param.getStartOf(),param.getEndOf());
|
|
|
|
|
- List<AlreadyUseLayoutNumberVo> useLayoutNumbers = baseMapper.alreadyUseLayoutNumber(param.getHotelId(),param.getStartOf(),param.getEndOf());
|
|
|
|
|
- List<CesRoomBuildingFloor> allBuildingFloors = buildingFloorService.list(Wrappers.<CesRoomBuildingFloor>query().eq("hotelId",param.getHotelId()).eq("invalid",false));
|
|
|
|
|
- List<CanUseResultVo> results = new ArrayList<>();
|
|
|
|
|
- List<CesRoomBuildingFloor> floors = allBuildingFloors.stream().filter(s->!s.getParentId().equals("0")).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<CesRoomLayout> layouts = layoutService.list(wrappers);
|
|
|
|
|
+ List<CesRooms> allRooms = baseMapper.canUseRooms(param.getHotelId(), param.getStartOf(), param.getEndOf());
|
|
|
|
|
+ List<AlreadyUseLayoutNumberVo> useLayoutNumbers = baseMapper.alreadyUseLayoutNumber(param.getHotelId(), param.getStartOf(), param.getEndOf());
|
|
|
|
|
+ List<CesRoomBuildingFloor> allBuildingFloors = buildingFloorService.list(Wrappers.<CesRoomBuildingFloor>query().eq("hotelId", param.getHotelId()).eq("invalid", false));
|
|
|
|
|
+ List<CanUseResultVo> results = new ArrayList<>();
|
|
|
|
|
+ List<CesRoomBuildingFloor> floors = allBuildingFloors.stream().filter(s -> !s.getParentId().equals("0")).collect(Collectors.toList());
|
|
|
|
|
|
|
|
BigDecimal hourPrice = null;
|
|
BigDecimal hourPrice = null;
|
|
|
List<String> relationHourRoomLayoutIds = new ArrayList<>();
|
|
List<String> relationHourRoomLayoutIds = new ArrayList<>();
|
|
|
- if(param.getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
|
|
|
|
|
- if(param.getHourRoomRuleId()==null)
|
|
|
|
|
- throw new JeecgBootException("参数错误");
|
|
|
|
|
- CesHourRoomRule hourRoomRule = hourRoomRuleService.getById(param.getHourRoomRuleId());
|
|
|
|
|
- if(hourRoomRule == null) throw new JeecgBootException("钟点房计费规则未找到");
|
|
|
|
|
- if(hourRoomRule.getLayoutIds()!=null && !hourRoomRule.getLayoutIds().isEmpty()){
|
|
|
|
|
- relationHourRoomLayoutIds.addAll(Arrays.stream(hourRoomRule.getLayoutIds().split(",")).collect(Collectors.toList()));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- hourPrice = hourRoomRule.getAfterOpenRoomPay();
|
|
|
|
|
|
|
+ if (param.getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
|
|
|
|
|
+ if (param.getHourRoomRuleId() == null)
|
|
|
|
|
+ throw new JeecgBootException("参数错误");
|
|
|
|
|
+ CesHourRoomRule hourRoomRule = hourRoomRuleService.getById(param.getHourRoomRuleId());
|
|
|
|
|
+ if (hourRoomRule == null) throw new JeecgBootException("钟点房计费规则未找到");
|
|
|
|
|
+ if (hourRoomRule.getLayoutIds() != null && !hourRoomRule.getLayoutIds().isEmpty()) {
|
|
|
|
|
+ relationHourRoomLayoutIds.addAll(Arrays.stream(hourRoomRule.getLayoutIds().split(",")).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ hourPrice = hourRoomRule.getAfterOpenRoomPay();
|
|
|
}
|
|
}
|
|
|
BigDecimal finalHourPrice = hourPrice;
|
|
BigDecimal finalHourPrice = hourPrice;
|
|
|
List<CesRooms> choiceRooms = new ArrayList<>();
|
|
List<CesRooms> choiceRooms = new ArrayList<>();
|
|
|
- if(param.getOrderId() != null && !param.getOrderId().isEmpty()) {
|
|
|
|
|
- List<BusBookingRooms> bookingRooms = bookingRoomsService.list(Wrappers.<BusBookingRooms>query().eq("booking_orders_id",param.getOrderId()));
|
|
|
|
|
- List<String> choiceRoomIds = bookingRooms.stream().map(w->w.getRoomId()).collect(Collectors.toList());
|
|
|
|
|
- choiceRooms = list(Wrappers.<CesRooms>query().in("id",choiceRoomIds));
|
|
|
|
|
|
|
+ if (param.getOrderId() != null && !param.getOrderId().isEmpty()) {
|
|
|
|
|
+ List<BusBookingRooms> bookingRooms = bookingRoomsService.list(Wrappers.<BusBookingRooms>query().eq("booking_orders_id", param.getOrderId()));
|
|
|
|
|
+ List<String> choiceRoomIds = bookingRooms.stream().map(w -> w.getRoomId()).collect(Collectors.toList());
|
|
|
|
|
+ choiceRooms = list(Wrappers.<CesRooms>query().in("id", choiceRoomIds));
|
|
|
}
|
|
}
|
|
|
List<CesRooms> finalChoiceRooms = choiceRooms;
|
|
List<CesRooms> finalChoiceRooms = choiceRooms;
|
|
|
- if(param.getCancelLayout() != null && param.getCancelLayout()) {
|
|
|
|
|
|
|
+ if (param.getCancelLayout() != null && param.getCancelLayout()) {
|
|
|
CanUseResultVo item = new CanUseResultVo();
|
|
CanUseResultVo item = new CanUseResultVo();
|
|
|
final Integer[] canUseRoomCount = {0};
|
|
final Integer[] canUseRoomCount = {0};
|
|
|
List<CanUseBuildingRoomsVo> floorVos = new ArrayList<>();
|
|
List<CanUseBuildingRoomsVo> floorVos = new ArrayList<>();
|
|
|
- floors.forEach(c->{
|
|
|
|
|
- CanUseBuildingRoomsVo floorRoomsVo = new CanUseBuildingRoomsVo();
|
|
|
|
|
- List<CesRooms> floorRooms = allRooms.stream().filter(e->e.getFloorId().equals(c.getId())).collect(Collectors.toList());
|
|
|
|
|
- Optional<CesRoomBuildingFloor> opBuilding = allBuildingFloors.stream().filter(q->q.getId().equals(c.getParentId())).findFirst();
|
|
|
|
|
- if(!opBuilding.isPresent()) return;
|
|
|
|
|
|
|
+ floors.forEach(c -> {
|
|
|
|
|
+ CanUseBuildingRoomsVo floorRoomsVo = new CanUseBuildingRoomsVo();
|
|
|
|
|
+ List<CesRooms> floorRooms = allRooms.stream().filter(e -> e.getFloorId().equals(c.getId())).collect(Collectors.toList());
|
|
|
|
|
+ Optional<CesRoomBuildingFloor> opBuilding = allBuildingFloors.stream().filter(q -> q.getId().equals(c.getParentId())).findFirst();
|
|
|
|
|
+ if (!opBuilding.isPresent()) return;
|
|
|
|
|
|
|
|
floorRoomsVo.setFloorName(c.getName());
|
|
floorRoomsVo.setFloorName(c.getName());
|
|
|
floorRoomsVo.setFloorId(c.getId());
|
|
floorRoomsVo.setFloorId(c.getId());
|
|
@@ -313,11 +321,11 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
floorRoomsVo.setBuildingId(opBuilding.get().getId());
|
|
floorRoomsVo.setBuildingId(opBuilding.get().getId());
|
|
|
canUseRoomCount[0] += floorRooms.size();
|
|
canUseRoomCount[0] += floorRooms.size();
|
|
|
// 设置完size之后添加已用房间 不影响数量
|
|
// 设置完size之后添加已用房间 不影响数量
|
|
|
- List<String> currentFloorRoomIds = floorRooms.stream().map(r->r.getId()).collect(Collectors.toList());
|
|
|
|
|
- List<CesRooms> orderRooms = finalChoiceRooms.stream().filter(y->y.getFloorId().equals(c.getId()) && !currentFloorRoomIds.contains(y.getId())).collect(Collectors.toList());
|
|
|
|
|
- floorRooms.forEach(p->{
|
|
|
|
|
- Optional<CesRoomLayout> opLayout = layouts.stream().filter(i->i.getId().equals(p.getLayoutId())).findFirst();
|
|
|
|
|
- if(opLayout.isPresent()) {
|
|
|
|
|
|
|
+ List<String> currentFloorRoomIds = floorRooms.stream().map(r -> r.getId()).collect(Collectors.toList());
|
|
|
|
|
+ List<CesRooms> orderRooms = finalChoiceRooms.stream().filter(y -> y.getFloorId().equals(c.getId()) && !currentFloorRoomIds.contains(y.getId())).collect(Collectors.toList());
|
|
|
|
|
+ floorRooms.forEach(p -> {
|
|
|
|
|
+ Optional<CesRoomLayout> opLayout = layouts.stream().filter(i -> i.getId().equals(p.getLayoutId())).findFirst();
|
|
|
|
|
+ if (opLayout.isPresent()) {
|
|
|
CesRoomLayout roomLayout = opLayout.get();
|
|
CesRoomLayout roomLayout = opLayout.get();
|
|
|
p.setMarketPrice(roomLayout.getMarketPrice());
|
|
p.setMarketPrice(roomLayout.getMarketPrice());
|
|
|
}
|
|
}
|
|
@@ -329,53 +337,72 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
|
|
|
item.setLayout(null);
|
|
item.setLayout(null);
|
|
|
item.setBuildingRooms(floorVos);
|
|
item.setBuildingRooms(floorVos);
|
|
|
results.add(item);
|
|
results.add(item);
|
|
|
- return results;
|
|
|
|
|
|
|
+ return results;
|
|
|
}
|
|
}
|
|
|
- layouts.forEach(s-> {
|
|
|
|
|
- CanUseResultVo item = new CanUseResultVo();
|
|
|
|
|
- List<CanUseBuildingRoomsVo> floorVos = new ArrayList<>();
|
|
|
|
|
- final Integer[] canUseRoomCount = {0};
|
|
|
|
|
- // 钟点房和全天房计费方案取到对应的价格
|
|
|
|
|
- if(param.getBookingType().equals(CheckInTypeEnum.ALL_DAYS.getKey())) {
|
|
|
|
|
- s.setFavPrice(s.getMarketPrice());
|
|
|
|
|
- } else if(param.getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
|
|
|
|
|
- // 判定是否支持房价方案
|
|
|
|
|
- s.setIsSupportHourRule(relationHourRoomLayoutIds.stream().anyMatch(p->p.equals(s.getId())));
|
|
|
|
|
- s.setFavPrice(finalHourPrice);
|
|
|
|
|
- } else
|
|
|
|
|
- s.setFavPrice(null);
|
|
|
|
|
-
|
|
|
|
|
- floors.forEach(c->{
|
|
|
|
|
- CanUseBuildingRoomsVo floorRoomsVo = new CanUseBuildingRoomsVo();
|
|
|
|
|
- List<CesRooms> floorRooms = allRooms.stream().filter(e->e.getFloorId().equals(c.getId()) && e.getLayoutId().equals(s.getId())).collect(Collectors.toList());
|
|
|
|
|
- Optional<CesRoomBuildingFloor> opBuilding = allBuildingFloors.stream().filter(q->q.getId().equals(c.getParentId())).findFirst();
|
|
|
|
|
- if(!opBuilding.isPresent()) return;
|
|
|
|
|
-
|
|
|
|
|
- floorRoomsVo.setFloorName(c.getName());
|
|
|
|
|
- floorRoomsVo.setFloorId(c.getId());
|
|
|
|
|
- floorRoomsVo.setBuildingName(opBuilding.get().getName());
|
|
|
|
|
- floorRoomsVo.setBuildingId(opBuilding.get().getId());
|
|
|
|
|
- canUseRoomCount[0] += floorRooms.size();
|
|
|
|
|
- // 设置完size之后添加已用房间 不影响数量
|
|
|
|
|
- List<String> currentFloorRoomIds = floorRooms.stream().map(r->r.getId()).collect(Collectors.toList());
|
|
|
|
|
- List<CesRooms> orderRooms = finalChoiceRooms.stream().filter(y->y.getFloorId().equals(c.getId()) && !currentFloorRoomIds.contains(y.getId()) && y.getLayoutId().equals(s.getId())).collect(Collectors.toList());
|
|
|
|
|
- floorRooms.addAll(orderRooms);
|
|
|
|
|
- floorRoomsVo.setFloorRooms(floorRooms);
|
|
|
|
|
- floorVos.add(floorRoomsVo);
|
|
|
|
|
- });
|
|
|
|
|
- // 主要为了排除掉未排房数量
|
|
|
|
|
- Optional<AlreadyUseLayoutNumberVo> alreadyUseLayoutNumberVo = useLayoutNumbers.stream().filter(k->k.getLayoutId().equals(s.getId())).findAny();
|
|
|
|
|
- if(alreadyUseLayoutNumberVo.isPresent()){
|
|
|
|
|
- canUseRoomCount[0] = canUseRoomCount[0] - alreadyUseLayoutNumberVo.get().getUseCount();
|
|
|
|
|
- // 算法如果正确 就不需要下面这步,待检验之前步骤正确性
|
|
|
|
|
- if(canUseRoomCount[0] < 0) canUseRoomCount[0] = 0;
|
|
|
|
|
- }
|
|
|
|
|
- s.setCanUseCount(canUseRoomCount[0]); //设置可用房间数
|
|
|
|
|
- item.setLayout(s);
|
|
|
|
|
- item.setBuildingRooms(floorVos);
|
|
|
|
|
- results.add(item);
|
|
|
|
|
- });
|
|
|
|
|
- return results;
|
|
|
|
|
|
|
+ layouts.forEach(s -> {
|
|
|
|
|
+ CanUseResultVo item = new CanUseResultVo();
|
|
|
|
|
+ List<CanUseBuildingRoomsVo> floorVos = new ArrayList<>();
|
|
|
|
|
+ final Integer[] canUseRoomCount = {0};
|
|
|
|
|
+ // 钟点房和全天房计费方案取到对应的价格
|
|
|
|
|
+ if (param.getBookingType().equals(CheckInTypeEnum.ALL_DAYS.getKey())) {
|
|
|
|
|
+ s.setFavPrice(s.getMarketPrice());
|
|
|
|
|
+ } else if (param.getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
|
|
|
|
|
+ // 判定是否支持房价方案
|
|
|
|
|
+ s.setIsSupportHourRule(relationHourRoomLayoutIds.stream().anyMatch(p -> p.equals(s.getId())));
|
|
|
|
|
+ s.setFavPrice(finalHourPrice);
|
|
|
|
|
+ } else
|
|
|
|
|
+ s.setFavPrice(null);
|
|
|
|
|
+
|
|
|
|
|
+ floors.forEach(c -> {
|
|
|
|
|
+ CanUseBuildingRoomsVo floorRoomsVo = new CanUseBuildingRoomsVo();
|
|
|
|
|
+ List<CesRooms> floorRooms = allRooms.stream().filter(e -> e.getFloorId().equals(c.getId()) && e.getLayoutId().equals(s.getId())).collect(Collectors.toList());
|
|
|
|
|
+ Optional<CesRoomBuildingFloor> opBuilding = allBuildingFloors.stream().filter(q -> q.getId().equals(c.getParentId())).findFirst();
|
|
|
|
|
+ if (!opBuilding.isPresent()) return;
|
|
|
|
|
+
|
|
|
|
|
+ floorRoomsVo.setFloorName(c.getName());
|
|
|
|
|
+ floorRoomsVo.setFloorId(c.getId());
|
|
|
|
|
+ floorRoomsVo.setBuildingName(opBuilding.get().getName());
|
|
|
|
|
+ floorRoomsVo.setBuildingId(opBuilding.get().getId());
|
|
|
|
|
+ canUseRoomCount[0] += floorRooms.size();
|
|
|
|
|
+ // 设置完size之后添加已用房间 不影响数量
|
|
|
|
|
+ List<String> currentFloorRoomIds = floorRooms.stream().map(r -> r.getId()).collect(Collectors.toList());
|
|
|
|
|
+ List<CesRooms> orderRooms = finalChoiceRooms.stream().filter(y -> y.getFloorId().equals(c.getId()) && !currentFloorRoomIds.contains(y.getId()) && y.getLayoutId().equals(s.getId())).collect(Collectors.toList());
|
|
|
|
|
+ floorRooms.addAll(orderRooms);
|
|
|
|
|
+ floorRoomsVo.setFloorRooms(floorRooms);
|
|
|
|
|
+ floorVos.add(floorRoomsVo);
|
|
|
|
|
+ });
|
|
|
|
|
+ // 主要为了排除掉未排房数量
|
|
|
|
|
+ Optional<AlreadyUseLayoutNumberVo> alreadyUseLayoutNumberVo = useLayoutNumbers.stream().filter(k -> k.getLayoutId().equals(s.getId())).findAny();
|
|
|
|
|
+ if (alreadyUseLayoutNumberVo.isPresent()) {
|
|
|
|
|
+ canUseRoomCount[0] = canUseRoomCount[0] - alreadyUseLayoutNumberVo.get().getUseCount();
|
|
|
|
|
+ // 算法如果正确 就不需要下面这步,待检验之前步骤正确性
|
|
|
|
|
+ if (canUseRoomCount[0] < 0) canUseRoomCount[0] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ s.setCanUseCount(canUseRoomCount[0]); //设置可用房间数
|
|
|
|
|
+ item.setLayout(s);
|
|
|
|
|
+ item.setBuildingRooms(floorVos);
|
|
|
|
|
+ results.add(item);
|
|
|
|
|
+ });
|
|
|
|
|
+ return results;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 在住来源分组统计
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param hotelId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<LivingSourceStatVo> livingSourceStat(String hotelId) {
|
|
|
|
|
+ return roomsMapper.livingSourceStat(hotelId);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 房态统计
|
|
|
|
|
+ * @param hotelId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<LivingSourceStatVo> roomLiveStat(String hotelId){
|
|
|
|
|
+ return roomsMapper.roomLiveStat(hotelId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|