if(o.payment_term IS NOT NULL ,CONCAT(o.payment_term,(case o.payment_term_unit when 'Y' then '年' when 'M' then '月' else '日' END ) ),(SELECT e.element_text from ag_po_order_life_product_elements e where o.id = e.order_id and e.factor_code like 'f_pay_term' LIMIT 1)) paymentTermUnit,
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,
o.order_price orderPrice,
pra.name practitionerName,
dept.name insurerBranchDeptName,
sub.name subordinateSystemName,
f.practitioner_level practitionerLevel,
f.commission_amount commissionAmount,
f.commission_type commissionType,
f.referral_rate referralRate,
f.referral_amount referralAmount,
op.drop_option_name commissionPayoutStatus,
pb.payout_yearmonth monthPeriod
from ag_acl_customer_fortune f
LEFT JOIN ag_po_order o
LEFT JOIN ag_acl_insurer i ON i.id = o.insurer_id
LEFT JOIN ag_product p ON p.id = o.product_id
LEFT JOIN ag_product_plan pp ON pp.id = o.plan_id
ON o.id = f.order_id
LEFT JOIN ag_acl_practitioner pra
LEFT JOIN ag_acl_insurer_branch_dept dept ON pra.dept_id = dept.id
LEFT JOIN ag_acl_practitioner_subordinate_system sub ON sub.id = pra.subordinate_system_id
Left Join ag_acl_practitioner_setting setting on setting.practitioner_id = pra.id
ON pra.customer_id = f.customer_id
LEFT JOIN ag_acl_customer_fortune_payout_batch pb ON pb.id = f.payout_batch_id
LEFT JOIN ag_md_drop_options op
LEFT JOIN ag_md_drop_master mas ON mas.id = op.drop_master_id
ON op.drop_option_code = f.commission_payout_status
left join ag_po_order_commission_check c on o.commission_check_id = c.id
IF(o.payment_term IS NOT NULL ,CONCAT(o.payment_term,(CASE o.payment_term_unit WHEN 'Y' THEN '年' WHEN 'M' THEN '月' ELSE '日' END ) ),(SELECT e.element_text FROM ag_po_order_life_product_elements e WHERE o.id = e.order_id AND e.factor_code LIKE 'f_pay_term' LIMIT 1)) paymentTermUnit,
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,
o.order_price orderPrice,
pra.name practitionerName,
IFNULL(pra.name,cha.name) practitionerName,
dept.name insurerBranchDeptName,
sub.name subordinateSystemName,
op1.drop_option_name practitionerLevel,
...
...
@@ -83,7 +44,8 @@
t.predict_month_period predictMonthPeriod,
op.drop_option_name commissionPayoutStatus,
t.remark,
pb.payout_yearmonth monthPeriod
pb.payout_yearmonth monthPeriod,
t.channel_type channelType
FROM ag_acl_customer_fortune t
LEFT JOIN ag_po_order o ON o.id = t.order_id
LEFT JOIN ag_product p ON p.id = o.product_id
...
...
@@ -98,16 +60,15 @@
LEFT JOIN ag_md_drop_master mas ON mas.id = op.drop_master_id
LEFT JOIN ag_md_drop_options op1 ON op1.id = setting.practitioner_level
LEFT JOIN ag_md_drop_master mas1 ON mas1.id = op1.drop_master_id
LEFT JOIN (SELECT distinct poc.order_id,poc.commission_period,c.* FROM ag_po_order_commission poc,ag_po_order_commission_check c
LEFT JOIN ag_acl_channel_new cha ON cha.customer_id = t.customer_id
LEFT JOIN (select distinct poc.order_id,poc.commission_period,c.* FROM ag_po_order_commission poc,ag_po_order_commission_check c
WHERE poc.commission_check_id=c.id AND poc.commission_status='2' AND poc.commission_type='1'
<iftest="item.commissionPayoutYearmonth == null">
GROUP BY poc.order_id,poc.commission_period
</if>
) c ON c.order_id=t.order_id AND c.commission_period=t.commission_period
WHERE t.settlement_type = '1'
AND mas.drop_code = 'Fortune_Payout_Status'
AND mas1.scenario_code = 'practitioner_level'
and setting.practitioner_type_id = 28
WHERE ((t.settlement_type='1' and setting.practitioner_type_id=28 and mas1.scenario_code='practitioner_level' ) or t.settlement_type='3')
and mas.drop_code = 'Fortune_Payout_Status'
and EXISTS(select 1 from ag_po_order_commission poc
where poc.commission_status='2' and poc.commission_type='1'
and poc.order_id=t.order_id and poc.commission_period=t.commission_period)
...
...
@@ -120,12 +81,15 @@
<iftest="item.insurerBranchId != null">
and pra.insurer_branch_id = #{item.insurerBranchId,jdbcType=BIGINT}
</if>
<iftest="item.channelId != null">
and cha.id = #{item.channelId,jdbcType=BIGINT}
</if>
<iftest="item.channelType != null">
and t.channel_type = #{item.channelType,jdbcType=VARCHAR}
</if>
<iftest="item.insurerBranchDeptId != null">
and dept.id = #{item.insurerBranchDeptId,jdbcType=BIGINT}
</if>
<!-- <if test="item.subordinateSystemId != null">
and sub.id = #{item.subordinateSystemId,jdbcType=BIGINT}
</if>-->
<iftest="item.subsystemIdList != null and item.subsystemIdList.size() > 0">