|
@@ -2,7 +2,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.EtlBytedanceReportVideoDailyMapper">
|
|
|
|
|
|
- <select id="getCtopMaterialAscriptionInfo" resultType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
|
|
|
+ <select id="getCtopMaterialAscriptionInfo"
|
|
|
+ resultType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
|
|
|
SELECT DISTINCT
|
|
|
md5,
|
|
|
cma.clip_id,
|
|
@@ -23,7 +24,8 @@
|
|
|
cma.plan_name is not null;
|
|
|
</select>
|
|
|
|
|
|
- <update id="updateOneBytedanceVideoInfo" parameterType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
|
|
|
+ <update id="updateOneBytedanceVideoInfo"
|
|
|
+ parameterType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
|
|
|
UPDATE etl_report_bytedance_video
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
<if test="etlReportBytedanceVideo.clipId!=null">clip_id=#{etlReportBytedanceVideo.clipId},</if>
|
|
@@ -61,67 +63,287 @@
|
|
|
</select>
|
|
|
<select id="etlBytedanceVideoInfo"
|
|
|
resultType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
|
|
|
- select
|
|
|
- (case when cmi.url is not null then cmi.url else '' end) 'url',
|
|
|
- (CASE when cmi.cover_url is null then ''
|
|
|
- ELSE cmi.cover_url end) 'cover_url',
|
|
|
- (case when cmi.material_name is null then '' else cmi.material_name end) 'material_name',
|
|
|
- (case when cbvi.signature is null then '' else cbvi.signature end)'md5',
|
|
|
- report.material_id 'material_id',
|
|
|
- cp.project_name 'project_name',
|
|
|
- cp.id as 'project_id',
|
|
|
- case when etlVideo.clip_name is null then '' else etlVideo.clip_name end 'clip_name',
|
|
|
- case when etlVideo.plan_name is null then '' else etlVideo.plan_name end 'plan_name',
|
|
|
- case when etlVideo.shot_name is null then '' else etlVideo.shot_name end 'shot_name',
|
|
|
- case when cmi.create_time is not null then cmi.create_time else '' end 'material_create_time',
|
|
|
- sum(report.cost) 'cost',
|
|
|
- sum(report.click) 'click',
|
|
|
- (case when sum(report.show_material)>0 and sum(report.click)>0 then round(sum(report.click)/sum(report.show_material)*100) else 0 end) 'ctr',
|
|
|
- sum(report.show_material) 'material_show',
|
|
|
- sum(report.convert_material) 'convert_material',
|
|
|
- (case when sum(report.convert_material)>0 and sum(report.click)>0 then round(sum(report.convert_material)/sum(report.click)*100) else 0 end) 'convert_rate',
|
|
|
- (case when sum(report.cost) >0 and sum(report.show_material)>0 then round(sum(report.cost)/sum(report.show_material)*1000,2) else 0 end) 'cpm',
|
|
|
- (case when sum(report.cost) >0 and sum(report.click)>0 then round(sum(report.cost)/sum(report.click),2) else 0 end) 'cpc',
|
|
|
- (case when sum(report.cost) >0 and sum(report.convert_material)>0 then round(sum(report.cost)/sum(report.convert_material),2) else 0 end) 'convert_cost',
|
|
|
- sum(report.download_start) 'download_start',
|
|
|
- sum(report.download_finish) 'download_finish',
|
|
|
- sum(report.active) 'active',
|
|
|
- sum(report.register) 'register',
|
|
|
- sum(report.next_day_open) 'next_day_open',
|
|
|
- sum(report.pay_count) 'active_pay_amount',
|
|
|
- (case when sum(report.cost) >0 and sum(report.pay_count)>0 then round(sum(report.cost)/sum(report.pay_count),2) else 0 end) 'active_pay_cost',
|
|
|
- (case when sum(report.cost) >0 and sum(report.next_day_open)>0 then round(sum(report.cost)/sum(report.next_day_open),2) else 0 end) 'next_day_open_cost',
|
|
|
- (case when sum(report.cost) >0 and sum(report.register)>0 then round(sum(report.cost)/sum(report.register),2) else 0 end) 'active_register_cost',
|
|
|
- (case when sum(report.cost) >0 and sum(report.active)>0 then round(sum(report.cost)/sum(report.active),2) else 0 end) 'active_cost',
|
|
|
- (case when sum(report.cost) >0 and sum(report.download_finish)>0 then round(sum(report.cost)/sum(report.download_finish),2) else 0 end) 'download_finish_cost',
|
|
|
- (case when sum(report.cost) >0 and sum(report.download_start)>0 then round(sum(report.cost)/sum(report.download_start),2) else 0 end) 'download_start_cost',
|
|
|
- (case when sum(report.download_start) >0 and sum(report.click)>0 then round(sum(report.download_start)/sum(report.click)*100,2) else 0 end) 'download_start_rate',
|
|
|
- (case when sum(report.download_finish) >0 and sum(report.download_start)>0 then round(sum(report.download_finish)/sum(report.download_start)*100,2) else 0 end) 'download_finish_rate',
|
|
|
- (case when sum(report.active) >0 and sum(report.click)>0 then round(sum(report.active)/sum(report.click)*100,2) else 0 end) 'active_rate',
|
|
|
- (case when sum(report.register) >0 and sum(report.active)>0 then round(sum(report.register)/sum(report.active)*100,2) else 0 end) 'active_register_rate',
|
|
|
- (case when sum(report.active) >0 and sum(report.next_day_open)>0 then round(sum(report.next_day_open)/sum(report.active)*100,2) else 0 end) 'next_day_open_rate',
|
|
|
- sum(report.form) 'form',
|
|
|
- (case when sum(report.cost) >0 and sum(report.valid_play)>0 then round(sum(report.cost)/sum(report.valid_play),2) else 0 end) 'valid_play_cost',
|
|
|
- sum(report.play75_feed_break) 'play75_feed_break',
|
|
|
- sum(report.play100_feed_break) 'play100_feed_break',
|
|
|
- sum(report.play25_feed_break) 'play25_feed_break',
|
|
|
- sum(report.play50_feed_break) 'play50_feed_break',
|
|
|
- sum(report.share_material) 'share_material',
|
|
|
- sum(report.follow) 'follow',
|
|
|
- sum(report.like_material) 'like_material',
|
|
|
- report.stat_datetime 'stat_datetime',
|
|
|
- report.account_id 'account_id'
|
|
|
- from ctop_bytedance_report_material_daily report
|
|
|
- left join ctop_user_allocation cua on cua.account_id = report.account_id
|
|
|
- left join (select account_id,material_id,signature from ctop_bytedance_video_info where account_id = #{accountId}) cbvi
|
|
|
- on report.account_id = cbvi.account_id and report.material_id = cbvi.material_id
|
|
|
- left join ctop_bytedance_video_etl_info etlVideo on etlVideo.video_code = cbvi.signature
|
|
|
- left join ctop_material_info cmi on cmi.code = cbvi.signature
|
|
|
- left join ctop_project cp on cp.id = cua.project_id
|
|
|
- where 1 = 1
|
|
|
- and report.stat_datetime = #{date}
|
|
|
- and report.account_id = #{accountId}
|
|
|
- group by report.material_id,report.account_id;
|
|
|
+ SELECT * from (
|
|
|
+ SELECT
|
|
|
+ t.*,
|
|
|
+ (case when t1.url is not null then t1.url else '' end) 'url',
|
|
|
+ (CASE when t1.cover_url is null then '' ELSE t1.cover_url end) 'cover_url',
|
|
|
+ (case when t1.material_name is null then '' else t1.material_name end) 'material_name',
|
|
|
+ (case when t1.create_time is not null then t1.create_time else '' end) 'material_create_time'
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ (CASE when cbvi.signature is null then '' ELSE cbvi.signature end) 'md5',
|
|
|
+ CONCAT(report.material_id, '-') 'material_id',
|
|
|
+ cp.project_name 'project_name',
|
|
|
+ cp.id AS 'project_id',
|
|
|
+ CASE
|
|
|
+ WHEN etlVideo.clip_name IS NULL THEN
|
|
|
+ ''
|
|
|
+ ELSE
|
|
|
+ etlVideo.clip_name
|
|
|
+ END 'clip_name',
|
|
|
+ CASE
|
|
|
+ WHEN etlVideo.plan_name IS NULL THEN
|
|
|
+ ''
|
|
|
+ ELSE
|
|
|
+ etlVideo.plan_name
|
|
|
+ END 'plan_name',
|
|
|
+ CASE
|
|
|
+ WHEN etlVideo.shot_name IS NULL THEN
|
|
|
+ ''
|
|
|
+ ELSE
|
|
|
+ etlVideo.shot_name
|
|
|
+ END 'shot_name',
|
|
|
+sum(report.cost) 'cost',
|
|
|
+ sum(report.click) 'click',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.show_material) > 0
|
|
|
+ AND sum(report.click) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.click) / sum(report.show_material) * 100
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'ctr',
|
|
|
+ sum(report.show_material) 'material_show',
|
|
|
+ sum(report.convert_material) 'convert_material',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.convert_material) > 0
|
|
|
+ AND sum(report.click) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.convert_material) / sum(report.click) * 100
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'convert_rate',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.show_material) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.show_material) * 1000,
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'cpm',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.click) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.click),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'cpc',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.convert_material) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.convert_material),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'convert_cost',
|
|
|
+ sum(report.download_start) 'download_start',
|
|
|
+ sum(report.download_finish) 'download_finish',
|
|
|
+ sum(report.active) 'active',
|
|
|
+ sum(report.register) 'register',
|
|
|
+ sum(report.next_day_open) 'next_day_open',
|
|
|
+ sum(report.pay_count) 'active_pay_amount',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.pay_count) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.pay_count),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'active_pay_cost',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.next_day_open) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.next_day_open),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'next_day_open_cost',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.register) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.register),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'active_register_cost',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.active) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.active),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'active_cost',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.download_finish) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.download_finish),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'download_finish_cost',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.download_start) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.download_start),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'download_start_cost',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.download_start) > 0
|
|
|
+ AND sum(report.click) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.download_start) / sum(report.click) * 100,
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'download_start_rate',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.download_finish) > 0
|
|
|
+ AND sum(report.download_start) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.download_finish) / sum(report.download_start) * 100,
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'download_finish_rate',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.active) > 0
|
|
|
+ AND sum(report.click) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.active) / sum(report.click) * 100,
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'active_rate',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.register) > 0
|
|
|
+ AND sum(report.active) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.register) / sum(report.active) * 100,
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'active_register_rate',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.active) > 0
|
|
|
+ AND sum(report.next_day_open) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.next_day_open) / sum(report.active) * 100,
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'next_day_open_rate',
|
|
|
+ sum(report.form) 'form',
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(report.cost) > 0
|
|
|
+ AND sum(report.valid_play) > 0 THEN
|
|
|
+ round(
|
|
|
+ sum(report.cost) / sum(report.valid_play),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+) 'valid_play_cost',
|
|
|
+ sum(report.play75_feed_break) 'play75_feed_break',
|
|
|
+ sum(report.play100_feed_break) 'play100_feed_break',
|
|
|
+ sum(report.play25_feed_break) 'play25_feed_break',
|
|
|
+ sum(report.play50_feed_break) 'play50_feed_break',
|
|
|
+ sum(report.share_material) 'share_material',
|
|
|
+ sum(report.follow) 'follow',
|
|
|
+ sum(report.like_material) 'like_material',
|
|
|
+ report.stat_datetime 'stat_datetime',
|
|
|
+ report.account_id 'account_id'
|
|
|
+ FROM
|
|
|
+ ctop_bytedance_report_material_daily report
|
|
|
+ LEFT JOIN ctop_user_allocation cua ON cua.account_id = report.account_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ account_id,
|
|
|
+ material_id,
|
|
|
+ signature
|
|
|
+ FROM
|
|
|
+ ctop_bytedance_video_info
|
|
|
+ WHERE
|
|
|
+ account_id = #{accountId}
|
|
|
+ GROUP BY material_id
|
|
|
+ ) cbvi ON report.account_id = cbvi.account_id
|
|
|
+ AND report.material_id = cbvi.material_id
|
|
|
+ LEFT JOIN ctop_bytedance_video_etl_info etlVideo ON etlVideo.video_code = cbvi.signature
|
|
|
+ LEFT JOIN ctop_project cp ON cp.id = cua.project_id
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ AND report.stat_datetime = #{date}
|
|
|
+ AND report.account_id = #{accountId}
|
|
|
+ GROUP BY
|
|
|
+ report.material_id,
|
|
|
+ report.account_id
|
|
|
+ ) t
|
|
|
+ LEFT JOIN ctop_material_info t1 ON t.md5 = t1.`code` ) t2
|
|
|
+ GROUP BY t2.md5
|
|
|
</select>
|
|
|
<select id="replaceEtlVideoInfo">
|
|
|
REPLACE INTO etl_report_bytedance_video(
|
|
@@ -234,5 +456,4 @@
|
|
|
</update>
|
|
|
|
|
|
|
|
|
-
|
|
|
</mapper>
|