|
|
@@ -563,12 +563,13 @@
|
|
|
select stat_date, link_id, app_id, person_id, person_pid, company_id,
|
|
|
ad_total_income, ad_play_user_count,
|
|
|
ad_total_income*scale/100.0 ad_settlement_amount,
|
|
|
- ad_total_income*0.1 ad_amount,
|
|
|
- ad_total_income*0.1*ad_scale/100.0 ad_amount_scale_rate
|
|
|
+ ad_amount,
|
|
|
+ ad_amount*ad_scale/100.0 ad_amount_scale_rate
|
|
|
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,ad_scale.scale as ad_scale,
|
|
|
- (ifnull(income,0))/100*(link_count/all_count) ad_total_income,
|
|
|
- ifnull(user_count, 0) ad_play_user_count
|
|
|
+ (ifnull(income,0)) * (link_count/all_count) ad_total_income,
|
|
|
+ ifnull(user_count, 0) ad_play_user_count,
|
|
|
+ ifnull(ad_fund, 0) * (link_count/all_count) ad_amount
|
|
|
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
|
|
|
@@ -597,11 +598,18 @@
|
|
|
)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
|
|
|
+ select stat_date,app_id,sum(income / 100) income
|
|
|
from tidb.media_api.adq_publisher_adpos_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
|
|
|
+ (
|
|
|
+ select stat_date, app_id, sum(ad_fund / 100) ad_fund
|
|
|
+ from tidb.media_api.adq_game_gift_save_list
|
|
|
+ where stat_date = #{dateLong}
|
|
|
+ group by 1, 2
|
|
|
+ ) t4 on t1.stat_date = t4.stat_date and t1.app_id = t4.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
|
|
|
@@ -614,7 +622,11 @@
|
|
|
)tb
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
+ <delete id="deleteIaaWxSettlementData">
|
|
|
+ DELETE
|
|
|
+ FROM deepthink.distrubution_iaa_weixin_settlement
|
|
|
+ WHERE stat_date = #{dateLong}
|
|
|
+ </delete>
|
|
|
|
|
|
<update id="saveIaaWxSettlementData">
|
|
|
replace into deepthink.distrubution_iaa_weixin_settlement
|