|
@@ -545,48 +545,49 @@
|
|
|
ad_total_income, ad_play_user_count,
|
|
ad_total_income, ad_play_user_count,
|
|
|
ad_total_income*scale/100.0 ad_settlement_amount
|
|
ad_total_income*scale/100.0 ad_settlement_amount
|
|
|
from
|
|
from
|
|
|
- (select t1.stat_date, t1.link_id,t1.app_id, lrp.id as person_id, lrp.pid as person_pid, lrp.company_id, scale.scale,
|
|
|
|
|
- (ifnull(income,0))/100*(link_count/all_count) ad_total_income,
|
|
|
|
|
- ifnull(user_count, 0) ad_play_user_count
|
|
|
|
|
- from (
|
|
|
|
|
- select m.stat_date,m.app_id,coalesce(m.link_id,t1.link_id,u.link_id) link_id, count(*) link_count,
|
|
|
|
|
- count(distinct m.login_id) user_count
|
|
|
|
|
- from hr_playlet.mp_event m
|
|
|
|
|
- left join
|
|
|
|
|
- (
|
|
|
|
|
- select app_id,uid, link_id
|
|
|
|
|
- from (
|
|
|
|
|
- select app_id,uid, link_id,row_number() over (partition by app_id,uid order by created_at ) r
|
|
|
|
|
- from hr_playlet.server_event se
|
|
|
|
|
- where stat_date = #{dateLong} and event = 'ACTIVATION' and link_id is not null
|
|
|
|
|
- )t where r = 1
|
|
|
|
|
- )t1 on m.app_id = t1.app_id and m.login_id = t1.uid
|
|
|
|
|
- left join hr_playlet.user_event u on m.app_id = u.app_id and m.login_id= u.uid
|
|
|
|
|
- where m.stat_date = #{dateLong} and media_type = 'wx' and event = 'ADSHOW'
|
|
|
|
|
- and coalesce(m.link_id,t1.link_id,u.link_id) is not null
|
|
|
|
|
- group by 1,2,3
|
|
|
|
|
- )t1
|
|
|
|
|
- left join
|
|
|
|
|
- (
|
|
|
|
|
- select m.stat_date,m.app_id,count(*) all_count
|
|
|
|
|
- from hr_playlet.mp_event m
|
|
|
|
|
- where m.stat_date = #{dateLong} and media_type = 'wx' and event = 'ADSHOW'
|
|
|
|
|
- group by 1,2
|
|
|
|
|
- )t2 on t1.stat_date = t2.stat_date and t1.app_id = t2.app_id
|
|
|
|
|
- left join
|
|
|
|
|
- (
|
|
|
|
|
- select stat_date,app_id,sum(income) income
|
|
|
|
|
- from tidb.media_api.adq_publisher_adunit_general
|
|
|
|
|
- where stat_date = #{dateLong}
|
|
|
|
|
- group by 1,2
|
|
|
|
|
- )t3 on t1.stat_date = t3.stat_date and t1.app_id = t3.app_id
|
|
|
|
|
- left join tidb.thirtpart.ly_link ll on t1.link_id=ll.id
|
|
|
|
|
- left join tidb.thirtpart.ly_responsibility_person lrp on ll.responsibility_person_id=lrp.id
|
|
|
|
|
- left join (select company_id, scale, ifnull(commission_scale, 10) as commission_scale from tidb.thirtpart.ly_responsibility_person_scale
|
|
|
|
|
- where source=8 and #{st} >= start_time and #{st} <= end_time
|
|
|
|
|
- ) scale on lrp.company_id = scale.company_id
|
|
|
|
|
- where link_id is not null
|
|
|
|
|
- )tb
|
|
|
|
|
|
|
+ (select t1.stat_date, t1.link_id,t1.app_id, lrp.id as person_id, lrp.pid as person_pid, lrp.company_id, scale.scale,
|
|
|
|
|
+ (ifnull(income,0))/100*(link_count/all_count) ad_total_income,
|
|
|
|
|
+ ifnull(user_count, 0) ad_play_user_count
|
|
|
|
|
+ from (
|
|
|
|
|
+ select m.stat_date,m.app_id,coalesce(m.link_id,t1.link_id,u.link_id) link_id, count(*) link_count,
|
|
|
|
|
+ count(distinct m.login_id) user_count
|
|
|
|
|
+ from hr_playlet.mp_event m
|
|
|
|
|
+ left join
|
|
|
|
|
+ (
|
|
|
|
|
+ select app_id,uid, link_id
|
|
|
|
|
+ from (
|
|
|
|
|
+ select app_id,uid, link_id,row_number() over (partition by app_id,uid order by created_at ) r
|
|
|
|
|
+ from hr_playlet.server_event se
|
|
|
|
|
+ where stat_date = #{dateLong} and event = 'ACTIVATION' and link_id is not null and link_id != ''
|
|
|
|
|
+ )t where r = 1
|
|
|
|
|
+ )t1 on m.app_id = t1.app_id and m.login_id = t1.uid
|
|
|
|
|
+ left join hr_playlet.user_event u on m.app_id = u.app_id and m.login_id= u.uid
|
|
|
|
|
+ where m.stat_date = #{dateLong} and media_type = 'wx' and event = 'ADSHOW'
|
|
|
|
|
+ and coalesce(m.link_id,t1.link_id,u.link_id) is not null
|
|
|
|
|
+ and coalesce(m.link_id,t1.link_id,u.link_id) != ''
|
|
|
|
|
+ group by 1,2,3
|
|
|
|
|
+ )t1
|
|
|
|
|
+ left join
|
|
|
|
|
+ (
|
|
|
|
|
+ select m.stat_date,m.app_id,count(*) all_count
|
|
|
|
|
+ from hr_playlet.mp_event m
|
|
|
|
|
+ where m.stat_date = #{dateLong} and media_type = 'wx' and event = 'ADSHOW'
|
|
|
|
|
+ group by 1,2
|
|
|
|
|
+ )t2 on t1.stat_date = t2.stat_date and t1.app_id = t2.app_id
|
|
|
|
|
+ left join
|
|
|
|
|
+ (
|
|
|
|
|
+ select stat_date,app_id,sum(income) income
|
|
|
|
|
+ from tidb.media_api.adq_publisher_adunit_general
|
|
|
|
|
+ where stat_date = #{dateLong}
|
|
|
|
|
+ group by 1,2
|
|
|
|
|
+ )t3 on t1.stat_date = t3.stat_date and t1.app_id = t3.app_id
|
|
|
|
|
+ left join tidb.thirtpart.ly_link ll on t1.link_id=ll.id
|
|
|
|
|
+ left join tidb.thirtpart.ly_responsibility_person lrp on ll.responsibility_person_id=lrp.id
|
|
|
|
|
+ left join (select company_id, scale, ifnull(commission_scale, 10) as commission_scale from tidb.thirtpart.ly_responsibility_person_scale
|
|
|
|
|
+ where source=8 and #{st} >= start_time and #{st} <= end_time
|
|
|
|
|
+ ) scale on lrp.company_id = scale.company_id
|
|
|
|
|
+ where link_id is not null and link_id != ''
|
|
|
|
|
+ )tb
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|