<?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.KylinTicketsMapper">

    <resultMap id="ticketAgentResult" type="com.liquidnet.service.kylin.dao.TicketAgentDao">
        <result column="tickets_id" property="ticketsId"/>
        <result column="title" property="title"/>
        <result column="is_agent" property="isAgent"/>
    </resultMap>

    <resultMap id="ticketDamaiResult" type="com.liquidnet.service.kylin.dao.TicketDamaiDao">
        <result column="tickets_id" property="ticketsId"/>
        <result column="title" property="title"/>
        <result column="is_agent" property="isAgent"/>
    </resultMap>


    <!-- 票分销情况-->
    <select id="ticketAgent" parameterType="java.lang.String" resultMap="ticketAgentResult">
        SELECT
            tickets_id ,
            concat(title,' - ',use_start)  as 'title',
            ts.is_agent
        FROM
            kylin_ticket_status AS ts
                LEFT JOIN kylin_ticket_relations AS tr ON tr.ticket_id = ts.ticket_id
                LEFT JOIN kylin_ticket_time_relation AS ttr ON tr.times_id = ttr.times_id
                LEFT JOIN kylin_tickets AS t ON t.tickets_id = ts.ticket_id
        where performance_id = ${performanceIds}
    </select>

    <!-- 票大麦情况-->
    <select id="ticketDamai" parameterType="java.lang.String" resultMap="ticketDamaiResult">
        SELECT
            tickets_id ,
            concat(title,' - ',use_start)  as 'title',
            ts.sync_damai
        FROM
            kylin_ticket_status AS ts
                LEFT JOIN kylin_ticket_relations AS tr ON tr.ticket_id = ts.ticket_id
                LEFT JOIN kylin_ticket_time_relation AS ttr ON tr.times_id = ttr.times_id
                LEFT JOIN kylin_tickets AS t ON t.tickets_id = ts.ticket_id
        where performance_id = ${performanceIds}
    </select>
</mapper>
