<?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.member.swing.mapper.CuMemberSwingNetDetailMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.swing.CuMemberSwingNetDetail">
        <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="PK_SWING_NET" property="pkSwingNet" />
        <result column="PK_MEMBER" property="pkMember" />
        <result column="FIRST_ACHIEVE_RATIO" property="firstAchieveRatio" />
        <result column="REPURCHASE_ACHIEVE_RATIO" property="repurchaseAchieveRatio" />
        <result column="FIRST_CALCULATE" property="firstCalculate" />
        <result column="REPURCHASE_CALCULATE" property="repurchaseCalculate" />
    </resultMap>
    <update id="mergeCuMemberSwingNetDetail">
        merge into CU_MEMBER_SWING_NET_DETAIL a
        using(
        <foreach collection="cuMemberSwingNetDetailVOList" item="item" separator=" union ">
        select #{item.pkId,jdbcType=BIGINT} pk_id,#{item.pkSwingNet,jdbcType=BIGINT} pk_swing_net,
               #{item.pkMember} pk_member,#{item.firstAchieveRatio,jdbcType=NUMERIC} first_achieve_ratio,
               #{item.repurchaseAchieveRatio,jdbcType=NUMERIC} repurchase_achieve_ratio,
               #{item.firstCalculate,jdbcType=INTEGER} first_calculate,
               #{item.repurchaseCalculate,jdbcType=INTEGER} repurchase_calculate,
               #{item.pkCountry,jdbcType=INTEGER} pk_country,#{item.pkCreator,jdbcType=NUMERIC} pk_creator,
               #{item.creationTime,jdbcType=TIMESTAMP} creation_time from dual
        </foreach>
            ) b
        on (a.pk_id = b.pk_id)
        when matched then update set
        a.pk_swing_net=b.pk_swing_net,a.pk_member=b.pk_member,a.first_achieve_ratio=b.first_achieve_ratio,
        a.repurchase_achieve_ratio=b.repurchase_achieve_ratio,a.first_calculate=b.first_calculate,
        a.repurchase_calculate=b.repurchase_calculate,a.pk_country=b.pk_country,
        a.pk_modified=b.pk_creator,a.modified_time=b.creation_time
        WHEN NOT MATCHED THEN
        insert (pk_id,pk_swing_net,pk_member,first_achieve_ratio,repurchase_achieve_ratio,first_calculate,
        repurchase_calculate,pk_country,pk_creator,creation_time) values(
        cu_member_swing_net_detail_seq.nextval,b.pk_swing_net,b.pk_member,b.first_achieve_ratio,b.repurchase_achieve_ratio,
        b.first_calculate,b.repurchase_calculate,b.pk_country,b.pk_creator,b.creation_time
        )
    </update>

</mapper>
