|
@@ -0,0 +1,263 @@
|
|
|
+<?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.kuaishou.modules.report.mapper.EtlKuaishouReportAccountDailyMapper">
|
|
|
+ <insert id="replaceBatch">
|
|
|
+ replace into ctop_etl_kuaishou_report_account_daily(
|
|
|
+ stat_date,
|
|
|
+ account_id,
|
|
|
+ charge,
|
|
|
+ photo_show,
|
|
|
+ photo_click,
|
|
|
+ aclick,
|
|
|
+ bclick,
|
|
|
+ photo_share,
|
|
|
+ photo_comment,
|
|
|
+ photo_like,
|
|
|
+ follow,
|
|
|
+ cancel_follow,
|
|
|
+ report,
|
|
|
+ block,
|
|
|
+ negative,
|
|
|
+ download_started,
|
|
|
+ download_completed,
|
|
|
+ activation,
|
|
|
+ submit,
|
|
|
+ event_pay_first_day,
|
|
|
+ event_pay_purchase_amount_first_day,
|
|
|
+ event_pay,
|
|
|
+ event_pay_purchase_amount,
|
|
|
+ event_register,
|
|
|
+ event_jin_jian_app,
|
|
|
+ event_credit_grant_app,
|
|
|
+ event_order_paid,
|
|
|
+ event_order_paid_purchase_amount,
|
|
|
+ event_jin_jian_landing_page,
|
|
|
+ event_credit_grant_landing_page,
|
|
|
+ event_next_day_stay,
|
|
|
+ form_count,
|
|
|
+ play_3s_count
|
|
|
+ )
|
|
|
+ values
|
|
|
+ <foreach collection="list" item="appInfo" separator=",">
|
|
|
+ (
|
|
|
+ #{appInfo.statDate},
|
|
|
+ #{appInfo.accountId},
|
|
|
+ #{appInfo.charge},
|
|
|
+ #{appInfo.photoShow},
|
|
|
+ #{appInfo.photoClick},
|
|
|
+ #{appInfo.aclick},
|
|
|
+ #{appInfo.bclick},
|
|
|
+ #{appInfo.photoShare},
|
|
|
+ #{appInfo.photoComment},
|
|
|
+ #{appInfo.photoLike},
|
|
|
+ #{appInfo.follow},
|
|
|
+ #{appInfo.cancelFollow},
|
|
|
+ #{appInfo.report},
|
|
|
+ #{appInfo.block},
|
|
|
+ #{appInfo.negative},
|
|
|
+ #{appInfo.downloadStarted},
|
|
|
+ #{appInfo.downloadCompleted},
|
|
|
+ #{appInfo.activation},
|
|
|
+ #{appInfo.submit},
|
|
|
+ #{appInfo.eventPayFirstDay},
|
|
|
+ #{appInfo.eventPayPurchaseAmountFirstDay},
|
|
|
+ #{appInfo.eventPay},
|
|
|
+ #{appInfo.eventPayPurchaseAmount},
|
|
|
+ #{appInfo.eventRegister},
|
|
|
+ #{appInfo.eventJinJianApp},
|
|
|
+ #{appInfo.eventCreditGrantApp},
|
|
|
+ #{appInfo.eventOrderPaid},
|
|
|
+ #{appInfo.eventOrderPaidPurchaseAmount},
|
|
|
+ #{appInfo.eventJinJianLandingPage},
|
|
|
+ #{appInfo.eventCreditGrantLandingPage},
|
|
|
+ #{appInfo.eventNextDayStay},
|
|
|
+ #{appInfo.formCount},
|
|
|
+ #{appInfo.play3sCount}
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getOnedayAggregatebyDaily"
|
|
|
+ resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly">
|
|
|
+ SELECT stat_date,
|
|
|
+ IFNULL(SUM(charge), 0) as 'charge',
|
|
|
+ SUM(photo_show) as 'photoShow',
|
|
|
+ SUM(photo_click) as 'photoClick',
|
|
|
+ SUM(aclick) as 'aclick',
|
|
|
+ SUM(bclick) as 'bclick',
|
|
|
+ SUM(photo_share) as 'photoShare',
|
|
|
+ SUM(photo_comment) as 'photoComment',
|
|
|
+ SUM(photo_like) as 'photoLike',
|
|
|
+ SUM(follow) as 'follow',
|
|
|
+ SUM(cancel_follow) as 'cancelFollow',
|
|
|
+ SUM(report) as 'report',
|
|
|
+ SUM(block) as 'block',
|
|
|
+ SUM(negative) as 'negative',
|
|
|
+ SUM(download_started) as 'downloadStarted',
|
|
|
+ SUM(download_completed) as 'downloadCompleted',
|
|
|
+ SUM(activation) as 'activation',
|
|
|
+ SUM(submit) as 'submit',
|
|
|
+ SUM(event_pay_first_day) as 'eventPayFirstDay',
|
|
|
+ SUM(event_pay_purchase_amount_first_day) as 'eventPayPurchaseAmountFirstDay',
|
|
|
+ SUM(event_pay) as 'eventPay',
|
|
|
+ SUM(event_pay_purchase_amount) as 'eventPayPurchaseAmount',
|
|
|
+ SUM(event_register) as 'eventRegister',
|
|
|
+ SUM(event_jin_jian_app) as 'eventJinJianApp',
|
|
|
+ SUM(event_credit_grant_app) as 'eventCreditGrantApp',
|
|
|
+ SUM(event_order_paid) as 'eventOrderPaid',
|
|
|
+ SUM(event_order_paid_purchase_amount) as 'eventOrderPaidPurchaseAmount',
|
|
|
+ SUM(event_jin_jian_landing_page) as 'eventJinJianLandingPage',
|
|
|
+ SUM(event_credit_grant_landing_page) as 'eventCreditGrantLandingPage',
|
|
|
+ SUM(event_next_day_stay) as 'eventNextDayStay',
|
|
|
+ SUM(form_count) as 'formCount',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(activation), 2), 0) as 'activationCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(activation) * 1000, 2), 0) as 'impression1kCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(photo_click), 2), 0) as 'photoClickCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(bclick), 2), 0) as 'actionCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(download_started), 2), 0) as 'downloadStartedCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(download_completed), 2), 0) as 'downloadCompletedCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(form_count), 2), 0) as 'formCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_pay_first_day), 2), 0) as 'eventPayFirstDayCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_pay), 2), 0) as 'eventPayCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_register), 2), 0) as 'eventRegisterCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_next_day_stay), 2), 0) as 'eventNextDayStayCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_app), 2), 0) as 'eventJinJianAppCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_app), 2), 0) as 'eventCreditGrantAppCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_landing_page), 2), 0) as 'eventJinJianLandingPageCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_landing_page), 2),
|
|
|
+ 0) as 'eventCreditGrantLandingPageCost',
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(submit), 2), 0) as 'submitCost',
|
|
|
+ IFNULL(ROUND(SUM(event_pay_purchase_amount_first_day) / SUM(charge) * 100, 2),
|
|
|
+ 0) as 'eventPayFirstDayRoi',
|
|
|
+ IFNULL(ROUND(SUM(event_pay_purchase_amount) / SUM(charge) * 100, 2), 0) as 'eventPayRoi',
|
|
|
+ IFNULL(ROUND(SUM(bclick) / SUM(activation) * 100, 2), 0) as 'actionRatio',
|
|
|
+ IFNULL(ROUND(SUM(photo_click) / SUM(photo_show) * 100, 2), 0) as 'photoClickRatio',
|
|
|
+ IFNULL(ROUND(SUM(download_started) / SUM(bclick) * 100, 2), 0) as 'downloadStartedRatio',
|
|
|
+ IFNULL(ROUND(SUM(download_completed) / SUM(download_started) * 100, 2), 0) as 'downloadCompletedRatio',
|
|
|
+ IFNULL(ROUND(SUM(activation) / SUM(download_completed) * 100, 2), 0) as 'activationRatio',
|
|
|
+ IFNULL(ROUND(SUM(event_register) / SUM(activation) * 100, 2), 0) as 'eventRegisterRatio',
|
|
|
+ IFNULL(ROUND(SUM(event_next_day_stay) / SUM(activation) * 100, 2), 0) as 'eventNextDayStayRatio',
|
|
|
+ IFNULL(ROUND(SUM(event_credit_grant_app) / SUM(event_jin_jian_app) * 100, 2),
|
|
|
+ 0) as 'eventCreditGrantAppRatio',
|
|
|
+ IFNULL(ROUND(SUM(form_count) / SUM(bclick) * 100, 2), 0) as 'formActionRatio',
|
|
|
+ IFNULL(ROUND(SUM(submit) / SUM(bclick) * 100, 2), 0) as 'submitRatio'
|
|
|
+ FROM ctop_etl_kuaishou_report_account_daily
|
|
|
+ WHERE account_id = #{accountId}
|
|
|
+ AND stat_date >= #{startTime}
|
|
|
+ AND stat_date <= #{endTime}
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getOnedayEtlReportList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT
|
|
|
+ <if test="type == 'alone'">
|
|
|
+ ${value} as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="type == 'more'">
|
|
|
+ <if test="value == 'activationCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(activation), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'impression1kCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(aclick) * 1000, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'photoClickCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(photo_click), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'actionCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(bclick), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'play3sRatio'">
|
|
|
+ IFNULL(ROUND(SUM(play_3s_count) / SUM(photo_show) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'downloadStartedCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(download_started), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'downloadCompletedCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(download_completed), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'formCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(form_count), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventPayFirstDayCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_pay_first_day), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventPayCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_pay), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventRegisterCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_register), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventNextDayStayCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_next_day_stay), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventJinJianAppCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_app), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventCreditGrantAppCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_app), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventJinJianLandingPageCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_landing_page), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventCreditGrantLandingPageCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_landing_page), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'submitCost'">
|
|
|
+ IFNULL(ROUND(SUM(charge) / SUM(submit), 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventPayFirstDayRoi'">
|
|
|
+ IFNULL(ROUND(SUM(event_pay_purchase_amount_first_day) / SUM(charge) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventPayRoi'">
|
|
|
+ IFNULL(ROUND(SUM(event_pay_purchase_amount) / SUM(charge) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'actionRatio'">
|
|
|
+ IFNULL(ROUND(SUM(bclick) / SUM(aclick) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'photoClickRatio'">
|
|
|
+ IFNULL(ROUND(SUM(photo_click) / SUM(photo_show) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'downloadStartedRatio'">
|
|
|
+ IFNULL(ROUND(SUM(download_started) / SUM(bclick) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'downloadCompletedRatio'">
|
|
|
+ IFNULL(ROUND(SUM(download_completed) / SUM(download_started) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'activationRatio'">
|
|
|
+ IFNULL(ROUND(SUM(activation) / SUM(download_completed) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventRegisterRatio'">
|
|
|
+ IFNULL(ROUND(SUM(event_register) / SUM(activation) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventNextDayStayRatio'">
|
|
|
+ IFNULL(ROUND(SUM(event_next_day_stay) / SUM(activation) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'eventCreditGrantAppRatio'">
|
|
|
+ IFNULL(ROUND(SUM(event_credit_grant_app) / SUM(event_jin_jian_app) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'formActionRatio'">
|
|
|
+ IFNULL(ROUND(SUM(form_count) / SUM(bclick) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ <if test="value == 'submitRatio'">
|
|
|
+ IFNULL(ROUND(SUM(submit) / SUM(bclick) * 100, 2), 0) as 'value',
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ stat_date as 'statDate'
|
|
|
+ FROM ctop_etl_kuaishou_report_account_daily
|
|
|
+ WHERE account_id = #{accountId}
|
|
|
+ AND stat_date >= #{startTime}
|
|
|
+ AND stat_date <= #{endTime}
|
|
|
+ group by stat_date
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getMaxChargeAccountId" resultType="java.lang.Long">
|
|
|
+ SELECT t1.account_id
|
|
|
+ FROM ctop_user_allocation t1
|
|
|
+ INNER JOIN ctop_kuaishou_report_hourly_account t2 ON t1.account_id = t2.account_id
|
|
|
+ where t2.stat_date = DATE_FORMAT(now(), '%Y-%m-%d')
|
|
|
+ AND t1.user_id = #{userId}
|
|
|
+ order by charge desc limit 1
|
|
|
+ </select>
|
|
|
+</mapper>
|