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,
<!-- t.practitioner_level practitionerLevel, -->
op1.drop_option_name practitionerLevel,
t.commission_amount commissionAmount,
t.commission_type commissionType,
t.referral_rate referralRate,
t.referral_amount referralAmount,
op.drop_option_name commissionPayoutStatus,
pb.payout_yearmonth monthPeriod
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
LEFT JOIN ag_product_plan pp ON pp.id = o.plan_id
LEFT JOIN ag_po_order_commission oc ON oc.order_id = t.order_id AND oc.id = t.commission_id
LEFT JOIN ag_po_order_commission_check c on oc.commission_check_id = c.id
LEFT JOIN ag_acl_insurer i ON i.id = o.insurer_id
LEFT JOIN ag_acl_practitioner pra ON pra.customer_id = t.customer_id <!-- ON pra.id = oc.practitioner_id -->
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
LEFT JOIN ag_acl_customer_fortune_payout_batch pb ON pb.id = t.payout_batch_id
LEFT JOIN ag_md_drop_options op ON op.drop_option_code = oc.commission_status
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
WHERE t.settlement_type = '1'
AND mas.drop_code = 'Commission_Payout_Status'
AND mas1.scenario_code = 'practitioner_level'
AND oc.commission_status = '2'
and setting.practitioner_type_id = 28
and setting.practitioner_type_id = 28
<iftest="item.insurerId != null">
<iftest="item.insurerId != null">
AND i.id = #{item.insurerId,jdbcType=BIGINT}
AND i.id = #{item.insurerId,jdbcType=BIGINT}
...
@@ -88,7 +124,7 @@
...
@@ -88,7 +124,7 @@
and pra.id = #{item.practitionerId,jdbcType=BIGINT}
and pra.id = #{item.practitionerId,jdbcType=BIGINT}
</if>
</if>
<iftest="item.commissionPayoutStatus != null">
<iftest="item.commissionPayoutStatus != null">
and f.commission_payout_status = #{item.commissionPayoutStatus,jdbcType=BIGINT}
and t.commission_payout_status = #{item.commissionPayoutStatus,jdbcType=BIGINT}
</if>
</if>
<iftest="item.commissionPayoutYearmonth != null">
<iftest="item.commissionPayoutYearmonth != null">
and c.check_yearmonth = #{item.commissionPayoutYearmonth,jdbcType=VARCHAR}
and c.check_yearmonth = #{item.commissionPayoutYearmonth,jdbcType=VARCHAR}
...
@@ -96,6 +132,64 @@
...
@@ -96,6 +132,64 @@
<iftest="item.payoutYearmonth != null">
<iftest="item.payoutYearmonth != null">
and pb.payout_yearmonth = #{item.payoutYearmonth,jdbcType=VARCHAR}
and pb.payout_yearmonth = #{item.payoutYearmonth,jdbcType=VARCHAR}