<?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.bonus.bonus.mapper.CuMemberBonusStageMapper">

    <!-- 删除会员阶段奖金表 -->
    <delete id="deleteCuMemberBonusStage">
        delete
        from CU_MEMBER_BONUS_STAGE
        where PK_BONUS in (
            select pk_id
            from cu_member_bonus
            where period = #{period}
              and grant_status &lt;= 2)
    </delete>

    <!-- 批量插入会员阶段奖 -->
    <insert id="batchInsertCuMemberBonusStage">
        insert ALL
        <foreach item="item" index="index" collection="cuMemberBonusStageList" separator=" ">
            into cu_member_bonus_stage (
            pk_bonus, pk_order, pk_bonus_items, income_status,
            cal_type, cal_achieve, cal_value,
            pretax_income, income_tax, real_income, remark,
            income_ratio, income_dial_ratio, order_dial_ratio,
            pk_creator, child_node, stage, stage_num)
            values (
            #{item.pkBonus}, #{item.pkOrder}, #{item.pkBonusItems}, #{item.incomeStatus},
            #{item.calType}, #{item.calAchieve}, #{item.calValue},
            #{item.pretaxIncome}, #{item.incomeTax}, #{item.realIncome}, #{item.remark},
            #{item.incomeRatio}, #{item.incomeDialRatio}, #{item.orderDialRatio},
            #{item.pkCreator}, #{item.childNode}, #{item.stage}, #{item.stageNum})
        </foreach>
        SELECT 1 FROM dual
    </insert>

</mapper>
