<?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.client.admin.zhengzai.kylin.mapper.KylinOrderTicketsMapper">
    
    <resultMap type="KylinOrderTickets" id="KylinOrderTicketsResult">
        <result property="mid"    column="mid"    />
        <result property="orderTicketsId"    column="order_tickets_id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="userMobile"    column="user_mobile"    />
        <result property="performanceTitle"    column="performance_title"    />
        <result property="orderCode"    column="order_code"    />
        <result property="qrCode"    column="qr_code"    />
        <result property="orderType"    column="order_type"    />
        <result property="orderVersion"    column="order_version"    />
        <result property="number"    column="number"    />
        <result property="price"    column="price"    />
        <result property="priceMember"    column="price_member"    />
        <result property="priceTotal"    column="price_total"    />
        <result property="priceVoucher"    column="price_voucher"    />
        <result property="priceActual"    column="price_actual"    />
        <result property="priceExpress"    column="price_express"    />
        <result property="priceRefund"    column="price_refund"    />
        <result property="priceNumber"    column="price_number"    />
        <result property="payType"    column="pay_type"    />
        <result property="paymentType"    column="payment_type"    />
        <result property="timePay"    column="time_pay"    />
        <result property="expressContacts"    column="express_contacts"    />
        <result property="expressAddress"    column="express_address"    />
        <result property="expressPhone"    column="express_phone"    />
        <result property="couponType"    column="coupon_type"    />
        <result property="getTicketType"    column="get_ticket_type"    />
        <result property="getTicketDescribe"    column="get_ticket_describe"    />
        <result property="payCountdownMinute"    column="pay_countdown_minute"    />
        <result property="comment"    column="comment"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
    </resultMap>

    <sql id="selectKylinOrderTicketsVo">
        select mid, order_tickets_id, user_id, user_name, user_mobile, performance_title, order_code, qr_code, order_type, order_version, number, price, price_member, price_total, price_voucher, price_actual, price_express, price_refund, price_number, pay_type, payment_type, time_pay, express_contacts, express_address, express_phone, coupon_type, get_ticket_type, get_ticket_describe, pay_countdown_minute, comment, created_at, updated_at from kylin_order_tickets
    </sql>

    <select id="selectKylinOrderTicketsList" parameterType="KylinOrderTickets" resultMap="KylinOrderTicketsResult">
        <include refid="selectKylinOrderTicketsVo"/>
        <where>  
            <if test="orderTicketsId != null  and orderTicketsId != ''"> and order_tickets_id = #{orderTicketsId}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="userMobile != null  and userMobile != ''"> and user_mobile = #{userMobile}</if>
            <if test="performanceTitle != null  and performanceTitle != ''"> and performance_title = #{performanceTitle}</if>
            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
            <if test="qrCode != null  and qrCode != ''"> and qr_code = #{qrCode}</if>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
            <if test="orderVersion != null  and orderVersion != ''"> and order_version = #{orderVersion}</if>
            <if test="number != null  and number != ''"> and number = #{number}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="priceMember != null "> and price_member = #{priceMember}</if>
            <if test="priceTotal != null "> and price_total = #{priceTotal}</if>
            <if test="priceVoucher != null "> and price_voucher = #{priceVoucher}</if>
            <if test="priceActual != null "> and price_actual = #{priceActual}</if>
            <if test="priceExpress != null "> and price_express = #{priceExpress}</if>
            <if test="priceRefund != null "> and price_refund = #{priceRefund}</if>
            <if test="priceNumber != null "> and price_number = #{priceNumber}</if>
            <if test="payType != null  and payType != ''"> and pay_type = #{payType}</if>
            <if test="paymentType != null  and paymentType != ''"> and payment_type = #{paymentType}</if>
            <if test="timePay != null  and timePay != ''"> and time_pay = #{timePay}</if>
            <if test="expressContacts != null  and expressContacts != ''"> and express_contacts = #{expressContacts}</if>
            <if test="expressAddress != null  and expressAddress != ''"> and express_address = #{expressAddress}</if>
            <if test="expressPhone != null  and expressPhone != ''"> and express_phone = #{expressPhone}</if>
            <if test="couponType != null  and couponType != ''"> and coupon_type = #{couponType}</if>
            <if test="getTicketType != null  and getTicketType != ''"> and get_ticket_type = #{getTicketType}</if>
            <if test="getTicketDescribe != null  and getTicketDescribe != ''"> and get_ticket_describe = #{getTicketDescribe}</if>
            <if test="payCountdownMinute != null  and payCountdownMinute != ''"> and pay_countdown_minute = #{payCountdownMinute}</if>
            <if test="comment != null  and comment != ''"> and comment = #{comment}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
        </where>
    </select>
    
    <select id="selectKylinOrderTicketsById" parameterType="Integer" resultMap="KylinOrderTicketsResult">
        <include refid="selectKylinOrderTicketsVo"/>
        where mid = #{mid}
    </select>
        
    <insert id="insertKylinOrderTickets" parameterType="KylinOrderTickets" useGeneratedKeys="true" keyProperty="mid">
        insert into kylin_order_tickets
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderTicketsId != null and orderTicketsId != ''">order_tickets_id,</if>
            <if test="userId != null and userId != ''">user_id,</if>
            <if test="userName != null and userName != ''">user_name,</if>
            <if test="userMobile != null and userMobile != ''">user_mobile,</if>
            <if test="performanceTitle != null and performanceTitle != ''">performance_title,</if>
            <if test="orderCode != null and orderCode != ''">order_code,</if>
            <if test="qrCode != null and qrCode != ''">qr_code,</if>
            <if test="orderType != null and orderType != ''">order_type,</if>
            <if test="orderVersion != null and orderVersion != ''">order_version,</if>
            <if test="number != null and number != ''">number,</if>
            <if test="price != null">price,</if>
            <if test="priceMember != null">price_member,</if>
            <if test="priceTotal != null">price_total,</if>
            <if test="priceVoucher != null">price_voucher,</if>
            <if test="priceActual != null">price_actual,</if>
            <if test="priceExpress != null">price_express,</if>
            <if test="priceRefund != null">price_refund,</if>
            <if test="priceNumber != null">price_number,</if>
            <if test="payType != null and payType != ''">pay_type,</if>
            <if test="paymentType != null and paymentType != ''">payment_type,</if>
            <if test="timePay != null and timePay != ''">time_pay,</if>
            <if test="expressContacts != null and expressContacts != ''">express_contacts,</if>
            <if test="expressAddress != null and expressAddress != ''">express_address,</if>
            <if test="expressPhone != null and expressPhone != ''">express_phone,</if>
            <if test="couponType != null and couponType != ''">coupon_type,</if>
            <if test="getTicketType != null and getTicketType != ''">get_ticket_type,</if>
            <if test="getTicketDescribe != null and getTicketDescribe != ''">get_ticket_describe,</if>
            <if test="payCountdownMinute != null and payCountdownMinute != ''">pay_countdown_minute,</if>
            <if test="comment != null and comment != ''">comment,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="updatedAt != null">updated_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderTicketsId != null and orderTicketsId != ''">#{orderTicketsId},</if>
            <if test="userId != null and userId != ''">#{userId},</if>
            <if test="userName != null and userName != ''">#{userName},</if>
            <if test="userMobile != null and userMobile != ''">#{userMobile},</if>
            <if test="performanceTitle != null and performanceTitle != ''">#{performanceTitle},</if>
            <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
            <if test="qrCode != null and qrCode != ''">#{qrCode},</if>
            <if test="orderType != null and orderType != ''">#{orderType},</if>
            <if test="orderVersion != null and orderVersion != ''">#{orderVersion},</if>
            <if test="number != null and number != ''">#{number},</if>
            <if test="price != null">#{price},</if>
            <if test="priceMember != null">#{priceMember},</if>
            <if test="priceTotal != null">#{priceTotal},</if>
            <if test="priceVoucher != null">#{priceVoucher},</if>
            <if test="priceActual != null">#{priceActual},</if>
            <if test="priceExpress != null">#{priceExpress},</if>
            <if test="priceRefund != null">#{priceRefund},</if>
            <if test="priceNumber != null">#{priceNumber},</if>
            <if test="payType != null and payType != ''">#{payType},</if>
            <if test="paymentType != null and paymentType != ''">#{paymentType},</if>
            <if test="timePay != null and timePay != ''">#{timePay},</if>
            <if test="expressContacts != null and expressContacts != ''">#{expressContacts},</if>
            <if test="expressAddress != null and expressAddress != ''">#{expressAddress},</if>
            <if test="expressPhone != null and expressPhone != ''">#{expressPhone},</if>
            <if test="couponType != null and couponType != ''">#{couponType},</if>
            <if test="getTicketType != null and getTicketType != ''">#{getTicketType},</if>
            <if test="getTicketDescribe != null and getTicketDescribe != ''">#{getTicketDescribe},</if>
            <if test="payCountdownMinute != null and payCountdownMinute != ''">#{payCountdownMinute},</if>
            <if test="comment != null and comment != ''">#{comment},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="updatedAt != null">#{updatedAt},</if>
         </trim>
    </insert>

    <update id="updateKylinOrderTickets" parameterType="KylinOrderTickets">
        update kylin_order_tickets
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderTicketsId != null and orderTicketsId != ''">order_tickets_id = #{orderTicketsId},</if>
            <if test="userId != null and userId != ''">user_id = #{userId},</if>
            <if test="userName != null and userName != ''">user_name = #{userName},</if>
            <if test="userMobile != null and userMobile != ''">user_mobile = #{userMobile},</if>
            <if test="performanceTitle != null and performanceTitle != ''">performance_title = #{performanceTitle},</if>
            <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
            <if test="qrCode != null and qrCode != ''">qr_code = #{qrCode},</if>
            <if test="orderType != null and orderType != ''">order_type = #{orderType},</if>
            <if test="orderVersion != null and orderVersion != ''">order_version = #{orderVersion},</if>
            <if test="number != null and number != ''">number = #{number},</if>
            <if test="price != null">price = #{price},</if>
            <if test="priceMember != null">price_member = #{priceMember},</if>
            <if test="priceTotal != null">price_total = #{priceTotal},</if>
            <if test="priceVoucher != null">price_voucher = #{priceVoucher},</if>
            <if test="priceActual != null">price_actual = #{priceActual},</if>
            <if test="priceExpress != null">price_express = #{priceExpress},</if>
            <if test="priceRefund != null">price_refund = #{priceRefund},</if>
            <if test="priceNumber != null">price_number = #{priceNumber},</if>
            <if test="payType != null and payType != ''">pay_type = #{payType},</if>
            <if test="paymentType != null and paymentType != ''">payment_type = #{paymentType},</if>
            <if test="timePay != null and timePay != ''">time_pay = #{timePay},</if>
            <if test="expressContacts != null and expressContacts != ''">express_contacts = #{expressContacts},</if>
            <if test="expressAddress != null and expressAddress != ''">express_address = #{expressAddress},</if>
            <if test="expressPhone != null and expressPhone != ''">express_phone = #{expressPhone},</if>
            <if test="couponType != null and couponType != ''">coupon_type = #{couponType},</if>
            <if test="getTicketType != null and getTicketType != ''">get_ticket_type = #{getTicketType},</if>
            <if test="getTicketDescribe != null and getTicketDescribe != ''">get_ticket_describe = #{getTicketDescribe},</if>
            <if test="payCountdownMinute != null and payCountdownMinute != ''">pay_countdown_minute = #{payCountdownMinute},</if>
            <if test="comment != null and comment != ''">comment = #{comment},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
            <if test="updatedAt != null">updated_at = #{updatedAt},</if>
        </trim>
        where mid = #{mid}
    </update>

    <delete id="deleteKylinOrderTicketsById" parameterType="Integer">
        delete from kylin_order_tickets where mid = #{mid}
    </delete>

    <delete id="deleteKylinOrderTicketsByIds" parameterType="String">
        delete from kylin_order_tickets where mid in 
        <foreach item="mid" collection="array" open="(" separator="," close=")">
            #{mid}
        </foreach>
    </delete>

</mapper>