zhwl/zhwl-business/zhwl-ticket-order/target/classes/mapper/cinema/CinemaOrderMapper.xml

285 lines
14 KiB
XML
Raw Normal View History

2025-07-01 17:54:58 +08:00
<?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.CinemaOrderMapper">
<!-- 剧场演绎票订单列表开始 -->
<resultMap type = "CinemaOrderVo" id = "CinemaOrderResult">
<result property = "id" column = "id"/>
<result property = "orderCode" column = "order_code"/>
<result property = "orderSource" column = "order_source"/>
<result property = "buyQuantity" column = "buy_quantity"/>
<result property = "totalPrice" column = "total_price"/>
<result property = "paymentMethod" column = "payment_method"/>
<result property = "orderPrepayId" column = "order_prepay_id"/>
<result property = "userName" column = "user_name"/>
<result property = "identityCard" column = "identity_card"/>
<result property = "paymentType" column = "payment_type"/>
<result property = "refundStatus" column = "refund_status"/>
<result property = "verificationType" column = "verification_type"/>
<result property = "paymentTime" column = "payment_time"/>
<result property = "createTime" column = "create_time"/>
<result property = "orderItemId" column = "order_item_id"/>
<result property = "ticketName" column = "ticket_name"/>
<result property = "classify" column = "classify"/>
<result property = "verificationCode" column = "verification_code"/>
<result property="mobile" column="mobile"/>
</resultMap>
<sql id = "selectCinemaOrderVo">
SELECT o.id,
o.order_code,
o.order_source,
o.buy_quantity,
o.total_price,
o.payment_method,
o.order_prepay_id,
IF(o.user_id = 0, o.user_name, zu.`name`) user_name,
IF(o.user_id = 0, o.identity_card, zu.`id_card`) identity_card,
zu.`mobile`,
o.payment_type,
o.refund_status,
o.verification_type,
o.payment_time,
o.create_time,
i.id as order_item_id,
i.ticket_name,
i.classify,
i.order_code as verification_code
FROM zdy_ticket_order o
LEFT JOIN zdy_ticket_order_item i on o.id = i.order_id
LEFT JOIN zdy_user zu ON zu.id = o.user_id
</sql>
<select id = "selectCinemaOrderList" parameterType = "CinemaOrderVo" resultMap = "CinemaOrderResult">
<include refid = "selectCinemaOrderVo"/>
<where>
o.del_flag = '0'
<if test = "orderCode != null and orderCode != ''">
and o.order_code like concat('%', #{orderCode}, '%')
</if>
<if test = "ticketName != null and ticketName != ''">
and i.ticket_name like concat('%', #{ticketName}, '%')
</if>
<if test = "userName != null and userName != ''">
and o.user_name like concat('%', #{userName}, '%')
</if>
<if test = "identityCard != null and identityCard != ''">
and o.identity_card like concat('%', #{identityCard}, '%')
</if>
<if test = "mobile != null and mobile != ''">
and zu.mobile = #{mobile}
</if>
<if test = "verificationCode != null and verificationCode != ''">
and i.order_code = #{verificationCode}
</if>
<if test = "orderPrepayId != null and orderPrepayId != ''">
and o.order_prepay_id = #{orderPrepayId}
</if>
<if test = "paymentMethod != null and paymentMethod != ''">
and o.payment_method = #{paymentMethod}
</if>
<if test = "orderSource != null and orderSource != ''">
and o.order_source = #{orderSource}
</if>
<if test = "paymentType != null and paymentType != ''">
and o.payment_type = #{paymentType}
</if>
<if test="paymentTimeBegin != null and paymentTimeEnd != null">
and o.payment_time between #{paymentTimeBegin} and #{paymentTimeEnd}
</if>
<if test = "refundStatus != null and refundStatus != ''">
and o.refund_status = #{refundStatus}
</if>
<if test = "verificationType != null and verificationType != ''">
and o.verification_type = #{verificationType}
<if test="verificationType == 0 or verificationType == '0'">
and o.payment_time is not null
and o.refund_time is null
</if>
</if>
<if test = "createTimeBegin != null ">and o.create_time &gt;= #{createTimeBegin}</if>
<if test = "createTimeEnd != null ">and o.create_time &lt;= #{createTimeEnd}</if>
</where>
order by o.id desc
</select>
<!-- 剧场演绎票订单列表结束 -->
<!-- 剧场演绎票订单详情开始 -->
<resultMap type = "CinemaOrderDetailResponse" id = "CinemaOrderDetailResult">
<result property = "id" column = "id"/>
<result property = "orderCode" column = "order_code"/>
<result property = "orderSource" column = "order_source"/>
<result property = "ticketName" column = "ticket_name"/>
<result property = "buyQuantity" column = "buy_quantity"/>
<result property = "totalPrice" column = "total_price"/>
<result property = "paymentMethod" column = "payment_method"/>
<result property = "orderPrepayId" column = "order_prepay_id"/>
<result property = "verificationCode" column = "verification_code"/>
<result property = "userName" column = "user_name"/>
<result property = "identityCard" column = "identity_card"/>
<result property = "paymentType" column = "payment_type"/>
<result property = "refundStatus" column = "refund_status"/>
<result property = "verificationType" column = "verification_type"/>
<result property = "paymentTime" column = "payment_time"/>
<result property = "createTime" column = "create_time"/>
<result property = "orderItemId" column = "order_item_id"/>
<result property = "classify" column = "classify"/>
<result property="mobile" column="mobile"/>
</resultMap>
<select id = "selectCinemaOrderById" parameterType = "Long" resultMap = "CinemaOrderDetailResult">
<include refid = "selectCinemaOrderVo"/>
where o.id = #{id} and o.del_flag = '0'
</select>
<!-- 剧场演绎票订单详情结束 -->
<!-- 剧场演绎票剧目详情开始 -->
<resultMap type = "CinemaMovieDetailResponse" id = "CinemaMovieDetailResult">
<result property = "id" column = "id"/>
<result property = "userName" column = "user_name"/>
<result property = "identityCard" column = "identity_card"/>
<result property = "availableStartTime" column = "available_start_time"/>
<result property = "availableEndTime" column = "available_end_time"/>
<result property = "rowNum" column = "row_num"/>
<result property = "seatNum" column = "seat_num"/>
<result property = "paymentType" column = "payment_type"/>
<result property = "paymentTime" column = "payment_time"/>
<result property = "verificationType" column = "verification_type"/>
<result property = "verificationTime" column = "verification_time"/>
<result property = "actuaAmount" column = "actua_amount"/>
<result property = "movieId" column = "movie_id"/>
<result property = "zoneId" column = "zone_id"/>
<result property = "zoneName" column = "zone_name"/>
<result property = "itemId" column = "item_id"/>
<result property = "itemName" column = "item_name"/>
<result property = "itemBeginTime" column = "item_begin_time"/>
<result property = "itemEndTime" column = "item_end_time"/>
<result property = "movieName" column = "movie_name"/>
<result property = "isUsed" column = "is_used"/>
<result property = "verificationCode" column = "verification_code"/>
<result property = "ticketId" column = "ticket_id"/>
<result property = "orderItemId" column = "order_item_id"/>
<result property = "userTouristId" column = "user_tourist_id"/>
<result property = "refundStatus" column = "refund_status"/>
<result property = "seatNumsRow" column = "seat_nums_row"/>
<result property = "rowStart" column = "row_start"/>
<result property = "printed" column = "is_printed"/>
<result property = "lastPrintedTime" column = "last_printed_time"/>
<result property="idCardType" column="id_card_type"/>
<collection property = "childList" javaType = "java.util.List" resultMap = "CinemaOrderChildResult"/>
</resultMap>
<resultMap type="CinemaOrderChildResponse" id="CinemaOrderChildResult">
<result property="id" column="order_detail_child_id"/>
<result property="ticketId" column="child_ticket_id"/>
<result property="ticketName" column="child_ticket_name"/>
</resultMap>
<sql id = "selectMovieDetail">
SELECT d.id,
d.user_name,
d.identity_card,
d.id_card_type,
d.verification_code,
d.available_start_time,
d.available_end_time,
d.row_num,
d.seat_num,
d.payment_type,
d.payment_time,
d.verification_type,
d.verification_time,
d.actua_amount,
d.movie_id,
d.movie_name,
d.item_id,
d.zone_id,
d.zone_name,
d.is_used,
i.item_name,
i.item_begin_time,
i.item_end_time,
c.ticket_id as child_ticket_id,
c.ticket_name as child_ticket_name,
c.id as order_detail_child_id,
d.ticket_id,
d.order_item_id,
d.user_tourist_id,
d.refund_status,
d.is_printed,
d.last_printed_time
FROM zdy_ticket_order_detail d
LEFT JOIN zdy_cinema_movie_venue_item i on i.item_id = d.item_id
LEFT JOIN zdy_cinema_movie m on m.movie_id = d.movie_id
LEFT JOIN zdy_ticket_order_detail_child c ON d.id = c.order_detail_id
</sql>
<select id = "selectCinemaMovieByOrderItemId" parameterType = "Long" resultMap = "CinemaMovieDetailResult">
<include refid = "selectMovieDetail"/>
where d.order_item_id = #{orderItemId} and d.del_flag = '0'
</select>
<!-- 剧场演绎票剧目详情结束 -->
<!-- 查询用户可核销门票列表开始 -->
<select id = "selectCinemaVerificationList" resultMap = "CinemaMovieDetailResult">
<include refid = "selectMovieDetail"/>
<where>
d.del_flag = '0'
AND d.payment_type = 200
AND d.refund_status IN (0, 100, 3)
AND d.verification_type = 0
AND d.available_start_time IS NOT NULL
and d.can_verification_mun > d.verification_mun
AND (NOW() BETWEEN d.available_start_time AND d.available_end_time)
<if test="detailId != null and detailId != '' ">
AND d.id = #{detailId}
</if>
<if test="childId != null and childId != '' ">
AND c.id = #{childId}
</if>
<if test="verificationCode != null and verificationCode != '' and type == 2">
AND d.verification_code = #{verificationCode}
</if>
<if test="identityCard != null and identityCard != '' and type == 1">
AND d.identity_card = #{identityCard}
</if>
<if test="userName != null and userName != '' and type == 1">
AND d.user_name = #{userName}
</if>
<if test="ticketIdList != null">
and (d.ticket_id in
<foreach item="ticketId" collection="ticketIdList" open="(" separator="," close=")">
#{ticketId}
</foreach>
or m.movie_id in
<foreach item="ticketId" collection="ticketIdList" open="(" separator="," close=")">
#{ticketId}
</foreach>
)
</if>
</where>
order by d.available_end_time ASC, d.payment_time desc
</select>
<!-- 查询用户可核销门票列表结束 -->
<!-- 批量新增订单明细 -->
<insert id = "batchInsertZdyTicketOrderDetail">
insert into zdy_ticket_order_detail (order_item_id, verification_code, ticket_id, user_tourist_id,
identity_card, user_name, ticket_price, buy_quantity, product_total_price, payable_amount, actua_amount,
order_time, available_start_time, available_end_time, can_verification_mun, create_by, create_time, update_by,
update_time ) VALUES
<foreach item = "detail" index = "index" collection = "list" separator = ",">
(#{detail.orderItemId}, #{detail.verificationCode}, #{detail.ticketId}, #{detail.userTouristId},
#{detail.identityCard}, #{detail.userName}, #{detail.ticketPrice}, #{detail.buyQuantity},
#{detail.productTotalPrice}, #{detail.payableAmount}, #{detail.actuaAmount}, #{detail.orderTime},
#{detail.availableStartTime}, #{detail.availableEndTime}, #{detail.canVerificationMun}, #{detail.createBy},
#{detail.createTime}, #{detail.updateBy}, #{detail.updateTime})
</foreach>
</insert>
<!-- 付款成功后批量更新订单明细 -->
<update id="updateOrderDetailByOrderItemId" >
update zdy_ticket_order_detail
set payment_type = 200,payment_method = #{paymentMethod},payment_time = now(),update_time = now()
where order_item_id = #{orderItemId}
</update>
</mapper>