|
@@ -6,28 +6,37 @@
|
|
|
where stat_date = ${date} limit 1
|
|
where stat_date = ${date} limit 1
|
|
|
</select>
|
|
</select>
|
|
|
<select id="tmpPushData" resultType="java.util.Map">
|
|
<select id="tmpPushData" resultType="java.util.Map">
|
|
|
- select concat(round(if(ifnull(sum(cost_amount),0)=0, 0, (ifnull(sum(iaa_amount),0)+ifnull(sum(pay_amount), 0))/sum(cost_amount)*100 ), 2), '%') AS water_roi,
|
|
|
|
|
- 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,
|
|
|
|
|
- ifnull(sum(cost_amount),0) AS cost_amount,
|
|
|
|
|
- round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
|
|
- ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(round(sum(real_cost_amount), 2), 0) AS real_profit,
|
|
|
|
|
- ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0) AS water_profit,
|
|
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount
|
|
|
|
|
|
|
+ SELECT concat(round(if(ifnull(SUM(cost_amount), 0) = 0, 0,
|
|
|
|
|
+ (ifnull(SUM(iaa_amount), 0) + ifnull(SUM(pay_amount), 0)) / SUM(cost_amount) * 100), 2),
|
|
|
|
|
+ '%') AS water_roi,
|
|
|
|
|
+ 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,
|
|
|
|
|
+ ifnull(SUM(cost_amount), 0) AS cost_amount,
|
|
|
|
|
+ round(ifnull(SUM(pay_amount), 0), 2) AS pay_amount,
|
|
|
|
|
+ ifnull(SUM(share_iaa_amount), 0) AS share_iaa_amount,
|
|
|
|
|
+ ifnull(SUM(share_iaa_amount), 0) + ifnull(SUM(share_pay_amount), 0) -
|
|
|
|
|
+ ifnull(round(SUM(real_cost_amount), 2), 0) AS real_profit,
|
|
|
|
|
+ ifnull(SUM(iaa_amount), 0) + ifnull(SUM(pay_amount), 0) - ifnull(SUM(cost_amount), 0) AS water_profit,
|
|
|
|
|
+ ifnull(SUM(share_iaa_amount), 0) + ifnull(SUM(share_pay_amount), 0) AS end_amount
|
|
|
|
|
|
|
|
- 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 deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- ) tb1,
|
|
|
|
|
- (select sum(pay_amount) as pay_amount,
|
|
|
|
|
- sum(iaa_amount) as iaa_amount,
|
|
|
|
|
- ifnull(round(sum(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)),2), 0) as share_iaa_amount_3,
|
|
|
|
|
- sum(share_pay_amount) as share_pay_amount,
|
|
|
|
|
- sum(share_iaa_amount) as share_iaa_amount
|
|
|
|
|
- from application.user_data_report_daily
|
|
|
|
|
- where stat_date = ${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- ) tb2
|
|
|
|
|
|
|
+ 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 deepthink.mini_app_info WHERE business_type IN (1, 3, 8))) tb1,
|
|
|
|
|
+ (SELECT SUM(pay_amount) AS pay_amount,
|
|
|
|
|
+ SUM(iaa_amount) AS iaa_amount,
|
|
|
|
|
+
|
|
|
|
|
+ round(ifnull(if(SUM(share_iaa_amount_3) > 0, SUM(share_iaa_amount_3), SUM(share_iaa_amount)), 0),
|
|
|
|
|
+ 2) AS share_iaa_amount_3,
|
|
|
|
|
+
|
|
|
|
|
+ SUM(share_pay_amount) AS share_pay_amount,
|
|
|
|
|
+ SUM(share_iaa_amount) AS share_iaa_amount
|
|
|
|
|
+ FROM application.user_data_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))) tb2
|
|
|
</select>
|
|
</select>
|
|
|
<select id="adHourData" resultType="java.util.Map">
|
|
<select id="adHourData" resultType="java.util.Map">
|
|
|
select concat(round(if(ifnull(sum(cost_amount),0)=0, 0, (ifnull(sum(iaa_amount),0)+ifnull(sum(pay_amount), 0))/sum(cost_amount)*100 ), 2), '%') AS water_roi,
|
|
select concat(round(if(ifnull(sum(cost_amount),0)=0, 0, (ifnull(sum(iaa_amount),0)+ifnull(sum(pay_amount), 0))/sum(cost_amount)*100 ), 2), '%') AS water_roi,
|
|
@@ -50,51 +59,83 @@
|
|
|
) tb2
|
|
) tb2
|
|
|
</select>
|
|
</select>
|
|
|
<select id="tmpTopMovie" resultType="java.util.Map">
|
|
<select id="tmpTopMovie" resultType="java.util.Map">
|
|
|
- select tb4.standard_movie_id, tb4.standard_movie_name as movie_name,
|
|
|
|
|
- group_concat(distinct case tb4.movie_source when 2 then 2 else 1 end) as movie_source,
|
|
|
|
|
- rank() over (order by sum(iaa_amount)+sum(pay_amount) desc) as rk,
|
|
|
|
|
- round(sum(share_pay_amount)+sum(share_iaa_amount),2) as share_end_amount, sum(iaa_amount)+sum(pay_amount) as end_amount,
|
|
|
|
|
- sum(cost_amount) as cost_amount,
|
|
|
|
|
- round(sum(real_cost_amount),2) as real_cost_amount,
|
|
|
|
|
- concat(round(if(ifnull(sum(cost_amount),0)=0, 0, (sum(iaa_amount)+sum(pay_amount))/sum(cost_amount)*100), 2), '%') AS water_roi,
|
|
|
|
|
- concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (sum(share_iaa_amount_3)+sum(share_pay_amount))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
|
|
|
|
|
- concat(round(if(ifnull(sum(iaa_real_cost_amount),0)=0, 0, sum(share_iaa_amount_3)/sum(iaa_real_cost_amount)*100), 2), '%') AS iaa_roi,
|
|
|
|
|
- concat(round(if(ifnull(sum(iap_real_cost_amount),0)=0, 0, sum(share_pay_amount)/sum(iap_real_cost_amount)*100), 2), '%') AS iap_roi
|
|
|
|
|
- from
|
|
|
|
|
- (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- union select movie_id from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- ) tb1
|
|
|
|
|
- left join
|
|
|
|
|
- (select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
|
|
|
- sum(iap_cost_amount) as iap_cost_amount, sum(iap_real_cost_amount) as iap_real_cost_amount,
|
|
|
|
|
- sum(iaa_cost_amount)+sum(iap_cost_amount) as cost_amount,
|
|
|
|
|
- sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
|
|
- from
|
|
|
|
|
- (select product_id, round(ifnull(sum(cost_amount),0),2) as iaa_cost_amount, sum(real_cost_amount) as iaa_real_cost_amount, 0 as iap_cost_amount, 0 as iap_real_cost_amount
|
|
|
|
|
- from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAA')
|
|
|
|
|
- group by product_id
|
|
|
|
|
- union all
|
|
|
|
|
- select product_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,round(ifnull(sum(cost_amount),0),2) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
|
|
- from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAP')
|
|
|
|
|
- group by product_id) subt2
|
|
|
|
|
- group by product_id
|
|
|
|
|
- ) tb2 on tb1.product_id=tb2.product_id
|
|
|
|
|
- left join
|
|
|
|
|
- (select movie_id, ifnull(sum(iaa_amount), 0) as iaa_amount,
|
|
|
|
|
- ifnull(sum(pay_amount), 0) as pay_amount,
|
|
|
|
|
- ifnull(sum(share_pay_amount), 0) as share_pay_amount,
|
|
|
|
|
- ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
|
|
- round(ifnull(sum(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)), 0),2) as share_iaa_amount_3
|
|
|
|
|
- from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- group by movie_id
|
|
|
|
|
- ) tb3 on tb1.product_id=tb3.movie_id
|
|
|
|
|
- left join
|
|
|
|
|
- (select moive_id, standard_movie_id, standard_movie_name, movie_source from deepthink.all_moive
|
|
|
|
|
- ) tb4 on tb1.product_id=tb4.moive_id
|
|
|
|
|
- where 1=1 and tb1.product_id!='-9999'
|
|
|
|
|
- group by tb4.standard_movie_name
|
|
|
|
|
- order by sum(iaa_amount)+sum(pay_amount) desc
|
|
|
|
|
- limit 10
|
|
|
|
|
|
|
+ SELECT tb4.standard_movie_id,
|
|
|
|
|
+ tb4.standard_movie_name AS movie_name,
|
|
|
|
|
+ group_concat(DISTINCT CASE tb4.movie_source WHEN 2 THEN 2 ELSE 1 END) AS movie_source,
|
|
|
|
|
+ rank() over (ORDER BY SUM(iaa_amount)+SUM(pay_amount) DESC) AS rk, round(SUM(share_pay_amount) + SUM(share_iaa_amount), 2) AS share_end_amount,
|
|
|
|
|
+ SUM(iaa_amount) + SUM(pay_amount) AS end_amount,
|
|
|
|
|
+ SUM(cost_amount) AS cost_amount,
|
|
|
|
|
+ round(SUM(real_cost_amount), 2) AS real_cost_amount,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(cost_amount), 0) = 0, 0,
|
|
|
|
|
+ (SUM(iaa_amount) + SUM(pay_amount)) / SUM(cost_amount) * 100), 2), '%') AS water_roi,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(real_cost_amount), 0) = 0, 0,
|
|
|
|
|
+ (SUM(share_iaa_amount_3) + SUM(share_pay_amount)) / SUM(real_cost_amount) * 100), 2),
|
|
|
|
|
+ '%') AS real_roi,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(iaa_real_cost_amount), 0) = 0, 0,
|
|
|
|
|
+ SUM(share_iaa_amount_3) / SUM(iaa_real_cost_amount) * 100), 2), '%') AS iaa_roi,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(iap_real_cost_amount), 0) = 0, 0,
|
|
|
|
|
+ SUM(share_pay_amount) / SUM(iap_real_cost_amount) * 100), 2), '%') AS iap_roi
|
|
|
|
|
+ FROM (SELECT product_id
|
|
|
|
|
+ FROM application.media_product_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))
|
|
|
|
|
+ UNION
|
|
|
|
|
+ SELECT movie_id
|
|
|
|
|
+ FROM application.user_data_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))) tb1
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (SELECT product_id,
|
|
|
|
|
+ SUM(iaa_cost_amount) AS iaa_cost_amount,
|
|
|
|
|
+ SUM(iaa_real_cost_amount) AS iaa_real_cost_amount,
|
|
|
|
|
+ SUM(iap_cost_amount) AS iap_cost_amount,
|
|
|
|
|
+ SUM(iap_real_cost_amount) AS iap_real_cost_amount,
|
|
|
|
|
+ SUM(iaa_cost_amount) + SUM(iap_cost_amount) AS cost_amount,
|
|
|
|
|
+ SUM(iaa_real_cost_amount) + SUM(iap_real_cost_amount) AS real_cost_amount
|
|
|
|
|
+ FROM (SELECT product_id,
|
|
|
|
|
+ round(ifnull(SUM(cost_amount), 0), 2) AS iaa_cost_amount,
|
|
|
|
|
+ SUM(real_cost_amount) AS iaa_real_cost_amount,
|
|
|
|
|
+ 0 AS iap_cost_amount,
|
|
|
|
|
+ 0 AS iap_real_cost_amount
|
|
|
|
|
+ FROM application.media_product_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id
|
|
|
|
|
+ FROM deepthink.mini_app_info
|
|
|
|
|
+ WHERE business_type IN (1, 3, 8) AND business_method = 'IAA')
|
|
|
|
|
+ GROUP BY product_id
|
|
|
|
|
+ UNION ALL
|
|
|
|
|
+ SELECT product_id,
|
|
|
|
|
+ 0 AS iaa_cost_amount,
|
|
|
|
|
+ 0 AS iaa_real_cost_amount,
|
|
|
|
|
+ round(ifnull(SUM(cost_amount), 0), 2) AS cost_amount,
|
|
|
|
|
+ SUM(real_cost_amount) AS real_cost_amount
|
|
|
|
|
+ FROM application.media_product_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id
|
|
|
|
|
+ FROM deepthink.mini_app_info
|
|
|
|
|
+ WHERE business_type IN (1, 3, 8) AND business_method = 'IAP')
|
|
|
|
|
+ GROUP BY product_id) subt2
|
|
|
|
|
+ GROUP BY product_id) tb2 ON tb1.product_id = tb2.product_id
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (SELECT movie_id,
|
|
|
|
|
+ ifnull(SUM(iaa_amount), 0) AS iaa_amount,
|
|
|
|
|
+ ifnull(SUM(pay_amount), 0) AS pay_amount,
|
|
|
|
|
+ ifnull(SUM(share_pay_amount), 0) AS share_pay_amount,
|
|
|
|
|
+ ifnull(SUM(share_iaa_amount), 0) AS share_iaa_amount,
|
|
|
|
|
+ round(ifnull(if(SUM(share_iaa_amount_3) > 0, SUM(share_iaa_amount_3), SUM(share_iaa_amount)), 0),
|
|
|
|
|
+ 2) AS share_iaa_amount_3
|
|
|
|
|
+ FROM application.user_data_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))
|
|
|
|
|
+ GROUP BY movie_id) tb3 ON tb1.product_id = tb3.movie_id
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (SELECT moive_id, standard_movie_id, standard_movie_name, movie_source FROM deepthink.all_moive) tb4
|
|
|
|
|
+ ON tb1.product_id = tb4.moive_id
|
|
|
|
|
+ WHERE 1 = 1
|
|
|
|
|
+ AND tb1.product_id!='-9999'
|
|
|
|
|
+ GROUP BY tb4.standard_movie_name
|
|
|
|
|
+ ORDER BY SUM (iaa_amount)+ SUM (pay_amount) DESC
|
|
|
|
|
+ limit 10
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="adDailyData" resultType="java.util.Map">
|
|
<select id="adDailyData" resultType="java.util.Map">
|
|
@@ -120,54 +161,89 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="todayTopMovie" resultType="com.alibaba.fastjson.JSONObject" >
|
|
<select id="todayTopMovie" resultType="com.alibaba.fastjson.JSONObject" >
|
|
|
- select tb4.standard_movie_id,
|
|
|
|
|
- tb4.standard_movie_name as movie_name,
|
|
|
|
|
- group_concat(distinct case tb4.movie_source when 2 then 2 else 1 end) as movie_source,
|
|
|
|
|
- sum(share_iaa_amount)+sum(share_pay_amount) as share_end_amount, sum(end_amount) as end_amount,
|
|
|
|
|
- sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount,
|
|
|
|
|
- concat(round(if(ifnull(sum(cost_amount),0)=0, 0, sum(end_amount)/sum(cost_amount)*100), 2), '%') AS water_roi,
|
|
|
|
|
- concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (sum(share_iaa_amount_3)+sum(share_pay_amount))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
|
|
|
|
|
- concat(round(if(ifnull(sum(iaa_real_cost_amount),0)=0, 0, sum(share_iaa_amount_3)/sum(iaa_real_cost_amount)*100), 2), '%') AS iaa_roi,
|
|
|
|
|
- concat(round(if(ifnull(sum(iap_real_cost_amount),0)=0, 0, sum(share_pay_amount)/sum(iap_real_cost_amount)*100), 2), '%') AS iap_roi,
|
|
|
|
|
- round(ifnull(sum(hour_cost_amount), 0), 2) as hour_cost_amount
|
|
|
|
|
- from
|
|
|
|
|
- (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- union select movie_id from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))) tb1
|
|
|
|
|
- left join
|
|
|
|
|
- (
|
|
|
|
|
- select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
|
|
|
- sum(iap_cost_amount) as iap_cost_amount, sum(iap_real_cost_amount) as iap_real_cost_amount,
|
|
|
|
|
- sum(iaa_cost_amount)+sum(iap_cost_amount) as cost_amount,
|
|
|
|
|
- sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
|
|
- from
|
|
|
|
|
- (select product_id, round(ifnull(sum(cost_amount),0),2) as iaa_cost_amount, sum(real_cost_amount) as iaa_real_cost_amount, 0 as iap_cost_amount, 0 as iap_real_cost_amount
|
|
|
|
|
- from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAA')
|
|
|
|
|
- group by product_id
|
|
|
|
|
- union all
|
|
|
|
|
- select product_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,round(ifnull(sum(cost_amount),0),2) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
|
|
- from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8) and business_method='IAP')
|
|
|
|
|
- group by product_id) subt2
|
|
|
|
|
- group by product_id
|
|
|
|
|
- ) tb2 on tb1.product_id=tb2.product_id
|
|
|
|
|
- left join
|
|
|
|
|
- (select movie_id, ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) as end_amount,
|
|
|
|
|
- round(ifnull(sum(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)), 0),2) as share_iaa_amount_3,
|
|
|
|
|
- ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
|
|
- ifnull(sum(share_pay_amount), 0) as share_pay_amount
|
|
|
|
|
- from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- group by movie_id
|
|
|
|
|
- ) tb3 on tb1.product_id=tb3.movie_id
|
|
|
|
|
- left join
|
|
|
|
|
- (select moive_id, standard_movie_id, standard_movie_name, movie_source from deepthink.all_moive
|
|
|
|
|
- ) tb4 on tb1.product_id=tb4.moive_id
|
|
|
|
|
- left join
|
|
|
|
|
- (select product_id, ifnull(sum(cost_amount), 0) as hour_cost_amount from application.media_product_report_hourly
|
|
|
|
|
- where stat_date=${date} and `hour`=${hour} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
|
|
|
- group by product_id) tb5 on tb1.product_id=tb5.product_id
|
|
|
|
|
- where 1=1 and tb1.product_id != '-9999'
|
|
|
|
|
- group by tb4.standard_movie_name
|
|
|
|
|
- order by sum(end_amount) desc
|
|
|
|
|
- limit 10
|
|
|
|
|
|
|
+ SELECT tb4.standard_movie_id,
|
|
|
|
|
+ tb4.standard_movie_name AS movie_name,
|
|
|
|
|
+ group_concat(DISTINCT CASE tb4.movie_source WHEN 2 THEN 2 ELSE 1 END) AS movie_source,
|
|
|
|
|
+ SUM(share_iaa_amount) + SUM(share_pay_amount) AS share_end_amount,
|
|
|
|
|
+ SUM(end_amount) AS end_amount,
|
|
|
|
|
+ SUM(cost_amount) AS cost_amount,
|
|
|
|
|
+ SUM(real_cost_amount) AS real_cost_amount,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(cost_amount), 0) = 0, 0, SUM(end_amount) / SUM(cost_amount) * 100), 2),
|
|
|
|
|
+ '%') AS water_roi,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(real_cost_amount), 0) = 0, 0,
|
|
|
|
|
+ (SUM(share_iaa_amount_3) + SUM(share_pay_amount)) / SUM(real_cost_amount) * 100), 2),
|
|
|
|
|
+ '%') AS real_roi,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(iaa_real_cost_amount), 0) = 0, 0,
|
|
|
|
|
+ SUM(share_iaa_amount_3) / SUM(iaa_real_cost_amount) * 100), 2), '%') AS iaa_roi,
|
|
|
|
|
+ concat(round(if(ifnull(SUM(iap_real_cost_amount), 0) = 0, 0,
|
|
|
|
|
+ SUM(share_pay_amount) / SUM(iap_real_cost_amount) * 100), 2), '%') AS iap_roi,
|
|
|
|
|
+ round(ifnull(SUM(hour_cost_amount), 0), 2) AS hour_cost_amount
|
|
|
|
|
+ FROM (SELECT product_id
|
|
|
|
|
+ FROM application.media_product_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))
|
|
|
|
|
+ UNION
|
|
|
|
|
+ SELECT movie_id
|
|
|
|
|
+ FROM application.user_data_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))) tb1
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (SELECT product_id,
|
|
|
|
|
+ SUM(iaa_cost_amount) AS iaa_cost_amount,
|
|
|
|
|
+ SUM(iaa_real_cost_amount) AS iaa_real_cost_amount,
|
|
|
|
|
+ SUM(iap_cost_amount) AS iap_cost_amount,
|
|
|
|
|
+ SUM(iap_real_cost_amount) AS iap_real_cost_amount,
|
|
|
|
|
+ SUM(iaa_cost_amount) + SUM(iap_cost_amount) AS cost_amount,
|
|
|
|
|
+ SUM(iaa_real_cost_amount) + SUM(iap_real_cost_amount) AS real_cost_amount
|
|
|
|
|
+ FROM (SELECT product_id,
|
|
|
|
|
+ round(ifnull(SUM(cost_amount), 0), 2) AS iaa_cost_amount,
|
|
|
|
|
+ SUM(real_cost_amount) AS iaa_real_cost_amount,
|
|
|
|
|
+ 0 AS iap_cost_amount,
|
|
|
|
|
+ 0 AS iap_real_cost_amount
|
|
|
|
|
+ FROM application.media_product_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id
|
|
|
|
|
+ FROM deepthink.mini_app_info
|
|
|
|
|
+ WHERE business_type IN (1, 3, 8) AND business_method = 'IAA')
|
|
|
|
|
+ GROUP BY product_id
|
|
|
|
|
+ UNION ALL
|
|
|
|
|
+ SELECT product_id,
|
|
|
|
|
+ 0 AS iaa_cost_amount,
|
|
|
|
|
+ 0 AS iaa_real_cost_amount,
|
|
|
|
|
+ round(ifnull(SUM(cost_amount), 0), 2) AS cost_amount,
|
|
|
|
|
+ SUM(real_cost_amount) AS real_cost_amount
|
|
|
|
|
+ FROM application.media_product_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id
|
|
|
|
|
+ FROM deepthink.mini_app_info
|
|
|
|
|
+ WHERE business_type IN (1, 3, 8) AND business_method = 'IAP')
|
|
|
|
|
+ GROUP BY product_id) subt2
|
|
|
|
|
+ GROUP BY product_id) tb2 ON tb1.product_id = tb2.product_id
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (SELECT movie_id,
|
|
|
|
|
+ ifnull(SUM(iaa_amount), 0) + ifnull(SUM(pay_amount), 0) AS end_amount,
|
|
|
|
|
+ round(ifnull(if(SUM(share_iaa_amount_3) > 0, SUM(share_iaa_amount_3), SUM(share_iaa_amount)), 0),
|
|
|
|
|
+ 2) AS share_iaa_amount_3,
|
|
|
|
|
+ ifnull(SUM(share_iaa_amount), 0) AS share_iaa_amount,
|
|
|
|
|
+ ifnull(SUM(share_pay_amount), 0) AS share_pay_amount
|
|
|
|
|
+ FROM application.user_data_report_daily
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))
|
|
|
|
|
+ GROUP BY movie_id) tb3 ON tb1.product_id = tb3.movie_id
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (SELECT moive_id, standard_movie_id, standard_movie_name, movie_source FROM deepthink.all_moive) tb4
|
|
|
|
|
+ ON tb1.product_id = tb4.moive_id
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (SELECT product_id, ifnull(SUM(cost_amount), 0) AS hour_cost_amount
|
|
|
|
|
+ FROM application.media_product_report_hourly
|
|
|
|
|
+ WHERE stat_date = ${date}
|
|
|
|
|
+ AND `hour` = ${hour}
|
|
|
|
|
+ AND ma_appid IN (SELECT app_id FROM deepthink.mini_app_info WHERE business_type IN (1, 3, 8))
|
|
|
|
|
+ GROUP BY product_id) tb5 ON tb1.product_id = tb5.product_id
|
|
|
|
|
+ WHERE 1 = 1
|
|
|
|
|
+ AND tb1.product_id != '-9999'
|
|
|
|
|
+ GROUP BY tb4.standard_movie_name
|
|
|
|
|
+ ORDER BY SUM (end_amount) DESC
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -380,7 +456,9 @@
|
|
|
) tb2
|
|
) tb2
|
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join (select advertiser_id,
|
|
left join (select advertiser_id,
|
|
|
- round(ifnull(sum(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)), 0),2) as share_iaa_amount_3,
|
|
|
|
|
|
|
+
|
|
|
|
|
+ round(ifnull(if(sum(share_iaa_amount_3) > 0, sum(share_iaa_amount_3), sum(share_iaa_amount)), 0),
|
|
|
|
|
+ 2) as share_iaa_amount_3,
|
|
|
ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
sum(share_pay_amount) as share_pay_amount
|
|
sum(share_pay_amount) as share_pay_amount
|
|
|
from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
from application.user_data_report_daily where stat_date=${date} and ma_appid in (select app_id from deepthink.mini_app_info where business_type in (1,3,8))
|
|
@@ -441,7 +519,8 @@
|
|
|
) tb1,
|
|
) tb1,
|
|
|
(select sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
|
|
(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) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount,
|
|
|
- ifnull(sum(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)), 0) as share_iaa_amount_3
|
|
|
|
|
|
|
+ round(ifnull(if(sum(share_iaa_amount_3) > 0, sum(share_iaa_amount_3), sum(share_iaa_amount)), 0),
|
|
|
|
|
+ 2) as share_iaa_amount_3
|
|
|
from application.user_data_report_daily
|
|
from application.user_data_report_daily
|
|
|
where stat_date = #{date}
|
|
where stat_date = #{date}
|
|
|
) tb2
|
|
) tb2
|