<?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.kxs.product.biz.mapper.KxsTicketTransferMapper">

    <resultMap type="com.kxs.product.api.model.KxsTicketTransfer" id="KxsTicketTransferMap">
        <result column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
        <result column="version" property="version" />
        <result column="order_sn" property="orderSn" />
        <result column="send_user_id" property="sendUserId" />
        <result column="send_user_name" property="sendUserName" />
        <result column="send_user_code" property="sendUserCode" />
        <result column="to_user_id" property="toUserId" />
        <result column="to_user_name" property="toUserName" />
        <result column="to_user_code" property="toUserCode" />
        <result column="to_user_id" property="toUserId" />
        <result column="transfer_num" property="transferNum" />
        <result column="ticket_type" property="ticketType" />

    </resultMap>
    <select id="getByPage" resultType="com.kxs.product.api.vo.kxsapp.ticket.TicketTransferListVO">
        select a.id, a.transfer_num, a.ticket_type, a.to_user_id, a.send_user_id, a.create_time,
        <if test="query.transferType == 1">
            a.send_user_name as username, a.send_user_code as userCode
        </if>
        <if test="query.transferType == 2">
            a.to_user_name as username, a.to_user_code as userCode
        </if>
        from kxs_ticket_transfer a
        <where>
            <if test="query.toUserId != null">
                and a.to_user_id = #{query.toUserId}
            </if>
            <if test="query.sendUserId != null">
                and a.send_user_id = #{query.sendUserId}
            </if>
        </where>
        order by a.create_time desc
    </select>


</mapper>
