zhwl/zhwl-business/zhwl-hotel-homestay/target/classes/mapper/hotelhomestay/ZdyHotelHomestayRoomMapper.xml
2025-07-01 17:54:58 +08:00

418 lines
17 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhwl.hotel.homestay.mapper.ZdyHotelHomestayRoomMapper">
<resultMap type="ZdyHotelHomestayRoom" id="ZdyHotelHomestayRoomResult">
<result property="id" column="id"/>
<result property="hotelHomestayId" column="hotel_homestay_id"/>
<result property="hotelHomestayRoomClassifyId" column="hotel_homestay_room_classify_id"/>
<result property="quantity" column="quantity"/>
<result property="number" column="number"/>
<result property="label" column="label"/>
<result property="delFlag" column="del_flag"/>
<result property="deptId" column="dept_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<resultMap type="ZdyHotelHomestayRoomVO" id="ZdyHotelHomestayRoomVOResult">
<result property="id" column="id"/>
<result property="hotelHomestayId" column="hotel_homestay_id"/>
<result property="hotelHomestayRoomClassifyId" column="hotel_homestay_room_classify_id"/>
<result property="quantity" column="quantity"/>
<result property="number" column="number"/>
<result property="label" column="label"/>
<result property="image" column="image"/>
<result property="weekdayPrice" column="weekday_price"/>
<result property="weekendPrice" column="weekend_price"/>
<result property="limitedLivePerson" column="limited_live_person"/>
<result property="cancelRuleType" column="cancel_rule_type"/>
<result property="cancelRuleContent" column="cancel_rule_content"/>
<result property="area" column="area"/>
<result property="bedType" column="bed_type"/>
<result property="window" column="window"/>
<result property="wifi" column="wifi"/>
<result property="floor" column="floor"/>
<result property="breakfast" column="breakfast"/>
<result property="delFlag" column="del_flag"/>
<result property="deptId" column="dept_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="level1Name" column="level1_name"/>
<result property="level2Name" column="level2_name"/>
</resultMap>
<sql id="selectZdyHotelHomestayRoomVo">
select id,
hotel_homestay_id,
hotel_homestay_room_classify_id,
quantity,
number,
label,
del_flag,
dept_id,
create_by,
create_time,
update_by,
update_time,
remark
from zdy_hotel_homestay_room r
</sql>
<select id="selectZdyHotelHomestayRoomList"
parameterType="com.zhwl.hotel.homestay.domain.dto.ZdyHotelHomestayRoomQueryDTO"
resultMap="ZdyHotelHomestayRoomVOResult">
select r.id,
r.hotel_homestay_id,
r.hotel_homestay_room_classify_id,
r.quantity,
r.number,
r.label,
r.del_flag,
r.dept_id,
r.create_by,
r.create_time,
r.update_by,
r.update_time,
r.remark,
rc.level1_name,
rc.level2_name,
rc.image,
rc.weekday_price,
rc.weekend_price,
rc.limited_live_person,
rc.cancel_rule_type,
rc.cancel_rule_content,
rc.area,
rc.bed_type,
rc.window,
rc.wifi,
rc.floor,
rc.breakfast
from zdy_hotel_homestay_room r
left join zdy_hotel_homestay_room_classify rc
on r.dept_id = rc.dept_id
and r.hotel_homestay_id = rc.hotel_homestay_id
and r.hotel_homestay_room_classify_id = rc.id
<where>
and r.del_flag = '0'
<if test="hotelHomestayId != null ">
and r.hotel_homestay_id = #{hotelHomestayId}
</if>
<if test="hotelHomestayRoomClassifyId != null ">
and r.hotel_homestay_room_classify_id = #{hotelHomestayRoomClassifyId}
</if>
<if test="quantity != null and quantity != ''">
and r.quantity = #{quantity}
</if>
<if test="number != null and number != ''">
and r.number = #{number}
</if>
<if test="label != null">
and r.label = #{label}
</if>
<if test="deptId != null ">
and r.dept_id = #{deptId}
</if>
<if test="level1Name != null and level1Name != ''">
and rc.level1_name like concat('%', #{level1Name}, '%')
</if>
<if test="level2Name != null and level2Name != ''">
and rc.level2_name like concat('%', #{level2Name}, '%')
</if>
<if test="floor != null and floor != ''">
and rc.floor = #{floor}
</if>
${params.dataScope}
</where>
order by r.number asc, rc.level1_name asc, rc.level2_name asc
</select>
<select id="selectZdyHotelHomestayRoomById" parameterType="Long"
resultMap="ZdyHotelHomestayRoomResult">
<include refid="selectZdyHotelHomestayRoomVo"/>
where r.id = #{id} and r.del_flag = '0'
</select>
<select id="selectZdyHotelHomestayRoomByIds" parameterType="Long"
resultMap="ZdyHotelHomestayRoomVOResult">
select r.id,
r.hotel_homestay_id,
r.hotel_homestay_room_classify_id,
r.quantity,
r.number,
r.label,
r.del_flag,
r.dept_id,
r.create_by,
r.create_time,
r.update_by,
r.update_time,
r.remark,
rc.level1_name,
rc.level2_name,
rc.image,
rc.weekday_price,
rc.weekend_price,
rc.limited_live_person,
rc.cancel_rule_type,
rc.cancel_rule_content,
rc.area,
rc.bed_type,
rc.window,
rc.wifi,
rc.floor,
rc.breakfast
from zdy_hotel_homestay_room r
left join zdy_hotel_homestay_room_classify rc
on r.dept_id = rc.dept_id
and r.hotel_homestay_id = rc.hotel_homestay_id
and r.hotel_homestay_room_classify_id = rc.id
<where>
r.del_flag = '0'
<if test="ids !=null and ids.size()>0">
and r.id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
</select>
<insert id="insertZdyHotelHomestayRoom" parameterType="ZdyHotelHomestayRoom" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_hotel_homestay_room
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="hotelHomestayId != null">hotel_homestay_id,
</if>
<if test="hotelHomestayRoomClassifyId != null">hotel_homestay_room_classify_id,
</if>
<if test="quantity != null and quantity != ''">
quantity,
</if>
<if test="number != null and number != ''">number,
</if>
<if test="label != null and label != ''">label,
</if>
<if test="delFlag != null and delFlag != ''">del_flag,
</if>
<if test="deptId != null">dept_id,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="remark != null">remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="hotelHomestayId != null">#{hotelHomestayId},
</if>
<if test="hotelHomestayRoomClassifyId != null">#{hotelHomestayRoomClassifyId},
</if>
<if test="quantity != null and quantity != ''">
#{quantity},
</if>
<if test="number != null and number != ''">#{number},
</if>
<if test="label != null and label != ''">#{label},
</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},
</if>
<if test="deptId != null">#{deptId},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="remark != null">#{remark},
</if>
</trim>
</insert>
<update id="updateZdyHotelHomestayRoom" parameterType="ZdyHotelHomestayRoom">
update zdy_hotel_homestay_room
<trim prefix="SET" suffixOverrides=",">
<if test="hotelHomestayId != null">hotel_homestay_id =
#{hotelHomestayId},
</if>
<if test="hotelHomestayRoomClassifyId != null">hotel_homestay_room_classify_id =
#{hotelHomestayRoomClassifyId},
</if>
<if test="quantity != null">quantity =
#{quantity},
</if>
<if test="number != null and number != ''">number =
#{number},
</if>
<if test="label != null and label != ''">label =
#{label},
</if>
<if test="delFlag != null and delFlag != ''">del_flag =
#{delFlag},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="remark != null">remark =
#{remark},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZdyHotelHomestayRoomById" parameterType="Long">
delete
from zdy_hotel_homestay_room
where id = #{id}
</delete>
<delete id="deleteZdyHotelHomestayRoomByIds" parameterType="String">
update zdy_hotel_homestay_room set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectRoomNumberByHotelHomestayId" parameterType="long" resultMap="ZdyHotelHomestayRoomResult">
select id, number
from zdy_hotel_homestay_room
where hotel_homestay_id = #{hotelHomestayId}
and del_flag = '0'
</select>
<select id="selectNumbersByHotelHomestayIdAndRoomClassifyId" parameterType="long"
resultMap="ZdyHotelHomestayRoomResult">
select id, number
from zdy_hotel_homestay_room
where hotel_homestay_id = #{hotelHomestayId}
and hotel_homestay_room_classify_id = #{roomClassifyId}
and del_flag = '0'
</select>
<select id="countByHotelHomestayIdAndRoomClassifyId" parameterType="long" resultType="int">
select count(1)
from zdy_hotel_homestay_room
where hotel_homestay_id = #{hotelHomestayId}
and hotel_homestay_room_classify_id = #{roomClassifyId}
and del_flag = '0'
</select>
<select id="queryAvailableRoom"
parameterType="com.zhwl.hotel.homestay.domain.dto.ZdyHotelHomestayAvailableRoomQueryDTO"
resultMap="ZdyHotelHomestayRoomVOResult">
<![CDATA[
select r.id,
r.hotel_homestay_id,
r.hotel_homestay_room_classify_id,
r.quantity,
r.number,
r.label,
rc.level1_name,
rc.level2_name,
rc.limited_live_person
from zdy_hotel_homestay_room r
left join zdy_hotel_homestay_room_classify rc
on r.dept_id = rc.dept_id
and r.hotel_homestay_id = rc.hotel_homestay_id
and r.hotel_homestay_room_classify_id = rc.id
where r.del_flag = '0'
and r.hotel_homestay_id = #{hotelHomestayId}
and r.id not in
(select distinct rs.room_id
from zdy_hotel_homestay_room_status rs
WHERE (
(
start_time <= CONCAT(DATE_FORMAT(#{startTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{checkInTime}
, '%H:%i:%s')
)
AND end_time >= CONCAT(DATE_FORMAT(#{endTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{leaveTime}
, '%H:%i:%s')))
or
(start_time >= CONCAT(DATE_FORMAT(#{startTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{checkInTime}
, '%H:%i:%s')
)
AND end_time <= CONCAT(DATE_FORMAT(#{endTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{leaveTime}
, '%H:%i:%s')))
or (
start_time <= CONCAT(DATE_FORMAT(#{startTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{checkInTime}
, '%H:%i:%s'))
AND end_time >= CONCAT(DATE_FORMAT(#{startTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{checkInTime}
, '%H:%i:%s')))
or
(start_time <= CONCAT(DATE_FORMAT(#{endTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{leaveTime}
, '%H:%i:%s'))
AND end_time >= CONCAT(DATE_FORMAT(#{endTime}
, '%Y-%m-%d')
, ' '
, TIME_FORMAT(#{leaveTime}
, '%H:%i:%s')))
))
]]>
</select>
<update id="updateLabelByIds">
update zdy_hotel_homestay_room set label = #{label}
where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<delete id="deleteByHomestayIds" parameterType="long">
update zdy_hotel_homestay_room set del_flag = '1' where hotel_homestay_id in
<foreach item="hotelHomestayId" collection="hotelHomestayIds" open="(" separator="," close=")">
#{hotelHomestayId}
</foreach>
</delete>
</mapper>