|
@@ -1239,7 +1239,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean unionOrder(String roomId, String bookingOrderId) {
|
|
|
|
|
|
|
+ public Boolean unionOrder(String roomId,String targetRoomId, String bookingOrderId) {
|
|
|
CesRooms room = roomsService.getById(roomId);
|
|
CesRooms room = roomsService.getById(roomId);
|
|
|
if(room == null) throw new JeecgBootException("房间不存在");
|
|
if(room == null) throw new JeecgBootException("房间不存在");
|
|
|
CesRoomLayout layout = layoutService.getById(room.getLayoutId());
|
|
CesRoomLayout layout = layoutService.getById(room.getLayoutId());
|
|
@@ -1253,8 +1253,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
bookingRooms.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
|
|
bookingRooms.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
|
|
|
bookingRooms.setLayoutId(layout.getId());
|
|
bookingRooms.setLayoutId(layout.getId());
|
|
|
bookingRooms.setRoomLayoutId(layout.getId());
|
|
bookingRooms.setRoomLayoutId(layout.getId());
|
|
|
- if(room.getLivingOrderId() == null || room.getLivingOrderId().isEmpty()) throw new JeecgBootException("非正常入住的订单无法联房");
|
|
|
|
|
- BusRoomsLivingOrder roomLivingOrder = roomsLivingOrderService.getById(room.getLivingOrderId());
|
|
|
|
|
|
|
+ CesRooms livingRoom = roomsService.getById(targetRoomId);
|
|
|
|
|
+ if(livingRoom == null) throw new JeecgBootException("入住房间订单不存在");
|
|
|
|
|
+ if(livingRoom.getLivingOrderId() == null || livingRoom.getLivingOrderId().isEmpty()) throw new JeecgBootException("非正常入住的订单无法联房");
|
|
|
|
|
+ BusRoomsLivingOrder roomLivingOrder = roomsLivingOrderService.getById(livingRoom.getLivingOrderId());
|
|
|
if(!roomLivingOrder.getBookingOrderId().equals(bookingOrderId)) throw new JeecgBootException("订单关联错误");
|
|
if(!roomLivingOrder.getBookingOrderId().equals(bookingOrderId)) throw new JeecgBootException("订单关联错误");
|
|
|
|
|
|
|
|
BusLivingCustomer livingCustomer = livingCustomerService.getOne(Wrappers.<BusLivingCustomer>query().eq("living_order_id",roomLivingOrder.getId()).eq("customer_id",roomLivingOrder.getContactId()));
|
|
BusLivingCustomer livingCustomer = livingCustomerService.getOne(Wrappers.<BusLivingCustomer>query().eq("living_order_id",roomLivingOrder.getId()).eq("customer_id",roomLivingOrder.getContactId()));
|
|
@@ -1272,6 +1274,47 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public Boolean mergeOrder(String mergeLivingOrderId, String livingOrderId) {
|
|
|
|
|
+ BusRoomsLivingOrder mergeLivingOrder = roomsLivingOrderService.getById(mergeLivingOrderId);
|
|
|
|
|
+ if(mergeLivingOrder == null) throw new JeecgBootException("合并的订单不存在");
|
|
|
|
|
+ if(mergeLivingOrder.getSettleType().equals(SettleTypeEnum.SETTLE_LEAVE.getKey())) throw new JeecgBootException("结账退房的订单无法合并");
|
|
|
|
|
+ BusBookingRooms bookingRooms = bookingRoomsService.getById(mergeLivingOrder.getBookingRoomId());
|
|
|
|
|
+ List<BusRoomsLivingOrder> needMergeLivingOrders = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(livingOrderId);
|
|
|
|
|
+ if(bookingRooms.getIsMain()){
|
|
|
|
|
+ List<BusRoomsLivingOrder> relationOtherLivingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
|
|
|
+ .eq("booking_order_id", bookingRooms.getBookingOrdersId()));
|
|
|
|
|
+ List<String> bookingRoomIds = relationOtherLivingOrders.stream().map(s->s.getBookingRoomId()).collect(Collectors.toList());
|
|
|
|
|
+ List<BusBookingRooms> bookingRoomsList = bookingRoomsService.list(Wrappers.<BusBookingRooms>query().in("id",bookingRoomIds));
|
|
|
|
|
+ bookingRoomsList.forEach(s->{
|
|
|
|
|
+ s.setIsMain(false);
|
|
|
|
|
+ s.setBookingOrdersId(livingOrder.getBookingOrderId());
|
|
|
|
|
+ });
|
|
|
|
|
+ bookingRoomsService.updateBatchById(bookingRoomsList);
|
|
|
|
|
+ needMergeLivingOrders.addAll(relationOtherLivingOrders);
|
|
|
|
|
+
|
|
|
|
|
+ BusBookingRooms mainBkRoom = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query().eq("booking_order_id",bookingRooms.getBookingOrdersId()));
|
|
|
|
|
+ if(mainBkRoom != null) mainBkRoom.setIsMain(true);
|
|
|
|
|
+ bookingRoomsService.updateById(mainBkRoom); // 设置预约的主房
|
|
|
|
|
+ } else {
|
|
|
|
|
+ needMergeLivingOrders.add(mergeLivingOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ needMergeLivingOrders.forEach(s->{
|
|
|
|
|
+ s.setBeforeMergeBookingOrderId(s.getBookingOrderId());
|
|
|
|
|
+ s.setBookingOrderId(mergeLivingOrder.getBookingOrderId());
|
|
|
|
|
+ });
|
|
|
|
|
+ roomsLivingOrderService.updateBatchById(needMergeLivingOrders);
|
|
|
|
|
+
|
|
|
|
|
+// CesRooms mergeRoom = roomsService.getById(livingRoomId);
|
|
|
|
|
+// if(mergeRoom == null) throw new JeecgBootException("房间不存在");
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
String getBookingRoomHotelId(BusBookingRooms bookingRoom) {
|
|
String getBookingRoomHotelId(BusBookingRooms bookingRoom) {
|
|
|
return roomsService.getById(bookingRoom.getRoomId()).getHotelId();
|
|
return roomsService.getById(bookingRoom.getRoomId()).getHotelId();
|
|
|
}
|
|
}
|