<?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.boot.security.server.dao.AdvertDao">

    <insert id="insertAdvertDataCount" parameterType="java.util.List">
        INSERT INTO advert_data_count (report_date, advertiser_id, advertiser_name, code_id,exposure,click,ecpm,cpc,income)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.reportDate}, #{item.advertiserId},
            #{item.advertiserName}, #{item.codeId},
            #{item.exposure}, #{item.click},
            #{item.ecpm}, #{item.cpc},
            #{item.income})
        </foreach>
        ON DUPLICATE KEY UPDATE
        report_date = VALUES(report_date),
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        exposure = VALUES(exposure),
        click = VALUES(click),
        ecpm = VALUES(ecpm),
        cpc = VALUES(cpc),
        income = VALUES(income)
    </insert>

    <insert id="insertAdvertList" parameterType="java.util.List">
        INSERT INTO advert_list(advertiser_id, advertiser_name, code_id,code_name,platform_id)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName},
            #{item.codeId},#{item.codeName},#{item.platformId})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        code_id = VALUES(code_id),
        code_name = VALUES(code_name),
        platform_id = VALUES(platform_id)
    </insert>

    <insert id="insertAdvertiserData" parameterType="java.util.List">
        INSERT INTO advertiser_data_count(advertiser_id, advertiser_name)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name)
    </insert>

    <insert id="insertAdvertiserUserMap" parameterType="java.util.List">
        INSERT INTO advertiser_user_map(advertiser_id, advertiser_name,user_id)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName},#{item.userId})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        user_id = VALUES(user_id)
    </insert>

    <insert id="insertAdvertiserDataTotalIncome" parameterType="java.util.List">
        INSERT INTO advertiser_data_count(advertiser_id, advertiser_name,total_income)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName},#{item.totalIncome})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        total_income = VALUES(total_income)
    </insert>

    <insert id="insertAdvertiserDataIncome" parameterType="java.util.List">
        INSERT INTO advertiser_data_count(advertiser_id, advertiser_name,income)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName},#{item.income})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        income = VALUES(income)
    </insert>

    <insert id="insertAdvertiserDataSevenIncome" parameterType="java.util.List">
        INSERT INTO advertiser_data_count(advertiser_id, advertiser_name,income_seven)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName},#{item.incomeSeven})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        income_seven = VALUES(income_seven)
    </insert>

    <insert id="insertAdvertiserDataThirtyIncome" parameterType="java.util.List">
        INSERT INTO advertiser_data_count(advertiser_id, advertiser_name,income_thirty)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName},#{item.incomeThirty})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        income_thirty = VALUES(income_thirty)
    </insert>

    <insert id="insertAdvertiserDataCount" parameterType="java.util.List">
        INSERT INTO advertiser_data_count(advertiser_id, advertiser_name,exposure,click)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.advertiserId},#{item.advertiserName},#{item.exposure},#{item.click})
        </foreach>
        ON DUPLICATE KEY UPDATE
        advertiser_id = VALUES(advertiser_id),
        advertiser_name = VALUES(advertiser_name),
        exposure = VALUES(exposure),
        click = VALUES(click)
    </insert>

    <insert id="insertAdvertDataMinuteEx" parameterType="java.util.List">
        INSERT INTO advertiser_data_minutes(report_date,advertiser_id, advertiser_name,code_id,minutes,exposure)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            ( #{item.reportDate},#{item.advertiserId},
            #{item.advertiserName},#{item.codeId},
            #{item.minutes},
            #{item.exposure} )
        </foreach>
        ON DUPLICATE KEY UPDATE
        exposure = VALUES(exposure)
    </insert>

    <insert id="insertAdvertDataMinuteCl" parameterType="java.util.List">
        INSERT INTO advertiser_data_minutes(report_date,advertiser_id, advertiser_name,code_id,minutes,click)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.reportDate},#{item.advertiserId},#{item.advertiserName},#{item.codeId},#{item.minutes},#{item.click})
        </foreach>
        ON DUPLICATE KEY UPDATE
        click = VALUES(click)
    </insert>
</mapper>