<?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.hzs.sale.ticket.mapper.SaBuyTicketMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="SaBuyTicket" type="com.hzs.common.domain.sale.ticket.SaBuyTicket">
        <id column="PK_ID" property="pkId" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="CREATION_TIME" property="creationTime" />
        <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="PK_COUNTRY" property="pkCountry" />
        <result column="PK_CREATOR" property="pkCreator" />
        <result column="PK_MODIFIED" property="pkModified" />
        <result column="BUY_NAME" property="buyName" />
        <result column="PHONE" property="phone" />
        <result column="ID_CARD" property="idCard" />
        <result column="SEX" property="sex" />
        <result column="CLOTH_SIZE" property="clothSize" />
        <result column="COHABITANT" property="cohabitant" />
        <result column="EMERGENCY_PHONE" property="emergencyPhone" />
        <result column="PK_TEAM" property="pkTeam" />
        <result column="PRICE" property="price" />
        <result column="PK_SA_TICKET" property="pkSaTicket" />
    </resultMap>
    <update id="mergeSaBuyTicketService">
        merge into sa_buy_ticket st
        using(
        <foreach collection="ticketParamList" item="item" open=" " separator=" union " close=" ">
            select #{item.pkId} pk_id,#{item.buyName} buy_name,#{item.phone} phone,
            #{item.idCard} id_card,#{item.sex} sex,#{item.clothSize} cloth_size,
            #{item.cohabitant} cohabitant,#{item.emergencyPhone} emergency_phone from dual
        </foreach>
            ) b
        on(st.pk_id=b.pk_id)
        when matched then
            update set st.buy_name=b.buy_name,st.phone=b.phone,st.id_card=b.id_card,
                st.sex=b.sex,st.cloth_size=b.cloth_size,st.cohabitant=b.cohabitant,
                st.emergency_phone=b.emergency_phone,pk_modified=#{pkMember},
            modified_time=sysdate
    </update>

</mapper>
