|
|
@@ -286,6 +286,7 @@
|
|
|
|
|
|
<insert id="runCPSDysSettlementData">
|
|
|
insert into media_api.playlet_distribution_income_detail
|
|
|
+ (playlet_id, stat_date, playlet_name, distributor_id, distributor_name, iaa_income, iap_income, refund_amount, iaa_income_after_scale, iap_income_after_scale)
|
|
|
select a.playlet_id,
|
|
|
stat_date,
|
|
|
playlet_name,
|
|
|
@@ -430,13 +431,13 @@
|
|
|
ifnull(sum(t3.all_pay_amount),0) as all_pay_amount,
|
|
|
ifnull(sum(t4.refund_amount), 0) as all_refund_amount,
|
|
|
ifnull(sum(case when t1.pay_merchant=15 then ifnull(t3.all_pay_amount,0) else 0 end), 0) as wx_virtual_pay_amount,
|
|
|
- ifnull(sum(case when t1.pay_merchant=15 then ifnull(t3.all_pay_amount,0)* wx_virtual_commission_rate else 0 end), 0) as wx_virtual_commission_amount,
|
|
|
+ ifnull(sum(case when t1.pay_merchant=15 then (ifnull(t3.all_pay_amount,0)-ifnull(t4.refund_amount,0))* wx_virtual_commission_rate else 0 end), 0) as wx_virtual_commission_amount,
|
|
|
ifnull(sum(case when t1.pay_merchant=15 then ifnull(t4.refund_amount,0) else 0 end), 0) as wx_virtual_refund_amount,
|
|
|
ifnull(sum(case when t1.pay_merchant in (22,23) then ifnull(t3.all_pay_amount,0) else 0 end), 0) as wx_common_pay_amount,
|
|
|
- ifnull(sum(case when t1.pay_merchant in (22,23) then ifnull(t3.all_pay_amount,0)* wx_common_commission_rate else 0 end), 0) as wx_common_commission_amount,
|
|
|
+ ifnull(sum(case when t1.pay_merchant in (22,23) then (ifnull(t3.all_pay_amount,0)-ifnull(t4.refund_amount,0))* wx_common_commission_rate else 0 end), 0) as wx_common_commission_amount,
|
|
|
ifnull(sum(case when t1.pay_merchant in (22,23) then ifnull(t4.refund_amount,0) else 0 end), 0) as wx_common_refund_amount,
|
|
|
ifnull(sum(case when t1.pay_merchant=30 then ifnull(t3.all_pay_amount,0) else 0 end), 0) as tt_common_pay_amount,
|
|
|
- ifnull(sum(case when t1.pay_merchant=30 then ifnull(t3.all_pay_amount,0)* tt_common_commission_rate else 0 end), 0) as tt_common_commission_amount,
|
|
|
+ ifnull(sum(case when t1.pay_merchant=30 then (ifnull(t3.all_pay_amount,0)-ifnull(t4.refund_amount,0))* tt_common_commission_rate else 0 end), 0) as tt_common_commission_amount,
|
|
|
ifnull(sum(case when t1.pay_merchant=30 then ifnull(t4.refund_amount,0) else 0 end), 0) as tt_common_refund_amount
|
|
|
|
|
|
from
|
|
|
@@ -478,7 +479,7 @@
|
|
|
left join (select company_id, scale, ifnull(commission_scale, 1) as commission_scale from thirtpart.ly_responsibility_person_scale where source=2
|
|
|
and #{st} >= start_time and #{st} <= end_time
|
|
|
) scale_tt_common on p.company_id = scale_tt_common.company_id
|
|
|
- where p.is_distributor = 1 or p.pid in (select id from thirtpart.ly_responsibility_person where is_distributor=1)
|
|
|
+<!-- where p.is_distributor = 1 or p.pid in (select id from thirtpart.ly_responsibility_person where is_distributor=1)-->
|
|
|
group by 1,2,3,4,5,6,7,8,9,10,11
|
|
|
) t2 on t1.link_id = t2.link_id
|
|
|
left join
|
|
|
@@ -504,7 +505,7 @@
|
|
|
ad_total_income,
|
|
|
ad_total_income*scale/100.0 ad_settlement_amount,
|
|
|
ad_original_income, ad_platform_subsidy, pre_ecpm,
|
|
|
- concat(round(if(ad_total_income=0, 0, (pre_ecpm-ad_total_income)/ad_total_income)*100, 2), '%') data_gap
|
|
|
+ round(if(ad_total_income=0, 0, (pre_ecpm-ad_total_income)/ad_total_income), 4) data_gap
|
|
|
from
|
|
|
(select t1.stat_date,t1.link_id,t1.app_id,t1.person_id,t1.person_pid, t1.company_id,ifnull(t1.scale,0) scale,
|
|
|
link_cost/100000/0.7 pre_ecpm,
|
|
|
@@ -521,7 +522,7 @@
|
|
|
where source=9 and #{st} >= start_time and #{st} <= end_time
|
|
|
) scale on lrp.company_id = scale.company_id
|
|
|
where stat_date = #{dateLong} and link_id is not null
|
|
|
- and (lrp.is_distributor=1 or lrp.pid in (select id from tidb.thirtpart.ly_responsibility_person where is_distributor=1))
|
|
|
+<!-- and (lrp.is_distributor=1 or lrp.pid in (select id from tidb.thirtpart.ly_responsibility_person where is_distributor=1))-->
|
|
|
group by 1,2,3,4,5,6,7
|
|
|
)t1
|
|
|
left join
|
|
|
@@ -613,20 +614,12 @@
|
|
|
replace into deepthink.distrubution_iaa_douyin_settlement
|
|
|
(stat_date, link_id, app_id, person_id, person_pid, company_id,
|
|
|
ad_total_income, ad_settlement_amount, ad_original_income, ad_platform_subsidy, pre_ecpm, data_gap)
|
|
|
+ values
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
(
|
|
|
- #{item.stat_date},
|
|
|
- #{item.link_id},
|
|
|
- #{item.app_id},
|
|
|
- #{item.person_id},
|
|
|
- #{item.person_pid},
|
|
|
- #{item.company_id},
|
|
|
- #{item.ad_total_income},
|
|
|
- #{item.ad_settlement_amount},
|
|
|
- #{item.ad_original_income},
|
|
|
- #{item.ad_platform_subsidy},
|
|
|
- #{item.pre_ecpm},
|
|
|
- #{item.data_gap}
|
|
|
+ #{item.stat_date}, #{item.link_id}, #{item.app_id}, #{item.person_id}, #{item.person_pid}, #{item.company_id},
|
|
|
+ #{item.ad_total_income}, #{item.ad_settlement_amount}, #{item.ad_original_income}, #{item.ad_platform_subsidy},
|
|
|
+ #{item.pre_ecpm}, #{item.data_gap}
|
|
|
)
|
|
|
</foreach>
|
|
|
</update>
|