(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' /*二代辅导人岗位津贴*/,
(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' /*二代辅导人岗位津贴*/,
l.s1_id '43' /*所属S1分部*/,
l.s1_id '43' /*所属S1分部*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '44' /*S1团队达标奖金率*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, calculation_rate)) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '44' /*S1团队达标奖金率*/,
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '45' /*'S1团队达标奖金¥(季度)'*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, referral_amount)) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '45' /*'S1团队达标奖金¥(季度)'*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '46' /*S1团队长辅导津贴比率*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, calculation_rate)) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '46' /*S1团队长辅导津贴比率*/,
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '47' /*S1团队长辅导津贴*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, referral_amount)) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s1_team_leader_id) '47' /*S1团队长辅导津贴*/,
'' as '48' /*S1续期绩效奖金*/,
'' as '48' /*S1续期绩效奖金*/,
l.s2_id '49' /*所属S2体系*/,
l.s2_id '49' /*所属S2体系*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '50' /*S2团队达标奖金率*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, calculation_rate)) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '50' /*S2团队达标奖金率*/,
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '51' /*'S2团队达标奖金¥(季度)'*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, referral_amount)) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '51' /*'S2团队达标奖金¥(季度)'*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '52' /*S2团队长辅导津贴比率*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, calculation_rate)) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '52' /*S2团队长辅导津贴比率*/,
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '53' /*S2团队长辅导津贴*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, referral_amount)) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s2_team_leader_id) '53' /*S2团队长辅导津贴*/,
'' as '54' /*S2续期绩效奖金*/,
'' as '54' /*S2续期绩效奖金*/,
l.s3_id '55' /*所属S3纵队*/,
l.s3_id '55' /*所属S3纵队*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '56' /*S3团队达标奖金率*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, calculation_rate)) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '56' /*S3团队达标奖金率*/,
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '57' /*'S3团队达标奖金¥(季度)'*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, referral_amount)) from ag_acl_customer_fortune where drop_option_code ='C08' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '57' /*'S3团队达标奖金¥(季度)'*/,
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '58' /*S3团队长辅导津贴比率*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, calculation_rate)) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '58' /*S3团队长辅导津贴比率*/,
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '59' /*S3团队长辅导津贴*/,
(SELECT group_concat(CONCAT_WS('-', practitioner_id, referral_amount)) from ag_acl_customer_fortune where drop_option_code ='C10' and order_id=f.order_id and practitioner_id = l.s3_team_leader_id) '59' /*S3团队长辅导津贴*/,
l.raise_id '60' /*育成人*/,
l.raise_id '60' /*育成人*/,
l.raise_level '61' /*育成人职级*/,
l.raise_level '61' /*育成人职级*/,
...
@@ -513,12 +513,17 @@
...
@@ -513,12 +513,17 @@
sum(case when drop_option_code ='S01' then f.referral_amount else null end) '67' /*S01-首年度销售佣金*/,
sum(case when drop_option_code ='S01' then f.referral_amount else null end) '67' /*S01-首年度销售佣金*/,
sum(case when drop_option_code ='S03' then f.referral_amount else null end) '68' /*S03-首年度辅导奖金*/,
sum(case when drop_option_code ='S03' then f.referral_amount else null end) '68' /*S03-首年度辅导奖金*/,
sum(case when drop_option_code ='R01' then f.referral_amount else null end) '69' /*R01-首年度直接销售佣金(旧)*/,
sum(case when drop_option_code ='R02' then f.referral_amount else null end) '70' /*R02-续年度直接销售拥金(旧)*/,
sum(case when drop_option_code ='R03' then f.referral_amount else null end) '71' /*R03-续年度辅导佣金(旧)*/,
sum(case when drop_option_code ='R04' then f.referral_amount else null end) '72' /*R04-续年度绩效奖金(旧)*/,
f.order_id,
f.order_id,
f.customer_id
l.customer_id
FROM ag_acl_customer_fortune f
FROM ag_acl_customer_fortune f
INNER JOIN ag_acl_life_insurance_practitioner l on l.order_id = f.order_id and l.customer_id = f.customer_id
LEFT JOIN ag_acl_customer_fortune_payout_batch pb on pb.id = f.payout_batch_id
LEFT JOIN ag_acl_customer_fortune_payout_batch pb on pb.id = f.payout_batch_id
LEFT JOIN ag_acl_life_insurance_practitioner l on l.order_id = f.order_id and l.practitioner_id = f.practitioner_id
LEFT JOIN ag_acl_practitioner pra on pra.customer_id = f.customer_id
LEFT JOIN ag_acl_practitioner pra on pra.customer_id = f.customer_id
LEFT JOIN ag_acl_practitioner_setting ps on ps.practitioner_id = pra.id
LEFT JOIN ag_acl_practitioner_setting ps on ps.practitioner_id = pra.id