|
|
@@ -8,22 +8,32 @@
|
|
|
<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),0)+ifnull(sum(share_pay_amount),0))/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)/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,
|
|
|
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,
|
|
|
- date_format(update_time, '%Y-%m-%d %H:%i:%s') as update_time
|
|
|
+ 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,2,3,8))
|
|
|
+ (select 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 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_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) and business_method='IAA')
|
|
|
+ UNION ALL
|
|
|
+ select 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_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) and business_method='IAP'))subtb2
|
|
|
) 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
|
|
|
+ (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,
|
|
|
+ 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,2,3,8))
|
|
|
+ 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 id="adHourData" resultType="java.util.Map">
|
|
|
@@ -38,33 +48,50 @@
|
|
|
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 deepthink.mini_app_info where business_type in (1,2,3,8))
|
|
|
+ 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))
|
|
|
) 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
|
|
|
from application.user_data_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,2,3,8))
|
|
|
+ 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))
|
|
|
) tb2
|
|
|
</select>
|
|
|
<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(end_amount) desc) as rk,
|
|
|
- sum(share_end_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_end_amount)/sum(real_cost_amount)*100), 2), '%') AS real_roi
|
|
|
+ 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)+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)/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,2,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,2,3,8))
|
|
|
+ (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, 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,2,3,8))
|
|
|
+ (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,
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as share_end_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,2,3,8))
|
|
|
+ (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(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)), 0) 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))
|
|
|
group by movie_id
|
|
|
) tb3 on tb1.product_id=tb3.movie_id
|
|
|
left join
|
|
|
@@ -72,7 +99,7 @@
|
|
|
) 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(end_amount) desc
|
|
|
+ order by sum(iaa_amount)+sum(pay_amount) desc
|
|
|
limit 10
|
|
|
</select>
|
|
|
|
|
|
@@ -89,12 +116,12 @@
|
|
|
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,2,3,8))
|
|
|
+ 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,
|
|
|
sum(share_iaa_amount) as share_iaa_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,2,3,8))
|
|
|
+ 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>
|
|
|
|
|
|
@@ -108,17 +135,17 @@
|
|
|
concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, sum(share_end_amount)/sum(real_cost_amount)*100), 2), '%') AS real_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,2,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,2,3,8))) tb1
|
|
|
+ (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, 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,2,3,8))
|
|
|
+ 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))
|
|
|
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,
|
|
|
ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as share_end_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,2,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))
|
|
|
group by movie_id
|
|
|
) tb3 on tb1.product_id=tb3.movie_id
|
|
|
left join
|
|
|
@@ -126,7 +153,7 @@
|
|
|
) 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,2,3,8))
|
|
|
+ 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
|
|
|
@@ -143,11 +170,11 @@
|
|
|
from
|
|
|
(select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
- 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,2,3,8))
|
|
|
+ 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))
|
|
|
group by advertiser_id) tb2
|
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join (select advertiser_id, sum(share_iaa_amount) as share_iaa_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,2,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))
|
|
|
group by advertiser_id) tb3
|
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
|
|
|
@@ -171,13 +198,13 @@
|
|
|
left join
|
|
|
(select advertiser_id, 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,2,3,8))
|
|
|
+ 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 advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join
|
|
|
(select advertiser_id, 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
|
|
|
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,2,3,8))
|
|
|
+ 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 advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
@@ -196,13 +223,13 @@
|
|
|
left join
|
|
|
(select advertiser_id, 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_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,2,3,8))
|
|
|
+ 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 advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join
|
|
|
(select advertiser_id, 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
|
|
|
from application.user_data_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,2,3,8))
|
|
|
+ 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 advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber from deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
@@ -219,11 +246,11 @@
|
|
|
from
|
|
|
(select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
- 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,2,3,8))
|
|
|
+ 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))
|
|
|
group by advertiser_id) tb2
|
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join (select advertiser_id, sum(cost_amount) as cost_amount_hour
|
|
|
- from application.media_ad_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,2,3,8))
|
|
|
+ from application.media_ad_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 advertiser_id) tb3
|
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
|
|
|
@@ -303,15 +330,31 @@
|
|
|
select tb4.dept_id, tb5.dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
ifnull(sum(cost_amount), 0) as cost_amount,
|
|
|
- concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi
|
|
|
+ concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/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)/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 cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
|
|
|
- left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
- 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,2,3,8))
|
|
|
- group by advertiser_id) tb2
|
|
|
+ left join
|
|
|
+ (select advertiser_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 advertiser_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_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) and business_method='IAA')
|
|
|
+ group by advertiser_id
|
|
|
+ UNION ALL
|
|
|
+ select advertiser_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_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) and business_method='IAP')
|
|
|
+ group by advertiser_id)subtb2
|
|
|
+ group by advertiser_id
|
|
|
+ ) tb2
|
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
|
- left join (select advertiser_id, sum(share_iaa_amount) as share_iaa_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,2,3,8))
|
|
|
+ left join (select advertiser_id,
|
|
|
+ ifnull(sum(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)), 0) as share_iaa_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))
|
|
|
group by advertiser_id) tb3
|
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
|
|
|
@@ -388,8 +431,10 @@
|
|
|
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,
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as share_end_amount
|
|
|
+ (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(if(share_iaa_amount_3>0,share_iaa_amount_3,share_iaa_amount)), 0) as share_iaa_amount
|
|
|
from application.user_data_report_daily where stat_date=${date}
|
|
|
group by movie_id
|
|
|
) tb3 on tb1.product_id=tb3.movie_id
|