|
@@ -883,4 +883,157 @@
|
|
|
group by video_project_name, project_ad_date, movie_project_source
|
|
group by video_project_name, project_ad_date, movie_project_source
|
|
|
order by project_ad_date desc
|
|
order by project_ad_date desc
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <select id="xwTotalCostRank" resultType="java.util.Map">
|
|
|
|
|
+ select round(ifnull(sum(cost_amount),0), 2) AS cost_amount,
|
|
|
|
|
+ round(ifnull(sum(income),0), 2) AS income,
|
|
|
|
|
+ concat(round(ifnull(sum(income) / nullif(sum(real_cost_amount), 0), 0) * 100, 2), '%') as roi,
|
|
|
|
|
+ max(tb2.update_time) as update_time
|
|
|
|
|
+ from
|
|
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, t1.user_id
|
|
|
|
|
+ from tidb.deepthink.advertiser_bind_info t1
|
|
|
|
|
+ join tidb.deepthink.bytedance_auth_list t2 on t1.admin_advertiser_id = t2.admin_advertiser_id
|
|
|
|
|
+ where t1.user_id is not null and t2.corporation_name like '%信维%'
|
|
|
|
|
+ ) tb1
|
|
|
|
|
+ left join (select advertiser_id,
|
|
|
|
|
+ ifnull(sum(cost_amount), 0) as cost_amount,
|
|
|
|
|
+ ifnull(sum(real_cost_amount), 0) as real_cost_amount,
|
|
|
|
|
+ max(t1.update_time) as update_time
|
|
|
|
|
+ from application.media_ad_report_daily t1
|
|
|
|
|
+ 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 ma_appid in (select app_id from tidb.deepthink.mini_app_info where t2.business_line in (1,6,7,4,8,9,10))
|
|
|
|
|
+ group by advertiser_id
|
|
|
|
|
+ ) tb2
|
|
|
|
|
+ on tb1.advertiser_id = tb2.advertiser_id
|
|
|
|
|
+ left join (select advertiser_id,
|
|
|
|
|
+ ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as income
|
|
|
|
|
+ from application.user_data_report_daily t1
|
|
|
|
|
+ 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 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 (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 (300)
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="xwDeptCostRank" resultType="java.util.Map">
|
|
|
|
|
+ select tb5.sub_dept_id as dept_id,
|
|
|
|
|
+ concat(tb5.dept_name, '-', tb5.sub_dept_name) as dept_name,
|
|
|
|
|
+ rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
|
|
+ round(ifnull(sum(cost_amount),0), 2) AS cost_amount,
|
|
|
|
|
+ round(ifnull(sum(income),0), 2) AS income,
|
|
|
|
|
+ concat(round(ifnull(sum(income) / nullif(sum(real_cost_amount), 0), 0) * 100, 2), '%') as roi
|
|
|
|
|
+ from
|
|
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, t1.user_id
|
|
|
|
|
+ from tidb.deepthink.advertiser_bind_info t1
|
|
|
|
|
+ join tidb.deepthink.bytedance_auth_list t2 on t1.admin_advertiser_id = t2.admin_advertiser_id
|
|
|
|
|
+ where t1.user_id is not null and t2.corporation_name like '%信维%'
|
|
|
|
|
+ ) tb1
|
|
|
|
|
+ left join (select advertiser_id,
|
|
|
|
|
+ ifnull(sum(cost_amount), 0) as cost_amount,
|
|
|
|
|
+ ifnull(sum(real_cost_amount), 0) as real_cost_amount
|
|
|
|
|
+ from application.media_ad_report_daily t1
|
|
|
|
|
+ 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 ma_appid in (select app_id from tidb.deepthink.mini_app_info where t2.business_line in (1,6,7,4,8,9,10))
|
|
|
|
|
+ group by advertiser_id
|
|
|
|
|
+ ) tb2
|
|
|
|
|
+ on tb1.advertiser_id = tb2.advertiser_id
|
|
|
|
|
+ left join (select advertiser_id,
|
|
|
|
|
+ ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as income
|
|
|
|
|
+ from application.user_data_report_daily t1
|
|
|
|
|
+ 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 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 (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 (300)
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
|
|
+ group by tb5.sub_dept_id, tb5.dept_name, tb5.sub_dept_name
|
|
|
|
|
+ having sum(cost_amount)>1
|
|
|
|
|
+ order by rk asc
|
|
|
|
|
+ limit 10
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="xwOptimizerCostRank" resultType="java.util.Map">
|
|
|
|
|
+ select tb1.user_id, tb4.phonenumber, tb4.nick_name, tb5.dept_id, tb5.dept_name,
|
|
|
|
|
+ rank() over (order by ifnull(sum(income) / nullif(sum(real_cost_amount), 0), 0) desc) as rk,
|
|
|
|
|
+ round(ifnull(sum(cost_amount),0), 2) AS cost_amount,
|
|
|
|
|
+ round(ifnull(sum(income),0), 2) AS income,
|
|
|
|
|
+ concat(round(ifnull(sum(income) / nullif(sum(real_cost_amount), 0), 0) * 100, 2), '%') as roi
|
|
|
|
|
+ from
|
|
|
|
|
+ (select cast(advertiser_id as char) advertiser_id, t1.user_id
|
|
|
|
|
+ from tidb.deepthink.advertiser_bind_info t1
|
|
|
|
|
+ join tidb.deepthink.bytedance_auth_list t2 on t1.admin_advertiser_id = t2.admin_advertiser_id
|
|
|
|
|
+ where t1.user_id is not null and t2.corporation_name like '%信维%'
|
|
|
|
|
+ ) tb1
|
|
|
|
|
+ left join (select advertiser_id,
|
|
|
|
|
+ ifnull(sum(cost_amount), 0) as cost_amount,
|
|
|
|
|
+ ifnull(sum(real_cost_amount), 0) as real_cost_amount
|
|
|
|
|
+ from application.media_ad_report_daily t1
|
|
|
|
|
+ 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 ma_appid in (select app_id from tidb.deepthink.mini_app_info where t2.business_line in (1,6,7,4,8,9,10))
|
|
|
|
|
+ group by advertiser_id
|
|
|
|
|
+ ) tb2
|
|
|
|
|
+ on tb1.advertiser_id = tb2.advertiser_id
|
|
|
|
|
+ left join (select advertiser_id,
|
|
|
|
|
+ ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as income
|
|
|
|
|
+ from application.user_data_report_daily t1
|
|
|
|
|
+ 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 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, status, del_flag 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 (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 (300)
|
|
|
|
|
+ ) tb5
|
|
|
|
|
+ on tb4.dept_id = tb5.sub_dept_id
|
|
|
|
|
+ where tb1.user_id is not null and (tb4.nick_name not like '%IAP%' and tb4.nick_name not like '%IAA%')
|
|
|
|
|
+ and tb4.status = 0 and tb4.del_flag = 0
|
|
|
|
|
+ group by tb1.user_id, tb4.phonenumber, tb4.nick_name, tb5.dept_id, tb5.dept_name
|
|
|
|
|
+ having sum(cost_amount)>1
|
|
|
|
|
+ order by rk asc
|
|
|
|
|
+ </select>
|
|
|
</mapper>
|
|
</mapper>
|