qh il y a 2 ans
Parent
commit
5738cf29f5

+ 12 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusRoomBookingOrdersController.java

@@ -378,8 +378,18 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	  */
 	 @ApiOperation(value="酒店预定订单-添加联房", notes="酒店预定订单-添加联房")
 	 @RequestMapping(value = "/union-order",method = RequestMethod.POST)
-	 public Result<Boolean> unionOrder(String roomId,String bookingOrderId) {
-	 	return Result.OK(service.unionOrder(roomId,bookingOrderId));
+	 public Result<Boolean> unionOrder(String roomId,String targetRoomId,String bookingOrderId) {
+	 	return Result.OK(service.unionOrder(roomId,targetRoomId,bookingOrderId));
+	 }
+
+	 /**
+	  * 合并联房
+	  * @return
+	  */
+	 @ApiOperation(value="酒店预定订单-合并联房", notes="酒店预定订单-合并联房")
+	 @RequestMapping(value = "/union-order",method = RequestMethod.POST)
+	 public Result<Boolean> mergeOrder(String livingRoomId,String livingOrderId){
+	 	return  Result.OK(service.mergeOrder(livingRoomId,livingOrderId));
 	 }
 
 

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusRoomsLivingOrder.java

@@ -190,6 +190,11 @@ public class BusRoomsLivingOrder implements Serializable {
     @ApiModelProperty(value = "预约单id")
 	private String bookingOrderId;
 
+    /**预约单id 合并之前原始BOOKING*/
+    @Excel(name = "合并之前原始BOOKING", width = 15)
+    @ApiModelProperty(value = "合并之前原始BOOKING")
+    private String beforeMergeBookingOrderId;
+
     /**定价房间id*/
     @Excel(name = "定价房间id", width = 15)
     @ApiModelProperty(value = "定价房间id")

+ 2 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusRoomBookingOrdersService.java

@@ -62,6 +62,7 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
 
     IPage<RoomLivingQueryVo> getLivingPageData(Integer status,String keyw, Page<RoomLivingQueryVo> page);
     Boolean setLivingOrderFee(List<BusOrderFee> fees,String livingOrderId);
-    Boolean unionOrder(String roomId, String bookingOrderId);
+    Boolean unionOrder(String roomId,String targetRoomId, String bookingOrderId);
+    Boolean mergeOrder(String livingRoomId, String livingOrderId);
 
 }

+ 46 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusRoomBookingOrdersServiceImpl.java

@@ -1239,7 +1239,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
     @Override
     @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);
         if(room == null) throw new JeecgBootException("房间不存在");
         CesRoomLayout layout = layoutService.getById(room.getLayoutId());
@@ -1253,8 +1253,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         bookingRooms.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
         bookingRooms.setLayoutId(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("订单关联错误");
 
         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;
     }
 
+    @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) {
         return roomsService.getById(bookingRoom.getRoomId()).getHotelId();
     }