覃浩 2 rokov pred
rodič
commit
3b0412c2b7

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

@@ -494,6 +494,13 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 }
 
 
+	 @ApiOperation(value="换房", notes="换房")
+	 @RequestMapping(value = "/change-living-room",method = RequestMethod.POST)
+	 public  Result<Boolean> changeRoom(@RequestBody List<BusLivingLayoutDayPrice> prices, String livingOrderId,String changeRoomId) {
+		 return Result.OK(service.changeLivingRoom(prices, livingOrderId, changeRoomId));
+	 }
+
+
 
 
 

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

@@ -74,6 +74,8 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     void syncDayOrderFeeItem(BusRoomsLivingOrder order, CesAllDayPriceRule allDayRule);
     List<BusRoomBookingOrders> countTodayYD(String hotelId);
 
+    Boolean changeLivingRoom(List<BusLivingLayoutDayPrice> prices,String livingOrderId, String roomId);
+
     /**
      * 根据手机号查询入住历史列表
      * @param hotelId

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

@@ -19,9 +19,11 @@ import org.jeecg.modules.business.service.*;
 import org.jeecg.modules.business.util.MxTools;
 import org.jeecg.modules.business.vo.*;
 import org.jeecg.modules.fw.entity.FwRoomClean;
+import org.jeecg.modules.fw.entity.FwRoomExamine;
 import org.jeecg.modules.fw.entity.FwRoomLock;
 import org.jeecg.modules.fw.entity.FwRoomRepair;
 import org.jeecg.modules.fw.service.IFwRoomCleanService;
+import org.jeecg.modules.fw.service.IFwRoomExamineService;
 import org.jeecg.modules.fw.service.IFwRoomLockService;
 import org.jeecg.modules.fw.service.IFwRoomRepairService;
 import org.jeecg.modules.pos.service.IPosJialiaoConfigDetailService;
@@ -126,6 +128,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
     @Resource
     private IFwRoomRepairService fwRoomRepairService;
+
+    @Resource
+    private IFwRoomExamineService fwRoomExamineService;
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam,Boolean isLiving,String hotelId) {
@@ -930,7 +935,14 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         if(customers.size() > 0) livingOrder.setContactId(customers.get(0).getCustomerId());
         roomsLivingOrderService.save(livingOrder);
 
-        
+        // 添加查房记录 start
+        FwRoomExamine examine = new FwRoomExamine();
+        examine.setHotelId(hotelId);
+        examine.setCreateTime(new Date());
+        examine.setLivingOrderId(livingOrder.getId());
+        examine.setRoomId(bkRoom.getRoomId());
+        fwRoomExamineService.save(examine);
+        // 添加查房记录 end
 
         CesRooms room = roomsService.getById(bkRoom.getRoomId());
         if(room==null) throw new JeecgBootException("房间不存在");
@@ -2346,4 +2358,36 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return "";
     }
 
+    // 换房
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean changeLivingRoom(List<BusLivingLayoutDayPrice> prices,String livingOrderId, String roomId) {
+        if(prices == null || prices.size() == 0) throw new JeecgBootException("请传入房价");
+        BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(livingOrderId);
+        if(livingOrder == null) throw  new JeecgBootException("入住记录不存在");
+        BusBookingRooms bkRoom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
+        if(bkRoom == null) throw new JeecgBootException("入住房间记录不存在");
+        CesRooms origLivingRoom = roomsService.getById(bkRoom.getRoomId());
+        if(origLivingRoom == null) throw new JeecgBootException("原房间不存在");
+        CesRooms changeRoom = roomsService.getById(roomId);
+        if(changeRoom == null) throw new JeecgBootException("更换房间不存在");
+        bkRoom.setRoomId(changeRoom.getId());
+        bkRoom.setLayoutId(changeRoom.getLayoutId());
+        bookingRoomsService.updateById(bkRoom);
+        origLivingRoom.setRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
+        roomsService.updateById(origLivingRoom);
+        changeRoom.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
+        roomsService.updateById(changeRoom);
+        livingLayoutDayPriceService.remove(Wrappers.<BusLivingLayoutDayPrice>query().eq("living_order_id",livingOrderId));
+        prices.forEach(s->{
+            s.setRoomLayoutId(changeRoom.getLayoutId());
+            s.setRoomId(changeRoom.getId());
+            s.setLivingType(1);
+            s.setLivingOrderId(livingOrderId);
+        });
+        livingLayoutDayPriceService.saveBatch(prices);
+
+        return true;
+    }
+
 }