|
|
@@ -89,24 +89,63 @@
|
|
|
</select>
|
|
|
<select id="adHourData" resultType="java.util.Map">
|
|
|
select
|
|
|
- <include refid="costAmount"/>,
|
|
|
- <include refid="realCostAmount"/>,
|
|
|
- <include refid="payAmount"/>,
|
|
|
- <include refid="shareIaaAmount"/>,
|
|
|
- <include refid="realProfit"/>,
|
|
|
- <include refid="waterProfit"/>,
|
|
|
- <include refid="realRoi"/>,
|
|
|
- <include refid="endAmount"/>
|
|
|
+ round(ifnull(sum(cost_amount),0), 2) as cost_amount,
|
|
|
+ round(ifnull(sum(mj_cost_amount),0), 2) as mj_cost_amount,
|
|
|
+ round(ifnull(sum(dj_cost_amount),0), 2) as dj_cost_amount,
|
|
|
+ round(ifnull(sum(real_cost_amount), 0), 2) as real_cost_amount,
|
|
|
+ round(ifnull(sum(dj_real_cost_amount), 0), 2) as dj_real_cost_amount,
|
|
|
+ round(ifnull(sum(mj_real_cost_amount), 0), 2) as mj_real_cost_amount,
|
|
|
+ round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
+ round(ifnull(sum(dj_pay_amount), 0), 2) AS dj_pay_amount,
|
|
|
+ round(ifnull(sum(mj_pay_amount), 0), 2) AS mj_pay_amount,
|
|
|
+ round(ifnull(sum(share_iaa_amount), 0), 2) as share_iaa_amount,
|
|
|
+ round(ifnull(sum(dj_share_iaa_amount), 0), 2) as dj_share_iaa_amount,
|
|
|
+ round(ifnull(sum(mj_share_iaa_amount), 0), 2) as mj_share_iaa_amount,
|
|
|
+ round(ifnull(sum(share_iaa_amount_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(sum(real_cost_amount), 0), 2) AS real_profit,
|
|
|
+ round(ifnull(sum(dj_share_iaa_amount_3), 0) + ifnull(sum(dj_share_pay_amount), 0) - ifnull(sum(dj_real_cost_amount), 0), 2) AS dj_real_profit,
|
|
|
+ round(ifnull(sum(mj_share_iaa_amount_3), 0) + ifnull(sum(mj_share_pay_amount), 0) - ifnull(sum(mj_real_cost_amount), 0), 2) AS mj_real_profit,
|
|
|
+ round(ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0), 2) AS water_profit,
|
|
|
+ round(ifnull(sum(dj_iaa_amount), 0) + ifnull(sum(dj_pay_amount), 0) - ifnull(sum(dj_cost_amount), 0), 2) AS dj_water_profit,
|
|
|
+ round(ifnull(sum(mj_iaa_amount), 0) + ifnull(sum(mj_pay_amount), 0) - ifnull(sum(mj_cost_amount), 0), 2) AS mj_water_profit,
|
|
|
+ concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount_3),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
|
|
|
+ concat(round(if(ifnull(sum(dj_real_cost_amount),0)=0, 0, (ifnull(sum(dj_share_iaa_amount_3),0)+ifnull(sum(dj_share_pay_amount),0))/sum(dj_real_cost_amount)*100), 2), '%') AS dj_real_roi,
|
|
|
+ concat(round(if(ifnull(sum(mj_real_cost_amount),0)=0, 0, (ifnull(sum(mj_share_iaa_amount_3),0)+ifnull(sum(mj_share_pay_amount),0))/sum(mj_real_cost_amount)*100), 2), '%') AS mj_real_roi,
|
|
|
+ round(ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0), 2) as end_amount,
|
|
|
+ round(ifnull(sum(dj_share_iaa_amount), 0) + ifnull(sum(dj_share_pay_amount), 0), 2) as dj_end_amount,
|
|
|
+ round(ifnull(sum(mj_share_iaa_amount), 0) + ifnull(sum(mj_share_pay_amount), 0), 2) as mj_end_amount
|
|
|
from
|
|
|
- (select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
- from application.media_ad_report_hourly
|
|
|
- where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
|
|
|
+ (select sum(cost_amount) as cost_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(cost_amount, 0) else 0 end) as dj_cost_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(cost_amount, 0) else 0 end) as mj_cost_amount,
|
|
|
+ sum(real_cost_amount) as real_cost_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(real_cost_amount, 0) else 0 end) as dj_real_cost_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(real_cost_amount, 0) else 0 end) as mj_real_cost_amount
|
|
|
+ from application.media_ad_report_hourly t1
|
|
|
+ left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
|
|
|
+ join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
|
|
|
+ where stat_date = #{date} and `hour`= #{hour}
|
|
|
+ and t2.business_line in (1,6,7,4,8,9,10)
|
|
|
) tb1,
|
|
|
- (select sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
|
|
|
+ (select sum(pay_amount) as pay_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(pay_amount, 0) else 0 end) as dj_pay_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(pay_amount, 0) else 0 end) as mj_pay_amount,
|
|
|
+ sum(share_iaa_amount) as share_iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount, 0) else 0 end) as dj_share_iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount, 0) else 0 end) as mj_share_iaa_amount,
|
|
|
sum(share_iaa_amount_3) as share_iaa_amount_3,
|
|
|
- sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
|
|
|
- from application.user_data_report_hourly
|
|
|
- where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as dj_share_iaa_amount_3,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as mj_share_iaa_amount_3,
|
|
|
+ sum(share_pay_amount) as share_pay_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(share_pay_amount, 0) else 0 end) as dj_share_pay_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(share_pay_amount, 0) else 0 end) as mj_share_pay_amount,
|
|
|
+ sum(iaa_amount) as iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(iaa_amount, 0) else 0 end) as dj_iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(iaa_amount, 0) else 0 end) as mj_iaa_amount
|
|
|
+ from application.user_data_report_hourly t1
|
|
|
+ left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
|
|
|
+ join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
|
|
|
+ where stat_date = #{date} and `hour`= #{hour}
|
|
|
+ and t2.business_line in (1,6,7,4,8,9,10)
|
|
|
) tb2
|
|
|
</select>
|
|
|
<select id="tmpTopMovie" resultType="java.util.Map">
|
|
|
@@ -163,31 +202,71 @@
|
|
|
|
|
|
<select id="adDailyData" resultType="java.util.Map">
|
|
|
select
|
|
|
- <include refid="costAmount"/>,
|
|
|
- <include refid="realCostAmount"/>,
|
|
|
- <include refid="payAmount"/>,
|
|
|
- <include refid="shareIaaAmount"/>,
|
|
|
- <include refid="realProfit"/>,
|
|
|
- <include refid="waterProfit"/>,
|
|
|
- <include refid="realRoi"/>,
|
|
|
- <include refid="endAmount"/>,
|
|
|
+ round(ifnull(sum(cost_amount),0), 2) as cost_amount,
|
|
|
+ round(ifnull(sum(mj_cost_amount),0), 2) as mj_cost_amount,
|
|
|
+ round(ifnull(sum(dj_cost_amount),0), 2) as dj_cost_amount,
|
|
|
+ round(ifnull(sum(real_cost_amount), 0), 2) as real_cost_amount,
|
|
|
+ round(ifnull(sum(dj_real_cost_amount), 0), 2) as dj_real_cost_amount,
|
|
|
+ round(ifnull(sum(mj_real_cost_amount), 0), 2) as mj_real_cost_amount,
|
|
|
+ round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
+ round(ifnull(sum(dj_pay_amount), 0), 2) AS dj_pay_amount,
|
|
|
+ round(ifnull(sum(mj_pay_amount), 0), 2) AS mj_pay_amount,
|
|
|
+ round(ifnull(sum(share_iaa_amount), 0), 2) as share_iaa_amount,
|
|
|
+ round(ifnull(sum(dj_share_iaa_amount), 0), 2) as dj_share_iaa_amount,
|
|
|
+ round(ifnull(sum(mj_share_iaa_amount), 0), 2) as mj_share_iaa_amount,
|
|
|
+ round(ifnull(sum(share_iaa_amount_3), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(sum(real_cost_amount), 0), 2) AS real_profit,
|
|
|
+ round(ifnull(sum(dj_share_iaa_amount_3), 0) + ifnull(sum(dj_share_pay_amount), 0) - ifnull(sum(dj_real_cost_amount), 0), 2) AS dj_real_profit,
|
|
|
+ round(ifnull(sum(mj_share_iaa_amount_3), 0) + ifnull(sum(mj_share_pay_amount), 0) - ifnull(sum(mj_real_cost_amount), 0), 2) AS mj_real_profit,
|
|
|
+ round(ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0), 2) AS water_profit,
|
|
|
+ round(ifnull(sum(dj_iaa_amount), 0) + ifnull(sum(dj_pay_amount), 0) - ifnull(sum(dj_cost_amount), 0), 2) AS dj_water_profit,
|
|
|
+ round(ifnull(sum(mj_iaa_amount), 0) + ifnull(sum(mj_pay_amount), 0) - ifnull(sum(mj_cost_amount), 0), 2) AS mj_water_profit,
|
|
|
+ concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount_3),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
|
|
|
+ concat(round(if(ifnull(sum(dj_real_cost_amount),0)=0, 0, (ifnull(sum(dj_share_iaa_amount_3),0)+ifnull(sum(dj_share_pay_amount),0))/sum(dj_real_cost_amount)*100), 2), '%') AS dj_real_roi,
|
|
|
+ concat(round(if(ifnull(sum(mj_real_cost_amount),0)=0, 0, (ifnull(sum(mj_share_iaa_amount_3),0)+ifnull(sum(mj_share_pay_amount),0))/sum(mj_real_cost_amount)*100), 2), '%') AS mj_real_roi,
|
|
|
+ round(ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0), 2) as end_amount,
|
|
|
+ round(ifnull(sum(dj_share_iaa_amount), 0) + ifnull(sum(dj_share_pay_amount), 0), 2) as dj_end_amount,
|
|
|
+ round(ifnull(sum(mj_share_iaa_amount), 0) + ifnull(sum(mj_share_pay_amount), 0), 2) as mj_end_amount,
|
|
|
date_format(max(update_time), '%Y-%m-%d %H:%i:%s') as update_time
|
|
|
from
|
|
|
- (select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount, max(update_time) as update_time
|
|
|
- from application.media_ad_report_daily
|
|
|
- where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
|
|
|
+ (select sum(cost_amount) as cost_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(cost_amount, 0) else 0 end) as dj_cost_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(cost_amount, 0) else 0 end) as mj_cost_amount,
|
|
|
+ sum(real_cost_amount) as real_cost_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(real_cost_amount, 0) else 0 end) as dj_real_cost_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(real_cost_amount, 0) else 0 end) as mj_real_cost_amount,
|
|
|
+ max(t1.update_time) as update_time
|
|
|
+ from application.media_ad_report_daily t1
|
|
|
+ left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
|
|
|
+ join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
|
|
|
+ where stat_date = #{date}
|
|
|
+ and t2.business_line in (1,6,7,4,8,9,10)
|
|
|
) tb1,
|
|
|
- (select sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
|
|
|
- sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount,
|
|
|
- sum(share_iaa_amount_3) as share_iaa_amount_3
|
|
|
- from application.user_data_report_daily
|
|
|
- where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
|
|
|
+ (select sum(pay_amount) as pay_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(pay_amount, 0) else 0 end) as dj_pay_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(pay_amount, 0) else 0 end) as mj_pay_amount,
|
|
|
+ sum(share_iaa_amount) as share_iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount, 0) else 0 end) as dj_share_iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount, 0) else 0 end) as mj_share_iaa_amount,
|
|
|
+ sum(share_iaa_amount_3) as share_iaa_amount_3,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as dj_share_iaa_amount_3,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(share_iaa_amount_3, 0) else 0 end) as mj_share_iaa_amount_3,
|
|
|
+ sum(share_pay_amount) as share_pay_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(share_pay_amount, 0) else 0 end) as dj_share_pay_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(share_pay_amount, 0) else 0 end) as mj_share_pay_amount,
|
|
|
+ sum(iaa_amount) as iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'DJ' then ifnull(iaa_amount, 0) else 0 end) as dj_iaa_amount,
|
|
|
+ sum(case t3.movie_type when 'MJ' then ifnull(iaa_amount, 0) else 0 end) as mj_iaa_amount
|
|
|
+ from application.user_data_report_daily t1
|
|
|
+ left join tidb.deepthink.mini_app_info t2 on t1.ma_appid = t2.app_id
|
|
|
+ join tidb.deepthink.all_moive t3 on t1.movie_id = t3.moive_id and find_in_set(t3.movie_source, t2.movie_sources) > 0
|
|
|
+ where stat_date = #{date}
|
|
|
+ and t2.business_line in (1,6,7,4,8,9,10)
|
|
|
) tb2
|
|
|
</select>
|
|
|
|
|
|
<select id="todayTopMovie" resultType="com.alibaba.fastjson.JSONObject" >
|
|
|
select
|
|
|
- tb4.ly_movie_name as movie_name, tb4.movie_project_source, tb6.dict_name as movie_project_source_name,
|
|
|
+ tb4.ly_movie_name as movie_name, tb4.movie_project_source, tb6.dict_name as movie_project_source_name, tb4.movie_type,
|
|
|
case
|
|
|
when (DATEDIFF(STR_TO_DATE(tb1.stat_date, '%Y%m%d'), STR_TO_DATE(tb4.project_ad_date, '%Y%m%d')) + 1) between 1
|
|
|
and 3 then '新剧1阶'
|
|
|
@@ -237,7 +316,7 @@
|
|
|
group by movie_id
|
|
|
) tb3 on tb1.movie_id=tb3.movie_id
|
|
|
left join
|
|
|
- (select moive_id, standard_movie_id, standard_movie_name, movie_source, movie_project_source,project_ad_date, ly_movie_name from tidb.deepthink.all_moive
|
|
|
+ (select moive_id, standard_movie_id, standard_movie_name, movie_source, movie_project_source,project_ad_date, ly_movie_name, movie_type from tidb.deepthink.all_moive
|
|
|
) tb4 on tb1.movie_id=tb4.moive_id
|
|
|
left join
|
|
|
(select movie_id, ifnull(sum(cost_amount), 0) as hour_cost_amount from application.media_ad_report_hourly
|
|
|
@@ -247,7 +326,7 @@
|
|
|
(select dict_key, dict_name from tidb.deepthink.dt_dictionary where select_key='movie_project_source'
|
|
|
) tb6 on tb4.movie_project_source=tb6.dict_key
|
|
|
where 1=1 and tb1.movie_id != '-9999'
|
|
|
- group by 1,2,3,4
|
|
|
+ group by 1,2,3,4,5
|
|
|
order by ${sort}
|
|
|
limit 20
|
|
|
</select>
|