<?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="cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportPlayableDailyMapper">

    <insert id="replaceIntoBatch">
        REPLACE INTO ctop_bytedance_report_playable_daily
        (
        account_id,
        playable_id,
        playable_url,
        playable_name,
        playable_preview_url,
        playable_orientation,
        stat_datetime,
        click,
        cost,
        active,
        download_finish,
        download_start,
        install_finish,
        register,
        pay_count,
        in_app_uv,
        in_app_detail_uv,
        in_app_cart,
        in_app_order,
        in_app_pay,
        phone,
        form,
        map_search,
        button,
        view_material,
        qq,
        lottery,
        vote,
        redirect,
        shopping,
        consult,
        wechat,
        phone_confirm,
        phone_connect,
        consult_effective,
        total_play,
        valid_play,
        play25_feed_break,
        play50_feed_break,
        play75_feed_break,
        play100_feed_break,
        advanced_creative_phone_click,
        advanced_creative_counsel_click,
        advanced_creative_form_click,
        share_material,
        comment_material,
        follow,
        home_visited,
        ies_challenge_click,
        ies_music_click,
        next_day_open,
        valid_play_cost,
        advanced_creative_coupon_addition,
        convert_material,
        active_pay_cost,
        download,
        location_click,
        play_over_rate,
        ctr,
        wifi_play_rate,
        like_material,
        active_pay_rate,
        active_cost,
        game_addiction_cost,
        game_addiction,
        active_rate,
        game_addiction_rate,
        download_finish_cost,
        active_register_cost,
        show_material,
        convert_rate,
        download_finish_rate,
        install_finish_rate,
        coupon,
        coupon_single_page,
        download_start_cost,
        message,
        valid_play_rate,
        average_play_time_per_play,
        convert_cost,
        install_finish_cost,
        download_start_rate,
        poi_address_click,
        attribution_convert_cost,
        click_website,
        message_action,
        advanced_creative_form_submit,
        luban_live_slidecart_click_cnt,
        poi_collect,
        luban_order_cnt,
        attribution_next_day_open_rate,
        attribution_next_day_open_cnt,
        loan_credit_rate,
        loan_credit_cost,
        luban_order_stat_amount,
        luban_live_enter_cnt,
        click_landing_page,
        luban_live_follow_cnt,
        click_shopwindow,
        attribution_deep_convert,
        luban_live_pay_order_count,
        luban_live_pay_order_stat_cost,
        card_show,
        pre_loan_credit,
        redirect_to_shop,
        attribution_deep_convert_cost,
        pre_loan_credit_cost,
        avg_click_cost,
        attribution_convert,
        attribution_next_day_open_cost,
        loan_completion_rate,
        click_download,
        loan_completion_cost,
        luban_order_roi,
        loan_completion,
        loan_credit,
        avg_show_cost,
        click_call_dy
        )
        VALUES
        <foreach collection="infos" item="info" separator=",">
      (
        #{info.accountId},
        #{info.playableId},
        #{info.playableUrl},
        #{info.playableName},
        #{info.playablePreviewUrl},
        #{info.playableOrientation},
        #{info.statDatetime},
        #{info.click},
        #{info.cost},
        #{info.active},
        #{info.downloadFinish},
        #{info.downloadStart},
        #{info.installFinish},
        #{info.register},
        #{info.payCount},
        #{info.inAppUv},
        #{info.inAppDetailUv},
        #{info.inAppCart},
        #{info.inAppOrder},
        #{info.inAppPay},
        #{info.phone},
        #{info.form},
        #{info.mapSearch},
        #{info.button},
        #{info.viewMaterial},
        #{info.qq},
        #{info.lottery},
        #{info.vote},
        #{info.redirect},
        #{info.shopping},
        #{info.consult},
        #{info.wechat},
        #{info.phoneConfirm},
        #{info.phoneConnect},
        #{info.consultEffective},
        #{info.totalPlay},
        #{info.validPlay},
        #{info.play25FeedBreak},
        #{info.play50FeedBreak},
        #{info.play75FeedBreak},
        #{info.play100FeedBreak},
        #{info.advancedCreativePhoneClick},
        #{info.advancedCreativeCounselClick},
        #{info.advancedCreativeFormClick},
        #{info.shareMaterial},
        #{info.commentMaterial},
        #{info.follow},
        #{info.homeVisited},
        #{info.iesChallengeClick},
        #{info.iesMusicClick},
        #{info.validPlayCost},
        #{info.advancedCreativeCouponAddition},
        #{info.convertMaterial},
        #{info.activePayCost},
        #{info.download},
        #{info.locationClick},
        #{info.playOverRate},
        #{info.ctr},
        #{info.wifiPlayRate},
        #{info.likeMaterial},
        #{info.activePayRate},
        #{info.activeCost},
        #{info.gameAddictionCost},
        #{info.gameAddiction},
        #{info.activeRate},
        #{info.gameAddictionRate},
        #{info.activeRegisterRate},
        #{info.downloadFinishCost},
        #{info.activeRegisterCost},
        #{info.showMaterial},
        #{info.convertRate},
        #{info.downloadFinishRate},
        #{info.installFinishRate},
        #{info.coupon},
        #{info.couponSinglePage},
        #{info.downloadStartCost},
        #{info.message},
        #{info.validPlayRate},
        #{info.averagePlayTimePerPlay},
        #{info.convertCost},
        #{info.installFinishCost},
        #{info.downloadStartRate},
        #{info.poiAddressClick},
        #{info.attributionConvertCost},
        #{info.clickWebsite},
        #{info.messageAction},
        #{info.advancedCreativeFormSubmit},
        #{info.lubanLiveSlidecartClickCnt},
        #{info.poiCollect},
        #{info.lubanOrderCnt},
        #{info.attributionNextDayOpenRate},
        #{info.attributionNextDayOpenCnt},
        #{info.loanCreditRate},
        #{info.loanCreditCost},
        #{info.lubanOrderStatAmount},
        #{info.lubanLiveEnterCnt},
        #{info.clickLandingPage},
        #{info.lubanLiveFollowCnt},
        #{info.clickShopwindow},
        #{info.attributionDeepConvert},
        #{info.lubanLivePayOrderCount},
        #{info.lubanLivePayOrderStatCost},
        #{info.cardShow},
        #{info.preLoanCredit},
        #{info.redirectToShop},
        #{info.attributionDeepConvertCost},
        #{info.preLoanCreditCost},
        #{info.avgClickCost},
        #{info.attributionConvert},
        #{info.attributionNextDayOpenCost},
        #{info.loanCompletionRate},
        #{info.clickDownload},
        #{info.loanCompletionCost},
        #{info.lubanOrderRoi},
        #{info.loanCompletion},
        #{info.loanCredit},
        #{info.avgShowCost},
        #{info.clickCallDy}
         )
        </foreach>
    </insert>

    <insert id="replaceMaterialRetry">
        REPLACE INTO ctop_bytedance_report_playable_retry
        (
            account_id,
            start_date,
            end_date,
            status,
            status_code,
            type
        )
        VALUES
        (
            #{retry.accountId},
            #{retry.startDate},
            #{retry.endDate},
            #{retry.status},
            #{retry.statusCode},
            #{retry.type}
        )

    </insert>

    <select id="getRetryList" resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableRetry">
            select
            account_id,
            start_date,
            end_date,
            status,
            type
        from
        ctop_bytedance_report_playable_retry
        where status = 0
    </select>

    <update id="updateRetry">
        update
        ctop_bytedance_report_playable_retry
        set
        status = 1
        where
        account_id = #{retry.accountId}
        and start_date = #{retry.startDate}
        and end_date = #{retry.endDate}
    </update>

</mapper>

