Browse Source

团客入住功能开发

baiyun 1 year ago
parent
commit
286b9db30f

+ 21 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/controller/KfOrderController.java

@@ -47,13 +47,22 @@ public class KfOrderController extends BaseController {
     }
 
     /**
-     * 根据 guestName 查询散客入住列表
+     * 查询散客信息和散客当前订单信息
      */
     @SaCheckPermission("business:guestOrder:list")
     @GetMapping("/queryListByGuestName")
     public R<List<KfOrderVo>> queryListByGuestName(@RequestParam String guestName) {
         return R.ok(kfOrderService.queryListByGuestName(guestName));
     }
+
+    /**
+     * 查询团客客人信息和当前订单信息
+     */
+    @SaCheckPermission("business:guestOrder:list")
+    @GetMapping("/selectTeamGuest")
+    public R<List<KfOrderVo>> selectTeamLockRoom(@RequestParam Long teamId, @RequestParam String guestName) {
+        return R.ok(kfOrderService.queryTeamGuest(teamId, guestName));
+    }
     /**
      * 导出散客入住列表
      */
@@ -88,6 +97,17 @@ public class KfOrderController extends BaseController {
         return toAjax(kfOrderService.insertByBo(bo));
     }
 
+    /**
+     * 团客锁房指定房间
+     */
+    @SaCheckPermission("business:guestOrder:add")
+    @Log(title = "指定房间", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping("roomAssign")
+    public R<Void> roomAssign(@RequestBody KfOrderBo bo) {
+        return toAjax(kfOrderService.roomAssign(bo));
+    }
+
     /**
      * 修改散客入住
      */

+ 2 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfOrderVo.java

@@ -59,7 +59,8 @@ public class KfOrderVo implements Serializable {
     private String roomCode;
     @ExcelProperty(value = "房间名称")
     private String roomName;
-
+    private String guestRoomType;
+    private Integer bedQuantity;
     /**
      * 入住时间
      */

+ 2 - 0
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/mapper/KfOrderMapper.java

@@ -21,6 +21,8 @@ public interface KfOrderMapper extends BaseMapperPlus<KfOrder, KfOrderVo> {
 
     List<KfOrderVo> queryListByGuestName(String guestName);
 
+    List<KfOrderVo> queryTeamGuest(Long teamId,String guestName);
+
     RemoteOrderVo selectByBo(@Param("bo") KfOrderBo bo);
 
     /** 根据房间code修改房间状态*/

+ 4 - 0
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/IKfOrderService.java

@@ -47,6 +47,9 @@ public interface IKfOrderService {
     List<KfOrderVo> queryCurrentAllOrder(List<String> orderStatus);
 
     List<KfOrderVo> queryListByGuestName(String guestName);
+
+    List<KfOrderVo> queryTeamGuest(Long teamId, String guestName);
+
     /**
      * 新增散客入住
      *
@@ -55,6 +58,7 @@ public interface IKfOrderService {
      */
     Boolean insertByBo(KfOrderBo bo);
 
+    Boolean roomAssign(KfOrderBo bo);
     /**
      * 修改散客入住
      *

+ 33 - 0
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfOrderServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
 import org.dromara.common.core.constant.HotelBusinessConstants;
 import org.dromara.common.core.enums.HotelRoomStatusEnum;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
@@ -20,11 +21,14 @@ import org.dromara.hotel.domain.KfOrder;
 import org.dromara.hotel.domain.bo.KfOrderBo;
 import org.dromara.hotel.domain.vo.KfGuestVo;
 import org.dromara.hotel.domain.vo.KfOrderVo;
+import org.dromara.hotel.domain.vo.KfTeamVo;
 import org.dromara.hotel.domain.vo.OrderAndGuestVo;
 import org.dromara.hotel.mapper.KfGuestMapper;
 import org.dromara.hotel.mapper.KfOrderMapper;
 import org.dromara.hotel.service.IKfOrderService;
+import org.dromara.hotel.service.IKfTeamService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 
@@ -39,6 +43,7 @@ import java.util.*;
 public class KfOrderServiceImpl implements IKfOrderService {
 
     private final KfOrderMapper baseMapper;
+    private final IKfTeamService teamService;
 
     private final KfGuestMapper guestMapper;
 
@@ -100,6 +105,11 @@ public class KfOrderServiceImpl implements IKfOrderService {
         return baseMapper.queryListByGuestName(guestName);
     }
 
+    @Override
+    public List<KfOrderVo> queryTeamGuest(Long teamId, String guestName) {
+        return baseMapper.queryTeamGuest(teamId, guestName);
+    }
+
     private LambdaQueryWrapper<KfOrder> buildQueryWrapper(KfOrderBo bo) {
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<KfOrder> lqw = Wrappers.lambdaQuery();
@@ -159,6 +169,29 @@ public class KfOrderServiceImpl implements IKfOrderService {
         return flag;
     }
 
+    @Override
+    @Transactional
+    public Boolean roomAssign(KfOrderBo bo) {
+        //校验该团客是否已经有预定或者入住状态的订单
+        if (baseMapper.selectCount(new LambdaQueryWrapper<KfOrder>()
+            .eq(KfOrder::getGuestId, bo.getGuestId())
+            .in(KfOrder::getOrderStatus, HotelBusinessConstants.ORDER_STATUS_YD, HotelBusinessConstants.ORDER_STATUS_RZ)) > 0) {
+            throw new ServiceException("该团客已有预定或者入住状态的订单,请先取消或修改订单");
+        }
+        //根据团客ID查询客团信息
+        KfTeamVo teamVo = teamService.queryById(bo.getTeamId());
+        bo.setTeamName(teamVo.getName());
+        bo.setStartTime(teamVo.getStartTime());
+        bo.setEndTime(teamVo.getEndTime());
+        bo.setOrderStatus(HotelBusinessConstants.ORDER_STATUS_YD);
+        bo.setOrderType(HotelBusinessConstants.ORDER_TYPE_TK);
+        //插入订单
+        boolean flag = insertByBo(bo);
+        //修改房间状态为预定
+        baseMapper.updateRoomStatus(bo.getRoomCode(), HotelRoomStatusEnum.YD.code());
+        return flag;
+    }
+
     /**
      * 修改散客入住
      *

+ 39 - 12
ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/business/KfOrderMapper.xml

@@ -30,15 +30,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectPageByBo" resultType="org.dromara.hotel.domain.vo.KfOrderVo">
         select
-        o.id,o.guest_id,g.name as guestName,o.team_id,o.team_name,o.room_code,o.room_name,o.start_time,o.end_time
-             ,o.order_status,o.plan_money,o.actual_money,o.remark,g.phone,g.sex,g.id_card as idCard from t_kf_order o
-        left join
-        t_kf_guest g on o.guest_id = g.id
+            o.id,o.guest_id,g.name as guestName,o.team_id,o.team_name,o.room_code,o.room_name,o.start_time
+            ,o.end_time, o.order_status,o.plan_money,o.actual_money,o.remark,g.phone,g.sex,g.id_card as idCard,
+            rt.room_type_name as guestRoomType, rt.bed_number as bedQuantity, o.order_index as orderIndex
+        from t_kf_order o
+            left join t_kf_guest g on o.guest_id = g.id
+            left join t_pt_room r on r.room_code = o.room_code
+            left join t_pt_room_type rt on r.guest_room_type = rt.room_type_id
         <where>
             o.del_flag = '0'
             <if test="bo.guestName != null and bo.guestName != ''">
                 and g.name like concat('%', #{bo.guestName}, '%')
             </if>
+            <if test="bo.teamId != null and bo.teamId != ''">
+                and o.team_id = #{bo.teamId}
+            </if>
+
             <if test="bo.teamName != null and bo.teamName != ''">
                 and o.team_name like concat('%', #{bo.teamName}, '%')
             </if>
@@ -57,23 +64,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="bo.orderType != null and bo.orderType != ''">
                 and o.order_type = #{bo.orderType}
             </if>
-        order by o.create_time desc
+        order by o.order_index asc, o.create_time desc
         </where>
     </select>
 
     <select id="queryListByGuestName" resultType="org.dromara.hotel.domain.vo.KfOrderVo">
-        select g.id as guestId,
-            concat_ws(' | ',g.name, g.phone, g.id_card, CASE o.order_status
-            WHEN '1' THEN '当前已预定'
-            WHEN '3' THEN '当前已入住'
-            else ''
-            END) AS guestName
+        select g.id as guestId, g.name as guestName,
+                concat('姓名: ',g.name,' | 手机号: ',g.phone, ' | '
+                , CASE o.order_status WHEN '1' THEN '当前已预定' WHEN '3' THEN '当前已入住' else '' END
+                ) AS phone
             from t_kf_guest g left join t_kf_order o on g.id = o.guest_id and o.order_status in ('1','3')
             <where>
                 g.del_flag = '0'
-                and g.name like concat('%', #{guestName}, '%')
+                <if test="guestName != null and guestName != ''">
+                    and g.name like concat('%', #{guestName}, '%')
+                </if>
             </where>
     </select>
+
+    <select id="queryTeamGuest" resultType="org.dromara.hotel.domain.vo.KfOrderVo">
+        select g.id as guestId, g.name as guestName,
+        concat('姓名: ',g.name,' | 手机号: ',g.phone, ' | '
+            , CASE o.order_status WHEN '1' THEN '当前已预定' WHEN '3' THEN '当前已入住' else '' END
+            ) AS phone
+        from t_kf_guest_team_r tgr
+            left join t_kf_guest g on tgr.guest_id = g.id
+            left join t_kf_order o on g.id = o.guest_id and o.order_status in ('1','3')
+        <where>
+            tgr.del_flag = '0'
+            <if test="teamId != null">
+                and tgr.team_id = #{teamId}
+            </if>
+            <if test="guestName != null">
+                and g.name like concat('%', #{guestName}, '%')
+            </if>
+        </where>
+    </select>
+
     <select id="selectByBo" resultType="org.dromara.hotel.api.domain.vo.RemoteOrderVo">
         SELECT tkg.id AS guestId, tkg.name, tkg.sex, tkg.id_card AS idCard, tkg.phone, tkg.other_id AS otherId, tkgtr.team_id AS teamId,
         tko.room_code AS roomCode, tpr.room_id AS roomId, tko.start_time AS checkinDate, tko.end_time AS checkoutDate,