<?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.liquidnet.service.kylin.mapper.KylinOrderExpressMapper">

    <select id="selectPrintList" resultType="com.liquidnet.service.kylin.dao.OrderExpressListDao">
        SELECT a.*,
               b.express_contacts, b.express_address, b.express_phone, b.province, b.city, b.county, b.number,
               d.use_start, d.title AS time_title, d.type AS time_type,
               e.title AS tickets_title, e.type AS tickets_type
        FROM kylin_order_express a
        INNER JOIN kylin_order_tickets b ON a.order_tickets_id = b.order_tickets_id
        INNER JOIN kylin_order_ticket_relations c ON b.order_tickets_id = c.order_id
        LEFT JOIN kylin_ticket_times d ON c.time_id = d.ticket_times_id
        LEFT JOIN kylin_tickets e ON c.ticket_id = e.tickets_id
        <where>
            a.order_express_id IN
            <foreach collection="ids" item="orderExpressId" index="index" open="(" close=")" separator=",">
                ${orderExpressId}
            </foreach>
            AND express_status NOT IN (1, 3)
        </where>
        ORDER BY a.mid DESC
    </select>
    <select id="selectPrintListOfPerformanceId" resultType="com.liquidnet.service.kylin.dao.OrderExpressListDao">
        SELECT a.*,
        b.express_contacts, b.express_address, b.express_phone, b.province, b.city, b.county, b.number,
        d.use_start, d.title AS time_title, d.type AS time_type,
        e.title AS tickets_title, e.type AS tickets_type
        FROM kylin_order_express a
        INNER JOIN kylin_order_tickets b ON a.order_tickets_id = b.order_tickets_id
        INNER JOIN kylin_order_ticket_relations c ON b.order_tickets_id = c.order_id
        LEFT JOIN kylin_ticket_times d ON c.time_id = d.ticket_times_id
        LEFT JOIN kylin_tickets e ON c.ticket_id = e.tickets_id
        <where>
            a.express_status = 2
            AND a.performances_id = #{performanceId}
            AND a.mid > ${mid}
        </where>
        ORDER BY a.mid ASC
        LIMIT ${limitNum}
    </select>
    <select id="getCanCancelExpressList" resultType="com.liquidnet.service.kylin.entity.KylinOrderExpress">
        SELECT
        mid, order_express_id, order_tickets_id
        FROM kylin_order_express
        <where>
            performances_id = #{performanceId}
            AND express_status = 2 -- 只能取消申请成功的 揽收以后不支持取消
            AND mid > ${mid}
        </where>
        LIMIT ${limitNum}
    </select>
</mapper>
