Bläddra i källkod

用户入住、退房房态状态更新

wangzhengliang 3 år sedan
förälder
incheckning
9f80afcd69

+ 12 - 0
src/main/java/com/chuanghai/ihotel/service/RoomRealtimeStatuService.java

@@ -53,5 +53,17 @@ public interface RoomRealtimeStatuService extends IService<RoomRealtimeStatuEnti
      * @return
      */
     List<RoomRealDataStatuVO> realData(RoomRealtimeStatuRequest request);
+
+    /**
+     * 用户入住,更新状态为入住状态
+     * @param orderId
+     */
+    void userHoldOrder(Long orderId);
+
+    /**
+     * 用户退房,更新状态为脏房状态
+     * @param orderId
+     */
+    void userReturnOrder(Long orderId);
 }
 

+ 6 - 0
src/main/java/com/chuanghai/ihotel/service/impl/HotelOrderServiceImpl.java

@@ -498,6 +498,9 @@ public class HotelOrderServiceImpl extends ServiceImpl<HotelOrderDao, HotelOrder
         // 门锁密码
         doorLockService.generatePassword(order);
 
+        // 更新房态状态
+        roomRealtimeStatuService.userHoldOrder(orderId);
+
         // 更新订单状态
         UpdateWrapper<HotelOrderEntity> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", orderId);
@@ -523,6 +526,9 @@ public class HotelOrderServiceImpl extends ServiceImpl<HotelOrderDao, HotelOrder
         // 密码锁密码删除
         roomDoorLockDataService.deleteByOrderId(orderId);
 
+        // 更新房态状态
+        roomRealtimeStatuService.userReturnOrder(orderId);
+
         // 更新订单状态
         UpdateWrapper<HotelOrderEntity> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", orderId);

+ 26 - 0
src/main/java/com/chuanghai/ihotel/service/impl/RoomRealtimeStatuServiceImpl.java

@@ -153,6 +153,32 @@ public class RoomRealtimeStatuServiceImpl extends ServiceImpl<RoomRealtimeStatuD
         return result;
     }
 
+    @Override
+    public void userHoldOrder(Long orderId) {
+        RoomRealtimeStatuEntity realtimeStatuEntity = findByBizId(orderId);
+        if (realtimeStatuEntity == null) {
+            throw new RRException(BizCodeEnume.UNKNOW_EXCEPTION, "房源锁定异常");
+        }
+
+        realtimeStatuEntity.setStatu("3");
+        this.updateById(realtimeStatuEntity);
+    }
+
+    @Override
+    public void userReturnOrder(Long orderId) {
+        RoomRealtimeStatuEntity roomRealtimeStatuEntity = findByBizId(orderId);
+        if (roomRealtimeStatuEntity == null) return;
+        roomRealtimeStatuEntity.setStatu("4");
+        this.updateById(roomRealtimeStatuEntity);
+    }
+
+    private RoomRealtimeStatuEntity findByBizId(Long bizId) {
+        QueryWrapper<RoomRealtimeStatuEntity> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("biz_id", bizId);
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
     /**
      * 随机根据房型选房
      * @param lockRoomDTO 锁房参数