<?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.moka.gdtauto.mapper.AdPlanMapper">

    <!-- 批量更新广告计划 system_status，依赖 allowMultiQueries=true -->
    <update id="batchUpdateSystemStatus" parameterType="java.util.List">
        <foreach collection="plans" item="item" separator=";">
            UPDATE ad_plan
            SET 
                configured_status = #{item.configuredStatus},
                system_status = #{item.systemStatus},
                system_delete = #{item.systemDelete},
                update_time   = NOW()
            WHERE adgroup_id = #{item.adgroupId}
        </foreach>
    </update>

    <!-- 批量更新广告计划 REQUEST_TIME 口径日报数据 -->
    <update id="batchUpdateReqDailyReport" parameterType="java.util.List">
        <foreach collection="plans" item="item" separator=";">
            UPDATE ad_plan
            SET cost              = #{item.cost},
                view_count        = #{item.viewCount},
                valid_click_count = #{item.validClickCount},
                ctr               = #{item.ctr},
                conversions_cost  = #{item.conversionsCost},
                req_income_val1  = #{item.reqIncomeVal1},
                req_income_roi1  = #{item.reqIncomeRoi1},
                scan_follow_user_cost = #{item.scanFollowUserCost},
                update_time       = NOW()
            WHERE adgroup_id = #{item.adgroupId}
        </foreach>
    </update>

    <!-- 批量更新广告计划 REPORTING_TIME 口径日报数据 -->
    <update id="batchUpdateRepDailyReport" parameterType="java.util.List">
        <foreach collection="plans" item="item" separator=";">
            UPDATE ad_plan
            SET rep_income_val1 = #{item.repIncomeVal1},
                rep_income_roi1 = #{item.repIncomeRoi1},
                update_time      = NOW()
            WHERE adgroup_id = #{item.adgroupId}
        </foreach>
    </update>

</mapper>
