279 lines
12 KiB
XML
279 lines
12 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.cinema.mapper.ZdyCinemaMovieVenueItemMapper">
|
||
|
|
||
|
<resultMap type = "ZdyCinemaMovieVenueItem" id = "ZdyCinemaMovieVenueItemResult">
|
||
|
<result property = "itemId" column = "item_id"/>
|
||
|
<result property = "hallId" column = "hall_id"/>
|
||
|
<result property = "hallName" column = "hallName"/>
|
||
|
<result property = "venueId" column = "venue_id"/>
|
||
|
<result property = "itemBeginTime" column = "item_begin_time"/>
|
||
|
<result property = "itemEndTime" column = "item_end_time"/>
|
||
|
<result property = "itemName" column = "item_name"/>
|
||
|
<result property = "itemRest" column = "item_rest"/>
|
||
|
<result property = "venueSeats" column = "venue_seats"/>
|
||
|
<result property = "seatNums" column = "seat_nums"/>
|
||
|
<result property = "saleNums" column = "sale_nums"/>
|
||
|
<result property = "createTime" column = "create_time"/>
|
||
|
<result property = "createBy" column = "create_by"/>
|
||
|
<result property = "updateTime" column = "update_time"/>
|
||
|
<result property = "updateBy" column = "update_by"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<resultMap type="ZdyCinemaMovieVenueItemDTO" id="ZdyCinemaMovieVenueItemDTOResult">
|
||
|
<result property="itemId" column="item_id"/>
|
||
|
<result property="hallId" column="hall_id"/>
|
||
|
<result property="hallName" column="hallName"/>
|
||
|
<result property="venueId" column="venue_id"/>
|
||
|
<result property="itemBeginTime" column="item_begin_time"/>
|
||
|
<result property="itemEndTime" column="item_end_time"/>
|
||
|
<result property="itemName" column="item_name"/>
|
||
|
<result property="itemRest" column="item_rest"/>
|
||
|
<result property="venueSeats" column="venue_seats"/>
|
||
|
<result property="seatNums" column="seat_nums"/>
|
||
|
<result property="saleNums" column="sale_nums"/>
|
||
|
<result property="venueBeginDate" column="venue_begin_date"/>
|
||
|
<result property="venueEndDate" column="venue_end_date"/>
|
||
|
<result property="venueWeek" column="venue_week"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<sql id = "selectZdyCinemaMovieVenueItemVo">
|
||
|
select item.item_id,
|
||
|
item.hall_id,
|
||
|
item.venue_id,
|
||
|
item.item_begin_time,
|
||
|
item.item_end_time,
|
||
|
item.item_name,
|
||
|
item.item_rest,
|
||
|
item.venue_seats,
|
||
|
item.seat_nums,
|
||
|
item.sale_nums,
|
||
|
hall.hall_name as hallName
|
||
|
from zdy_cinema_movie_venue_item item
|
||
|
left join zdy_cinema_hall hall on hall.hall_id = item.hall_id
|
||
|
</sql>
|
||
|
|
||
|
<select id = "selectZdyCinemaMovieVenueItemList" parameterType = "ZdyCinemaMovieVenueItem" resultMap = "ZdyCinemaMovieVenueItemResult">
|
||
|
<include refid = "selectZdyCinemaMovieVenueItemVo"/>
|
||
|
<where>
|
||
|
<if test = "hallId != null ">
|
||
|
and item.hall_id = #{hallId}
|
||
|
</if>
|
||
|
<if test = "venueId != null ">
|
||
|
and item.venue_id = #{venueId}
|
||
|
</if>
|
||
|
<if test = "itemBeginTime != null and itemBeginTime != ''">
|
||
|
and item.item_begin_time = #{itemBeginTime}
|
||
|
</if>
|
||
|
<if test = "itemEndTime != null and itemEndTime != ''">
|
||
|
and item.item_end_time = #{itemEndTime}
|
||
|
</if>
|
||
|
<if test = "itemName != null and itemName != ''">
|
||
|
and item.item_name like concat('%', #{itemName}, '%')
|
||
|
</if>
|
||
|
<if test = "itemRest != null and itemRest != ''">
|
||
|
and item.item_rest = #{itemRest}
|
||
|
</if>
|
||
|
<if test = "venueRest != null and venueRest != ''">
|
||
|
and item.venue_rest = #{venueRest}
|
||
|
</if>
|
||
|
<if test = "seatNums != null ">
|
||
|
and item.seat_nums = #{seatNums}
|
||
|
</if>
|
||
|
<if test = "saleNums != null ">
|
||
|
and item.sale_nums = #{saleNums}
|
||
|
</if>
|
||
|
</where>
|
||
|
</select>
|
||
|
|
||
|
<select id = "selectZdyCinemaMovieVenueItemByItemId" parameterType = "Long" resultMap = "ZdyCinemaMovieVenueItemResult">
|
||
|
<include refid = "selectZdyCinemaMovieVenueItemVo"/>
|
||
|
where item.item_id = #{itemId}
|
||
|
</select>
|
||
|
|
||
|
<insert id = "insertZdyCinemaMovieVenueItem" parameterType = "ZdyCinemaMovieVenueItem" useGeneratedKeys = "true"
|
||
|
keyProperty = "itemId">
|
||
|
insert into zdy_cinema_movie_venue_item
|
||
|
<trim prefix = "(" suffix = ")" suffixOverrides = ",">
|
||
|
<if test = "hallId != null">hall_id,
|
||
|
</if>
|
||
|
<if test = "venueId != null">venue_id,
|
||
|
</if>
|
||
|
<if test = "itemBeginTime != null">item_begin_time,
|
||
|
</if>
|
||
|
<if test = "itemEndTime != null">item_end_time,
|
||
|
</if>
|
||
|
<if test = "itemName != null">item_name,
|
||
|
</if>
|
||
|
<if test = "itemRest != null">item_rest,
|
||
|
</if>
|
||
|
<if test = "venueSeats != null">venue_seats,
|
||
|
</if>
|
||
|
<if test = "seatNums != null">seat_nums,
|
||
|
</if>
|
||
|
<if test = "saleNums != null">sale_nums,
|
||
|
</if>
|
||
|
<if test = "createTime != null">create_time,</if>
|
||
|
<if test = "createBy != null">create_by,</if>
|
||
|
<if test = "updateTime != null">update_time,</if>
|
||
|
<if test = "updateBy != null">update_by,</if>
|
||
|
</trim>
|
||
|
<trim prefix = "values (" suffix = ")" suffixOverrides = ",">
|
||
|
<if test = "hallId != null">#{hallId},
|
||
|
</if>
|
||
|
<if test = "venueId != null">#{venueId},
|
||
|
</if>
|
||
|
<if test = "itemBeginTime != null">#{itemBeginTime},
|
||
|
</if>
|
||
|
<if test = "itemEndTime != null">#{itemEndTime},
|
||
|
</if>
|
||
|
<if test = "itemName != null">#{itemName},
|
||
|
</if>
|
||
|
<if test = "itemRest != null">#{itemRest},
|
||
|
</if>
|
||
|
<if test = "venueSeats != null">#{venueSeats},
|
||
|
</if>
|
||
|
<if test = "seatNums != null">#{seatNums},
|
||
|
</if>
|
||
|
<if test = "saleNums != null">#{saleNums},
|
||
|
</if>
|
||
|
<if test = "createTime != null">#{createTime},</if>
|
||
|
<if test = "createBy != null">#{createBy},</if>
|
||
|
<if test = "updateTime != null">#{updateTime},</if>
|
||
|
<if test = "updateBy != null">#{updateBy},</if>
|
||
|
</trim>
|
||
|
</insert>
|
||
|
|
||
|
<update id = "updateZdyCinemaMovieVenueItem" parameterType = "ZdyCinemaMovieVenueItem">
|
||
|
update zdy_cinema_movie_venue_item
|
||
|
<trim prefix = "SET" suffixOverrides = ",">
|
||
|
<if test = "hallId != null">hall_id = #{hallId},
|
||
|
</if>
|
||
|
<if test = "venueId != null">venue_id = #{venueId},
|
||
|
</if>
|
||
|
<if test = "itemBeginTime != null">item_begin_time = #{itemBeginTime},
|
||
|
</if>
|
||
|
<if test = "itemEndTime != null">item_end_time = #{itemEndTime},
|
||
|
</if>
|
||
|
<if test = "itemName != null">item_name = #{itemName},
|
||
|
</if>
|
||
|
<if test = "itemRest != null">item_rest = #{itemRest},
|
||
|
</if>
|
||
|
<if test = "venueSeats != null">venue_seats = #{venueSeats},
|
||
|
</if>
|
||
|
<if test = "seatNums != null">seat_nums = #{seatNums},
|
||
|
</if>
|
||
|
<if test = "saleNums != null">sale_nums = #{saleNums},
|
||
|
</if>
|
||
|
<if test = "createTime != null">create_time = #{createTime},</if>
|
||
|
<if test = "createBy != null">create_by = #{createBy},</if>
|
||
|
<if test = "updateTime != null">update_time = #{updateTime},</if>
|
||
|
<if test = "updateBy != null">update_by = #{updateBy},</if>
|
||
|
</trim>
|
||
|
where item_id = #{itemId}
|
||
|
</update>
|
||
|
|
||
|
<delete id = "deleteZdyCinemaMovieVenueItemByItemId" parameterType = "Long">
|
||
|
delete
|
||
|
from zdy_cinema_movie_venue_item
|
||
|
where item_id = #{itemId}
|
||
|
</delete>
|
||
|
|
||
|
<delete id = "deleteZdyCinemaMovieVenueItemByItemIds" parameterType = "String">
|
||
|
delete from zdy_cinema_movie_venue_item where item_id in
|
||
|
<foreach item = "itemId" collection = "array" open = "(" separator = "," close = ")">
|
||
|
#{itemId}
|
||
|
</foreach>
|
||
|
</delete>
|
||
|
|
||
|
<select id = "selectVenueItemListByVenueId" parameterType = "Long" resultMap = "ZdyCinemaMovieVenueItemResult">
|
||
|
select item_id,
|
||
|
hall_id,
|
||
|
venue_id,
|
||
|
item_begin_time,
|
||
|
item_end_time,
|
||
|
item_name,
|
||
|
item_rest,
|
||
|
venue_seats,
|
||
|
seat_nums,
|
||
|
sale_nums
|
||
|
from zdy_cinema_movie_venue_item
|
||
|
where venue_id = #{venueId}
|
||
|
</select>
|
||
|
|
||
|
<select id = "checkHallInVenueItem" parameterType = "Long" resultType = "Integer">
|
||
|
select count(hall_id)
|
||
|
from zdy_cinema_movie_venue_item
|
||
|
where hall_id = #{hallId}
|
||
|
</select>
|
||
|
|
||
|
<!-- 根据场次id查询该影厅是否有正在出售的票 -->
|
||
|
<select id = "selectIsSaleByItemIds" parameterType = "String">
|
||
|
select sum(sale_nums)
|
||
|
from zdy_cinema_movie_venue_item where item_id in
|
||
|
<foreach item = "itemId" collection = "array" open = "(" separator = "," close = ")">
|
||
|
#{itemId}
|
||
|
</foreach>
|
||
|
</select>
|
||
|
<!-- 根据场地id查询该影厅是否有正在出售的票 -->
|
||
|
<select id = "selectIsSaleByHallId" parameterType = "Long">
|
||
|
select IFNULL(sum(sale_nums), 0)
|
||
|
from zdy_cinema_movie_venue_item where hall_id = #{hallId}
|
||
|
</select>
|
||
|
<!-- 根据场次id更新销量 -->
|
||
|
<update id = "updateSaleNums">
|
||
|
update zdy_cinema_movie_venue_item
|
||
|
set sale_nums = sale_nums + #{nums}
|
||
|
where item_id = #{id}
|
||
|
</update>
|
||
|
|
||
|
<select id="getOverlappingItems" parameterType="VenueItemOverlappingQueryDTO"
|
||
|
resultMap="ZdyCinemaMovieVenueItemDTOResult">
|
||
|
SELECT
|
||
|
zcmvi.item_begin_time,
|
||
|
zcmvi.item_end_time,
|
||
|
zcmvi.item_rest,
|
||
|
zcmv.venue_begin_date,
|
||
|
zcmv.venue_end_date
|
||
|
FROM zdy_cinema_movie_venue_item zcmvi
|
||
|
INNER JOIN zdy_cinema_movie_venue zcmv ON zcmv.venue_id = zcmvi.venue_id
|
||
|
WHERE
|
||
|
DATE(zcmv.venue_begin_date) <= #{venueEndDate}
|
||
|
AND DATE(zcmv.venue_end_date) >= #{venueBeginDate}
|
||
|
AND TIME(zcmvi.item_begin_time) <= TIME(#{itemEndTime})
|
||
|
AND TIME(zcmvi.item_end_time) > TIME(#{itemBeginTime})
|
||
|
AND zcmvi.hall_id = #{hallId}
|
||
|
<if test="itemId != null">
|
||
|
AND zcmvi.item_id != #{itemId}
|
||
|
</if>
|
||
|
</select>
|
||
|
|
||
|
<select id="existsByHallIds" resultType="java.lang.Boolean">
|
||
|
select exists(
|
||
|
SELECT 1
|
||
|
FROM zdy_cinema_movie_venue_item zcmvi
|
||
|
LEFT JOIN zdy_cinema_movie_venue zcmv on zcmvi.venue_id = zcmv.venue_id
|
||
|
LEFT JOIN zdy_cinema_movie zcm on zcm.movie_id = zcmv.movie_id
|
||
|
WHERE
|
||
|
zcm.del_state = 0
|
||
|
AND hall_id in
|
||
|
<foreach item="hallId" collection="array" open="(" separator="," close=")">
|
||
|
#{hallId}
|
||
|
</foreach>
|
||
|
)
|
||
|
</select>
|
||
|
|
||
|
<select id="existsByHallId" parameterType="java.lang.Long" resultType="java.lang.Boolean">
|
||
|
select exists(
|
||
|
SELECT 1
|
||
|
FROM zdy_cinema_movie_venue_item zcmvi
|
||
|
LEFT JOIN zdy_cinema_movie_venue zcmv on zcmvi.venue_id = zcmv.venue_id
|
||
|
LEFT JOIN zdy_cinema_movie zcm on zcm.movie_id = zcmv.movie_id
|
||
|
WHERE
|
||
|
zcm.del_state = 0
|
||
|
AND hall_id = #{hallId}
|
||
|
)
|
||
|
</select>
|
||
|
</mapper>
|