<?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.xxl.job.executor.report.mapper.KuaishouReportHourlyAccountMapper">
    <insert id="replaceBatch">
        replace into ctop_kuaishou_report_hourly_account(
        id,
        account_id,
        stat_date,
        stat_hour,
        charge,
        photo_click,
        photo_show,
        aclick,
        bclick,
        photo_click_ratio,
        action_ratio,
        impression_1k_cost,
        event_credit_grant_landing_page_cost,
        event_credit_grant_landing_page,
        event_jin_jian_landing_page_cost,
        event_jin_jian_landing_page,
        form_action_ratio,
        form_cost,
        form_count,
        event_order_paid_cost,
        event_order_paid_purchase_amount,
        event_order_paid,
        event_credit_grant_app_ratio,
        event_credit_grant_app_cost,
        event_credit_grant_app,
        event_pay_purchase_amount_first_day,
        event_jin_jian_app_cost,
        event_jin_jian_app,
        event_register_cost,
        event_register,
        event_pay_roi,
        event_pay_purchase_amount,
        event_pay,
        event_pay_first_day_roi,
        event_pay_first_day,
        photo_click_cost,
        action_cost,
        share,
        comment,
        photo_like,
        follow,
        report,
        block,
        negative,
        activation,
        submit,
        cancel_follow,
        download_started,
        download_completed,
        event_next_day_stay
        )
        values
        <foreach collection="records" item="record" separator=",">
            (
            #{record.id},
            #{record.accountId},
            #{record.statDate},
            #{record.statHour},
            #{record.charge},
            #{record.photoClick},
            #{record.photoShow},
            #{record.aclick},
            #{record.bclick},
            #{record.photoClickRatio},
            #{record.actionRatio},
            #{record.impression1kCost},
            #{record.eventCreditGrantLandingPageCost},
            #{record.eventCreditGrantLandingPage},
            #{record.eventJinJianLandingPageCost},
            #{record.eventJinJianLandingPage},
            #{record.formActionRatio},
            #{record.formCost},
            #{record.formCount},
            #{record.eventOrderPaidCost},
            #{record.eventOrderPaidPurchaseAmount},
            #{record.eventOrderPaid},
            #{record.eventCreditGrantAppRatio},
            #{record.eventCreditGrantAppCost},
            #{record.eventCreditGrantApp},
            #{record.eventPayPurchaseAmountFirstDay},
            #{record.eventJinJianAppCost},
            #{record.eventJinJianApp},
            #{record.eventRegisterCost},
            #{record.eventRegister},
            #{record.eventPayRoi},
            #{record.eventPayPurchaseAmount},
            #{record.eventPay},
            #{record.eventPayFirstDayRoi},
            #{record.eventPayFirstDay},
            #{record.photoClickCost},
            #{record.actionCost},
            #{record.photoShare},
            #{record.comment},
            #{record.photoLike},
            #{record.follow},
            #{record.report},
            #{record.block},
            #{record.negative},
            #{record.activation},
            #{record.submit},
            #{record.cancelFollow},
            #{record.downloadStarted},
            #{record.downloadCompleted},
            #{record.eventNextDayStay}
            )
        </foreach>

    </insert>

    <select id="selectMaxHour" resultType="java.lang.Integer">
        select max(stat_hour)
        from
        ctop_kuaishou_report_hourly_account
        where account_id = #{accountId}
        and stat_date = #{statDate}

    </select>

    <select id="getCost" resultType="java.math.BigDecimal">
        select charge
        from
        ctop_kuaishou_report_hourly_account
        where
        account_id = #{accountId}
        and stat_date = #{statDate}
        and stat_hour = #{statHour}

    </select>

</mapper>
