sum(case when drop_option_code ='C04' then f.calculation_rate else null end) '28' /*'经纪人月销售加码奖金%'*/,
sum(case when drop_option_code ='C04' then f.calculation_rate else null end) '28' /*'经纪人月销售加码奖金%'*/,
sum(case when drop_option_code ='C04' then f.referral_amount else null end) '29' /*经纪人月销售加码奖金*/,
sum(case when drop_option_code ='C04' then f.referral_amount else null end) '29' /*经纪人月销售加码奖金*/,
l.introducer_id '30' /*推荐人*/,
(SELECT group_concat(a.name)
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C05' and practitioner_id = l.introducer_id) '31' /*个人推荐率*/,
from ag_acl_customer_fortune t
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C05' and practitioner_id = l.introducer_id) '32' /*个人推荐奖¥*/,
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C05' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.introducer_id
) '30' /*推荐人*/,
(SELECT group_concat(calculation_rate)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C05' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.introducer_id
) '31' /*个人推荐率*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C05' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.introducer_id
) '32' /*个人推荐奖¥*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C15' and sale_practitioner_id = l.s1_team_introducer_id) '33' /*S1体系推荐率*/,
(SELECT group_concat(calculation_rate)
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C15' and sale_practitioner_id = l.s1_team_introducer_id) '34' /*S1体系推荐奖金¥*/,
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_team_introducer_id
) '33' /*S1体系推荐率*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_team_introducer_id
) '34' /*S1体系推荐奖金¥*/,
l.mentor_id '35' /*一代辅导人*/,
(SELECT group_concat(a.name)
l.mentor_level '36' /*一代辅导人职级*/,
from ag_acl_customer_fortune t
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C06' and practitioner_id = l.mentor_id) '37' /*'一代辅导人职级岗位津贴%'*/,
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C06' and practitioner_id = l.mentor_id) '38' /*一代辅导人岗位津贴*/,
where drop_option_code ='C06' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.mentor_id
) '35' /*一代辅导人*/,
(SELECT group_concat(op1.drop_option_name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
LEFT JOIN ag_acl_practitioner_setting b on b.practitioner_id = a.id
LEFT JOIN ag_md_drop_options op1 ON op1.id = b.practitioner_level
where t.drop_option_code ='C06' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.mentor_id
) '36' /*一代辅导人职级*/,
(SELECT group_concat(calculation_rate)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C06' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.mentor_id
) '37' /*'一代辅导人职级岗位津贴%'*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C06' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.mentor_id
) '38' /*一代辅导人岗位津贴*/,
l.in_mentor_id '39' /*二代辅导人*/,
(SELECT group_concat(op1.drop_option_name)
l.in_mentor_level '40' /*二代辅导人职级*/,
from ag_acl_customer_fortune t
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C07' and practitioner_id = l.in_mentor_id) '41' /*'二代辅导人职级岗位津贴%'*/,
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C07' and practitioner_id = l.in_mentor_id) '42' /*二代辅导人岗位津贴*/,
LEFT JOIN ag_acl_practitioner_setting b on b.practitioner_id = a.id
LEFT JOIN ag_md_drop_options op1 ON op1.id = b.practitioner_level
where t.drop_option_code ='C07' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.in_mentor_id
) '39' /*二代辅导人*/,
(SELECT group_concat(op1.drop_option_name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
LEFT JOIN ag_acl_practitioner_setting b on b.practitioner_id = a.id
LEFT JOIN ag_md_drop_options op1 ON op1.id = b.practitioner_level
where t.drop_option_code ='C07' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.in_mentor_id
) '40' /*二代辅导人职级*/,
(SELECT group_concat(calculation_rate)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C07' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.in_mentor_id
) '41' /*'二代辅导人职级岗位津贴%'*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C06' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.in_mentor_id
) '42' /*二代辅导人岗位津贴*/,
l.s1_id '43' /*所属S1分部*/,
l.s1_id '43' /*所属S1分部*/,
(case when l.s1_team_leader_id is not null then
(case when l.s1_team_leader_id is not null then
...
@@ -572,16 +630,28 @@
...
@@ -572,16 +630,28 @@
where t.drop_option_code ='C10' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id and a.id=l.s3_team_leader_id
where t.drop_option_code ='C10' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id and a.id=l.s3_team_leader_id
) '59' /*S3团队长辅导津贴*/,
) '59' /*S3团队长辅导津贴*/,
(SELECT group_concat(sale_practitioner_id) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.raise_id) '60' /*S1育成人*/,
(SELECT group_concat(a.name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s1_raise_id
) '60' /*S1育成人*/,
(SELECT group_concat(op1.drop_option_name)
(SELECT group_concat(op1.drop_option_name)
from ag_acl_customer_fortune t
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
LEFT JOIN ag_acl_practitioner_setting b on b.practitioner_id = a.id
LEFT JOIN ag_acl_practitioner_setting b on b.practitioner_id = a.id
LEFT JOIN ag_md_drop_options op1 ON op1.id = b.practitioner_level
LEFT JOIN ag_md_drop_options op1 ON op1.id = b.practitioner_level
where t.drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id
where t.drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s1_raise_id
) '61' /*S1育成人职级*/,
) '61' /*S1育成人职级*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id) '62' /*S1育成奖金率*/,
(SELECT group_concat(calculation_rate)
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id) '63' /*S1育成金额*/,
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s1_raise_id
) '62' /*S1育成奖金率*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s1_raise_id
) '63' /*S1育成金额*/,
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.calculation_rate else null end) '64' /*C14直接销售加码佣金率*/,
sum(case when drop_option_code ='C14' then f.referral_amount else null end) '65' /*C14直接销售加码佣金*/,
sum(case when drop_option_code ='C14' then f.referral_amount else null end) '65' /*C14直接销售加码佣金*/,
...
@@ -607,23 +677,87 @@
...
@@ -607,23 +677,87 @@
where t.drop_option_code ='R04' and t.order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id and c.commission_status='2'
where t.drop_option_code ='R04' and t.order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id and c.commission_status='2'
) '72' /*R04-续年度绩效奖金(旧)*/,
) '72' /*R04-续年度绩效奖金(旧)*/,
l.s1_team_introducer_id '73' /*S1推荐人*/,
(SELECT group_concat(a.name)
l.s2_team_introducer_id '74' /*S2推荐人*/,
from ag_acl_customer_fortune t
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C15' and sale_practitioner_id = l.s2_team_introducer_id) '74' /*S2体系推荐率*/,
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C15' and sale_practitioner_id = l.s2_team_introducer_id) '75' /*S2体系推荐奖金¥*/,
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s1_team_introducer_id
l.s3_team_introducer_id '77' /*S3推荐人*/,
) '73' /*S1推荐人*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C15' and sale_practitioner_id = l.s3_team_introducer_id) '78' /*S3体系推荐率*/,
(SELECT group_concat(a.name)
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C15' and sale_practitioner_id = l.s3_team_introducer_id) '79' /*S3体系推荐奖金¥*/,
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
(SELECT group_concat(sale_practitioner_id) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.s2_raise_id) '80' /*S2育成人*/,
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s2_team_introducer_id
l.s2_raise_level '81' /*S2育成人职级*/,
) '74' /*S2推荐人*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.s2_raise_id) '82' /*S2育成奖金率*/,
(SELECT group_concat(calculation_rate)
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.s2_raise_id) '83' /*S2育成金额*/,
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
(SELECT group_concat(sale_practitioner_id) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.s3_raise_id) '84' /*S3育成人*/,
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s2_team_introducer_id
l.s3_raise_level '85' /*S3育成人职级*/,
) '74' /*S2体系推荐率*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.s3_raise_id) '86' /*S3育成奖金率*/,
(SELECT group_concat(referral_amount)
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.s3_raise_id) '87' /*S3育成金额*/,
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s2_team_introducer_id
) '75' /*S2体系推荐奖金¥*/,
(SELECT group_concat(a.name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_team_introducer_id
) '77' /*S3推荐人*/,
(SELECT group_concat(calculation_rate)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_team_introducer_id
) '78' /*S3体系推荐率*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C15' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_team_introducer_id
) '79' /*S3体系推荐奖金¥*/,
(SELECT group_concat(a.name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s2_raise_id
) '80' /*S2育成人*/,
(SELECT group_concat(op1.drop_option_name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
LEFT JOIN ag_acl_practitioner_setting b on b.practitioner_id = a.id
LEFT JOIN ag_md_drop_options op1 ON op1.id = b.practitioner_level
where t.drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s2_raise_id
) '81' /*S2育成人职级*/,
(SELECT group_concat(calculation_rate)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s2_raise_id
) '82' /*S2育成奖金率*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s2_raise_id
) '83' /*S2育成金额*/,
(SELECT group_concat(a.name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_raise_id
) '84' /*S3育成人*/,
(SELECT group_concat(op1.drop_option_name)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
LEFT JOIN ag_acl_practitioner_setting b on b.practitioner_id = a.id
LEFT JOIN ag_md_drop_options op1 ON op1.id = b.practitioner_level
where t.drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_raise_id
) '85' /*S3育成人职级*/,
(SELECT group_concat(calculation_rate)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_raise_id
) '86' /*S3育成奖金率*/,
(SELECT group_concat(referral_amount)
from ag_acl_customer_fortune t
LEFT JOIN ag_acl_practitioner a on a.customer_id = t.customer_id
where drop_option_code ='C09' and order_id=f.order_id and sale_practitioner_id = l.practitioner_id and a.id=l.s3_raise_id
) '87' /*S3育成金额*/,
sum(case when drop_option_code ='C95' then f.referral_amount else null end) as '88' /*其它税前加扣款1*/,
sum(case when drop_option_code ='C95' then f.referral_amount else null end) as '88' /*其它税前加扣款1*/,
sum(case when drop_option_code ='C96' then f.referral_amount else null end) as '89' /*其它税前加扣款2*/,
sum(case when drop_option_code ='C96' then f.referral_amount else null end) as '89' /*其它税前加扣款2*/,