|
@@ -60,7 +60,7 @@
|
|
|
FROM
|
|
FROM
|
|
|
(select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount, max(update_time) as update_time
|
|
(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
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = ${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
) tb1,
|
|
) tb1,
|
|
|
(select sum(pay_amount) as pay_amount,
|
|
(select sum(pay_amount) as pay_amount,
|
|
|
sum(iaa_amount) as iaa_amount,
|
|
sum(iaa_amount) as iaa_amount,
|
|
@@ -68,7 +68,7 @@
|
|
|
sum(share_pay_amount) as share_pay_amount,
|
|
sum(share_pay_amount) as share_pay_amount,
|
|
|
sum(share_iaa_amount) as share_iaa_amount
|
|
sum(share_iaa_amount) as share_iaa_amount
|
|
|
from application.user_data_report_daily
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = ${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
) tb2
|
|
) tb2
|
|
|
</select>
|
|
</select>
|
|
|
<select id="adHourData" resultType="java.util.Map">
|
|
<select id="adHourData" resultType="java.util.Map">
|
|
@@ -83,13 +83,13 @@
|
|
|
from
|
|
from
|
|
|
(select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
(select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
from application.media_ad_report_hourly
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
) 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_3) as share_iaa_amount_3,
|
|
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
|
|
sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
|
|
|
from application.user_data_report_hourly
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
) tb2
|
|
) tb2
|
|
|
</select>
|
|
</select>
|
|
|
<select id="tmpTopMovie" resultType="java.util.Map">
|
|
<select id="tmpTopMovie" resultType="java.util.Map">
|
|
@@ -102,8 +102,8 @@
|
|
|
<include refid="iaaRoi"/>,
|
|
<include refid="iaaRoi"/>,
|
|
|
<include refid="iapRoi"/>
|
|
<include refid="iapRoi"/>
|
|
|
from
|
|
from
|
|
|
- (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
- union select movie_id 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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
|
|
+ union select movie_id 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_type not in (2,4,6))
|
|
|
) tb1
|
|
) tb1
|
|
|
left join
|
|
left join
|
|
|
(select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
(select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
@@ -112,12 +112,12 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
from
|
|
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
|
|
(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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11) and business_method='IAA')
|
|
|
|
|
|
|
+ from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6) and business_method='IAA')
|
|
|
group by product_id
|
|
group by product_id
|
|
|
union all
|
|
union all
|
|
|
select product_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,
|
|
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
|
|
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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11) and business_method='IAP')
|
|
|
|
|
|
|
+ from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6) and business_method='IAP')
|
|
|
group by product_id) subt2
|
|
group by product_id) subt2
|
|
|
group by product_id
|
|
group by product_id
|
|
|
) tb2 on tb1.product_id=tb2.product_id
|
|
) tb2 on tb1.product_id=tb2.product_id
|
|
@@ -127,7 +127,7 @@
|
|
|
ifnull(sum(share_pay_amount), 0) as share_pay_amount,
|
|
ifnull(sum(share_pay_amount), 0) as share_pay_amount,
|
|
|
ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3
|
|
round(ifnull(sum(share_iaa_amount_3), 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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ 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_type not in (2,4,6))
|
|
|
group by movie_id
|
|
group by movie_id
|
|
|
) tb3 on tb1.product_id=tb3.movie_id
|
|
) tb3 on tb1.product_id=tb3.movie_id
|
|
|
left join
|
|
left join
|
|
@@ -152,13 +152,13 @@
|
|
|
from
|
|
from
|
|
|
(select sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount, max(update_time) as update_time
|
|
(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
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
) 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,
|
|
|
sum(share_iaa_amount_3) as share_iaa_amount_3
|
|
sum(share_iaa_amount_3) as share_iaa_amount_3
|
|
|
from application.user_data_report_daily
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
) tb2
|
|
) tb2
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -174,8 +174,8 @@
|
|
|
<include refid="iapRoi"/>,
|
|
<include refid="iapRoi"/>,
|
|
|
round(ifnull(sum(hour_cost_amount), 0), 2) as hour_cost_amount
|
|
round(ifnull(sum(hour_cost_amount), 0), 2) as hour_cost_amount
|
|
|
from
|
|
from
|
|
|
- (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
- union select movie_id 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_type in (1,3,8,9,10,11))) tb1
|
|
|
|
|
|
|
+ (select product_id from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
|
|
+ union select movie_id 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_type not in (2,4,6))) tb1
|
|
|
left join
|
|
left join
|
|
|
(
|
|
(
|
|
|
select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
select product_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
@@ -184,11 +184,11 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
from
|
|
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
|
|
(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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11) and business_method='IAA')
|
|
|
|
|
|
|
+ from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6) and business_method='IAA')
|
|
|
group by product_id
|
|
group by product_id
|
|
|
union all
|
|
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
|
|
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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11) and business_method='IAP')
|
|
|
|
|
|
|
+ from application.media_product_report_daily where stat_date=${date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6) and business_method='IAP')
|
|
|
group by product_id) subt2
|
|
group by product_id) subt2
|
|
|
group by product_id
|
|
group by product_id
|
|
|
) tb2 on tb1.product_id=tb2.product_id
|
|
) tb2 on tb1.product_id=tb2.product_id
|
|
@@ -197,7 +197,7 @@
|
|
|
sum(share_iaa_amount_3) as share_iaa_amount_3,
|
|
sum(share_iaa_amount_3) 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,
|
|
|
ifnull(sum(share_pay_amount), 0) as share_pay_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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ 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_type not in (2,4,6))
|
|
|
group by movie_id
|
|
group by movie_id
|
|
|
) tb3 on tb1.product_id=tb3.movie_id
|
|
) tb3 on tb1.product_id=tb3.movie_id
|
|
|
left join
|
|
left join
|
|
@@ -205,7 +205,7 @@
|
|
|
) tb4 on tb1.product_id=tb4.moive_id
|
|
) tb4 on tb1.product_id=tb4.moive_id
|
|
|
left join
|
|
left join
|
|
|
(select product_id, ifnull(sum(cost_amount), 0) as hour_cost_amount from application.media_product_report_hourly
|
|
(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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date=${date} and `hour`=${hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
group by product_id) tb5 on tb1.product_id=tb5.product_id
|
|
group by product_id) tb5 on tb1.product_id=tb5.product_id
|
|
|
where 1=1 and tb1.product_id != '-9999'
|
|
where 1=1 and tb1.product_id != '-9999'
|
|
|
group by tb4.standard_movie_name
|
|
group by tb4.standard_movie_name
|
|
@@ -215,7 +215,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="optimizerCostRank" resultType="java.util.Map">
|
|
<select id="optimizerCostRank" resultType="java.util.Map">
|
|
|
- select tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id, tb5.dept_name,
|
|
|
|
|
|
|
+ select tb1.user_id, tb4.phonenumber, tb4.nick_name, tb5.dept_id, tb5.dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
<include refid="costAmount"/>,
|
|
<include refid="costAmount"/>,
|
|
|
<include refid="iaaRoi"/>,
|
|
<include refid="iaaRoi"/>,
|
|
@@ -229,11 +229,11 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
FROM
|
|
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
|
|
(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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11) and business_method='IAA')
|
|
|
|
|
|
|
+ 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_type not in (2,4,6) and business_method='IAA')
|
|
|
group by advertiser_id
|
|
group by advertiser_id
|
|
|
UNION ALL
|
|
UNION ALL
|
|
|
select advertiser_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,round(ifnull(sum(cost_amount),0),2) as iap_cost_amount, sum(real_cost_amount) as iap_real_cost_amount
|
|
select advertiser_id, 0 as iaa_cost_amount, 0 as iaa_real_cost_amount,round(ifnull(sum(cost_amount),0),2) as iap_cost_amount, sum(real_cost_amount) as iap_real_cost_amount
|
|
|
- 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_type in (1,3,8,9,10,11) and business_method='IAP')
|
|
|
|
|
|
|
+ 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_type not in (2,4,6) and business_method='IAP')
|
|
|
group by advertiser_id)subtb2
|
|
group by advertiser_id)subtb2
|
|
|
group by advertiser_id
|
|
group by advertiser_id
|
|
|
) tb2
|
|
) tb2
|
|
@@ -242,19 +242,25 @@
|
|
|
round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
|
sum(share_iaa_amount) as share_iaa_amount,
|
|
sum(share_iaa_amount) 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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ 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_type not in (2,4,6))
|
|
|
group by advertiser_id) tb3
|
|
group by advertiser_id) tb3
|
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
on tb1.user_id=tb4.user_id
|
|
|
- left join (select dept_id, dept_name from tidb.deepthink.sys_dept) tb5
|
|
|
|
|
- on tb4.dept_id = tb5.dept_id
|
|
|
|
|
- group by tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id, tb5.dept_name
|
|
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select dp.dept_id, dp.dept_name, ifnull(subdp.dept_id, dp.dept_id) as sub_dept_id, ifnull(subdp.dept_name, dp.dept_name) as sub_dept_name from (select * from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)) dp
|
|
|
|
|
+ right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id
|
|
|
|
|
+ where dp.dept_id is not null
|
|
|
|
|
+ union all
|
|
|
|
|
+ select dept_id, dept_name, dept_id as sub_dept_id, dept_name as sub_dept_name from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
|
|
+ group by tb1.user_id, tb4.phonenumber, tb4.nick_name, tb5.dept_id, tb5.dept_name
|
|
|
having sum(cost_amount)>1
|
|
having sum(cost_amount)>1
|
|
|
order by rk asc
|
|
order by rk asc
|
|
|
</select>
|
|
</select>
|
|
|
<select id="optimizerDateData" resultType="java.util.Map">
|
|
<select id="optimizerDateData" resultType="java.util.Map">
|
|
|
- select tb1.user_id,tb4.phonenumber,tb4.nick_name, tb4.dept_id,
|
|
|
|
|
|
|
+ select tb1.user_id,tb4.phonenumber,tb4.nick_name, tb5.dept_id,
|
|
|
<include refid="costAmount"/>,
|
|
<include refid="costAmount"/>,
|
|
|
<include refid="iaaAmount"/>,
|
|
<include refid="iaaAmount"/>,
|
|
|
<include refid="payAmount"/>,
|
|
<include refid="payAmount"/>,
|
|
@@ -265,17 +271,25 @@
|
|
|
left join
|
|
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
|
|
(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
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
group by advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
|
|
group by advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join
|
|
left join
|
|
|
(select advertiser_id, sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
|
|
(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
|
|
sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
|
|
|
from application.user_data_report_daily
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
on tb1.user_id=tb4.user_id
|
|
|
- group by tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id
|
|
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select dp.dept_id, dp.dept_name, ifnull(subdp.dept_id, dp.dept_id) as sub_dept_id, ifnull(subdp.dept_name, dp.dept_name) as sub_dept_name from (select * from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)) dp
|
|
|
|
|
+ right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id
|
|
|
|
|
+ where dp.dept_id is not null
|
|
|
|
|
+ union all
|
|
|
|
|
+ select dept_id, dept_name, dept_id as sub_dept_id, dept_name as sub_dept_name from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
|
|
+ group by tb1.user_id, tb4.phonenumber, tb4.nick_name, tb5.dept_id
|
|
|
having sum(cost_amount)>0
|
|
having sum(cost_amount)>0
|
|
|
</select>
|
|
</select>
|
|
|
<select id="optimizerHourData" resultType="java.util.Map">
|
|
<select id="optimizerHourData" resultType="java.util.Map">
|
|
@@ -289,13 +303,13 @@
|
|
|
left join
|
|
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
|
|
(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
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
group by advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
|
|
group by advertiser_id) tb2 on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join
|
|
left join
|
|
|
(select advertiser_id, sum(pay_amount) as pay_amount, sum(iaa_amount) as iaa_amount,
|
|
(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
|
|
sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
|
|
|
from application.user_data_report_hourly
|
|
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_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ where stat_date = #{date} and `hour`= #{hour} and ma_appid in (select app_id from tidb.deepthink.mini_app_info where business_type not in (2,4,6))
|
|
|
group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber from tidb.deepthink.sys_user) tb4
|
|
left join (select user_id, nick_name, phonenumber from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
on tb1.user_id=tb4.user_id
|
|
@@ -305,25 +319,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="deptCostRank" resultType="java.util.Map">
|
|
<select id="deptCostRank" resultType="java.util.Map">
|
|
|
- select tb4.dept_id, tb5.dept_name,
|
|
|
|
|
|
|
+ select tb5.dept_id, tb5.dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
<include refid="costAmount"/>,
|
|
<include refid="costAmount"/>,
|
|
|
ifnull(sum(cost_amount_hour), 0) as cost_amount_hour
|
|
ifnull(sum(cost_amount_hour), 0) as cost_amount_hour
|
|
|
from
|
|
from
|
|
|
(select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info) tb1
|
|
(select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info) tb1
|
|
|
left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ 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_type not in (2,4,6))
|
|
|
group by advertiser_id) tb2
|
|
group by advertiser_id) tb2
|
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
|
left join (select advertiser_id, sum(cost_amount) as cost_amount_hour
|
|
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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ 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_type not in (2,4,6))
|
|
|
group by advertiser_id) tb3
|
|
group by advertiser_id) tb3
|
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
on tb1.user_id=tb4.user_id
|
|
|
- left join (select dept_id, dept_name from tidb.deepthink.sys_dept) tb5
|
|
|
|
|
- on tb4.dept_id = tb5.dept_id
|
|
|
|
|
- group by tb4.dept_id, tb5.dept_name
|
|
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select dp.dept_id, dp.dept_name, ifnull(subdp.dept_id, dp.dept_id) as sub_dept_id, ifnull(subdp.dept_name, dp.dept_name) as sub_dept_name from (select * from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)) dp
|
|
|
|
|
+ right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id
|
|
|
|
|
+ where dp.dept_id is not null
|
|
|
|
|
+ union all
|
|
|
|
|
+ select dept_id, dept_name, dept_id as sub_dept_id, dept_name as sub_dept_name from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
|
|
+ group by tb5.dept_id, tb5.dept_name
|
|
|
having sum(cost_amount)>1
|
|
having sum(cost_amount)>1
|
|
|
order by rk asc
|
|
order by rk asc
|
|
|
limit 10
|
|
limit 10
|
|
@@ -393,7 +413,7 @@
|
|
|
order by tb2.user_id
|
|
order by tb2.user_id
|
|
|
</select>
|
|
</select>
|
|
|
<select id="deptRank2" resultType="java.util.Map">
|
|
<select id="deptRank2" resultType="java.util.Map">
|
|
|
- select tb4.dept_id, tb5.dept_name,
|
|
|
|
|
|
|
+ select tb5.dept_id, tb5.dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
<include refid="costAmount"/>,
|
|
<include refid="costAmount"/>,
|
|
|
<include refid="iaaRoi"/>,
|
|
<include refid="iaaRoi"/>,
|
|
@@ -407,11 +427,11 @@
|
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
sum(iaa_real_cost_amount)+sum(iap_real_cost_amount) as real_cost_amount
|
|
|
FROM
|
|
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
|
|
(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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11) and business_method='IAA')
|
|
|
|
|
|
|
+ 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_type not in (2,4,6) and business_method='IAA')
|
|
|
group by advertiser_id
|
|
group by advertiser_id
|
|
|
UNION ALL
|
|
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
|
|
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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11) and business_method='IAP')
|
|
|
|
|
|
|
+ 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_type not in (2,4,6) and business_method='IAP')
|
|
|
group by advertiser_id)subtb2
|
|
group by advertiser_id)subtb2
|
|
|
group by advertiser_id
|
|
group by advertiser_id
|
|
|
) tb2
|
|
) tb2
|
|
@@ -420,14 +440,20 @@
|
|
|
round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
round(ifnull(sum(share_iaa_amount_3), 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 tidb.deepthink.mini_app_info where business_type in (1,3,8,9,10,11))
|
|
|
|
|
|
|
+ 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_type not in (2,4,6))
|
|
|
group by advertiser_id) tb3
|
|
group by advertiser_id) tb3
|
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
on tb1.advertiser_id = tb3.advertiser_id
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
on tb1.user_id=tb4.user_id
|
|
|
- left join (select dept_id, dept_name from tidb.deepthink.sys_dept) tb5
|
|
|
|
|
- on tb4.dept_id = tb5.dept_id
|
|
|
|
|
- group by tb4.dept_id, tb5.dept_name
|
|
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select dp.dept_id, dp.dept_name, ifnull(subdp.dept_id, dp.dept_id) as sub_dept_id, ifnull(subdp.dept_name, dp.dept_name) as sub_dept_name from (select * from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)) dp
|
|
|
|
|
+ right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id
|
|
|
|
|
+ where dp.dept_id is not null
|
|
|
|
|
+ union all
|
|
|
|
|
+ select dept_id, dept_name, dept_id as sub_dept_id, dept_name as sub_dept_name from tidb.deepthink.sys_dept where parent_id in (select dept_id from tidb.deepthink.sys_dept where parent_id=300)
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
|
|
+ group by tb5.dept_id, tb5.dept_name
|
|
|
having sum(cost_amount)>1
|
|
having sum(cost_amount)>1
|
|
|
order by rk
|
|
order by rk
|
|
|
</select>
|
|
</select>
|