|
@@ -524,15 +524,7 @@
|
|
|
where tb1.ma_appid != tb2.ma_appid
|
|
where tb1.ma_appid != tb2.ma_appid
|
|
|
order by tb2.user_id
|
|
order by tb2.user_id
|
|
|
</select>
|
|
</select>
|
|
|
- <select id="deptRank2" resultType="java.util.Map">
|
|
|
|
|
- select tb5.dept_id, tb5.dept_name,
|
|
|
|
|
- rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
|
|
- <include refid="costAmount"/>,
|
|
|
|
|
- <include refid="sharePayAmount"/>,
|
|
|
|
|
- <include refid="shareIaaAmount3"/>,
|
|
|
|
|
- <include refid="iaaRoi"/>,
|
|
|
|
|
- <include refid="iapRoi"/>
|
|
|
|
|
- from
|
|
|
|
|
|
|
+ <sql id="deptRankSqlPart">
|
|
|
(select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info where user_id is not null and user_id != -9999 ) tb1
|
|
(select cast(advertiser_id as char) advertiser_id, user_id from tidb.deepthink.advertiser_bind_info where user_id is not null and user_id != -9999 ) tb1
|
|
|
left join
|
|
left join
|
|
|
(select advertiser_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
(select advertiser_id, sum(iaa_cost_amount) as iaa_cost_amount, sum(iaa_real_cost_amount) as iaa_real_cost_amount,
|
|
@@ -548,30 +540,51 @@
|
|
|
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) 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_line in (1,6,7,4,8,9,10) and business_method='IAP')
|
|
|
group by advertiser_id)subtb2
|
|
group by advertiser_id)subtb2
|
|
|
group by advertiser_id
|
|
group by advertiser_id
|
|
|
- ) tb2
|
|
|
|
|
|
|
+ ) tb2
|
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
on tb1.advertiser_id = tb2.advertiser_id
|
|
|
- left join (select advertiser_id,
|
|
|
|
|
- round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
|
|
|
- ifnull(sum(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 tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
|
|
|
|
|
- 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
|
|
|
|
|
- on tb1.user_id=tb4.user_id
|
|
|
|
|
- left join (
|
|
|
|
|
|
|
+ left join (select advertiser_id,
|
|
|
|
|
+ round(ifnull(sum(share_iaa_amount_3), 0),2) as share_iaa_amount_3,
|
|
|
|
|
+ ifnull(sum(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 tidb.deepthink.mini_app_info where business_line in (1,6,7,4,8,9,10))
|
|
|
|
|
+ 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
|
|
|
|
|
+ on tb1.user_id=tb4.user_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
|
|
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
|
|
right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id
|
|
|
where dp.dept_id is not null
|
|
where dp.dept_id is not null
|
|
|
union all
|
|
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)
|
|
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
|
|
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
where tb4.user_id is not null
|
|
where tb4.user_id is not null
|
|
|
|
|
+ </sql>
|
|
|
|
|
+ <select id="deptRank2" resultType="java.util.Map">
|
|
|
|
|
+ select tb5.dept_id, tb5.dept_name,
|
|
|
|
|
+ rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
|
|
+ <include refid="costAmount"/>,
|
|
|
|
|
+ <include refid="sharePayAmount"/>,
|
|
|
|
|
+ <include refid="shareIaaAmount3"/>,
|
|
|
|
|
+ <include refid="iaaRoi"/>,
|
|
|
|
|
+ <include refid="iapRoi"/>
|
|
|
|
|
+ from
|
|
|
|
|
+ <include refid="deptRankSqlPart"/>
|
|
|
group by tb5.dept_id, tb5.dept_name
|
|
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>
|
|
|
|
|
+ <select id="deptRankTotal" resultType="java.util.Map">
|
|
|
|
|
+ select 0 as dept_id, '总计' as dept_name,
|
|
|
|
|
+ <include refid="costAmount"/>,
|
|
|
|
|
+ <include refid="sharePayAmount"/>,
|
|
|
|
|
+ <include refid="shareIaaAmount3"/>,
|
|
|
|
|
+ <include refid="iaaRoi"/>,
|
|
|
|
|
+ <include refid="iapRoi"/>
|
|
|
|
|
+ from
|
|
|
|
|
+ <include refid="deptRankSqlPart"/>
|
|
|
|
|
+ </select>
|
|
|
<select id="cutDeptRank" resultType="java.util.Map">
|
|
<select id="cutDeptRank" resultType="java.util.Map">
|
|
|
select row_number() over (order by sum(cost) desc) as ranks,
|
|
select row_number() over (order by sum(cost) desc) as ranks,
|
|
|
dept_name as dept_name,
|
|
dept_name as dept_name,
|