IF(o.cover_term IS NOT NULL ,o.cover_term_type ,(SELECT e.element_text FROM ag_po_order_life_product_elements e WHERE o.id = e.order_id AND e.factor_code LIKE 'f_coverage_term' LIMIT 1)) coverTermType,
(select name from ag_acl_channel where id = f.channel_id) '18' /*渠道*/,
(select name from ag_acl_channel_new where id = f.channel_id) '18' /*渠道*/,
ifnull(coalesce(l.s1_id,l.s2_id,l.s3_id),(SELECT a.subordinate_system_id from ag_acl_practitioner a where a.id = f.sale_practitioner_id)) as '19' /*FYC体系*/,
ifnull(l.practitioner_name,(select t.name from ag_acl_practitioner t where t.id = f.sale_practitioner_id)) '20' /*销售经纪人*/,
ifnull(l.practitioner_level,
...
...
@@ -682,7 +685,11 @@
sum(case when drop_option_code ='C14' then f.calculation_rate else null end) '64' /*C14直接销售加码佣金率*/,
sum(case when drop_option_code ='C14' then f.referral_amount else null end) '65' /*C14直接销售加码佣金*/,
IF(f.rule_id is null, if(o.settlement_rule_type=1,'简单基本法','标准基本法'),
(select (case settlement_rule_type when 1 then '简单基本法' when 2 then '标准基本法' when 3 then '特殊结算' when 4 then if(o.settlement_rule_type=1,'简单基本法','标准基本法') end)
from ag_settlement_rule_base where id = f.rule_id
)
) '66' /*基本法属性*/,
sum(case when drop_option_code ='S01' then f.referral_amount else null end) '67' /*S01-首年度销售佣金*/,
IF(f.rule_id is null, if(o.settlement_rule_type=1,'简单基本法','标准基本法'),
(select (case settlement_rule_type when 1 then '简单基本法' when 2 then '标准基本法' when 3 then '特殊结算' when 4 then if(o.settlement_rule_type=1,'简单基本法','标准基本法') end)
from ag_settlement_rule_base where id = f.rule_id
)
) '66' /*基本法属性*/,
null as '67' /*S01-首年度销售佣金*/,
null as '68' /*S03-首年度辅导奖金*/,
...
...
@@ -997,7 +1009,11 @@
sum(case when f.drop_option_code ='D01' then f.referral_amount else null end) '14' /*D01首年渠道服务费*/,
sum(case when f.drop_option_code ='D02' then f.referral_amount else null end) '15' /*D02续年渠道服务费*/,
IF(f.rule_id is null, if(o.settlement_rule_type=1,'简单基本法','标准基本法'),
(select (case settlement_rule_type when 1 then '简单基本法' when 2 then '标准基本法' when 3 then '特殊结算' when 4 then if(o.settlement_rule_type=1,'简单基本法','标准基本法') end)
from ag_settlement_rule_base where id = f.rule_id
)
) '16' /*基本法属性*/,
sum(case when f.drop_option_code ='D91' then f.referral_amount else null end) as '17' /*D91渠道加扣款1*/,
sum(case when f.drop_option_code ='D92' then f.referral_amount else null end) as '18' /*D92渠道加扣款2*/,