|
|
@@ -1688,37 +1688,42 @@
|
|
|
<select id="querySettledAmount" resultType="com.jzg.organization.entity.dto.CalRes">
|
|
|
select
|
|
|
a.company_id ,
|
|
|
- sum(COALESCE(a.jq_supervise_costs_premiums, 0)+ COALESCE(a.sy_supervise_costs_premiums, 0)+ coalesce(a.jy_supervise_costs_proportion, 0 )) as sxf_settlement,
|
|
|
- sum(COALESCE(a.jq_other_costs_premiums, 0)+ COALESCE(a.sy_other_costs_premiums, 0)+ coalesce(a.jy_other_costs_premiums, 0 )) as gdf_settlement
|
|
|
+ sum(COALESCE(a.actual_received_amount, 0)) as settlement
|
|
|
from
|
|
|
(
|
|
|
select
|
|
|
ipi.company_id ,
|
|
|
- ipi.jq_supervise_costs_premiums,
|
|
|
- ipi.sy_supervise_costs_premiums,
|
|
|
- ipi.jy_supervise_costs_proportion,
|
|
|
- ipi.jq_other_costs_premiums,
|
|
|
- ipi.sy_other_costs_premiums,
|
|
|
- ipi.jy_other_costs_premiums,
|
|
|
- ipi.settlement_status ,
|
|
|
- ipi.settlement_time
|
|
|
- from
|
|
|
- ins_ply_income ipi
|
|
|
+ COALESCE(ins.actual_received_amount, 0) as actual_received_amount
|
|
|
+ from ins_ply_income_invoice_settlement ins
|
|
|
+ inner join ins_ply_income_invoice inc
|
|
|
+ on ins.invoice_id = inc.id
|
|
|
+ AND inc.is_delete = 0
|
|
|
+ inner join ins_ply_income_invoice_link link
|
|
|
+ on link.invoice_id = inc.id
|
|
|
+ AND link.is_delete = 0
|
|
|
+ inner join ins_ply_income ipi
|
|
|
+ on link.income_id = ipi.id
|
|
|
+ AND ipi.is_delete = 0
|
|
|
<where>
|
|
|
- ipi.is_delete = 0
|
|
|
- AND ipi.settlement_status = 1
|
|
|
- <if test="settledStartDate != null and settledStartDate != ''">
|
|
|
- AND ipi.settlement_time >= cast( '${settledStartDate}' as datetime)
|
|
|
+ ins.is_delete = 0
|
|
|
+ <if test="settledStartDate != null">
|
|
|
+ AND ins.receive_payment_date >= #{settledStartDate}
|
|
|
</if>
|
|
|
- <if test="settledEndDate != null and settledEndDate != ''">
|
|
|
- AND ipi.settlement_time < cast('${settledEndDate}' as datetime)
|
|
|
+ <if test="settledEndDate != null">
|
|
|
+ AND ins.receive_payment_date < #{settledEndDate}
|
|
|
</if>
|
|
|
<if test="agreementType != null and agreementType != ''">
|
|
|
AND ipi.agreement_type = #{agreementType}
|
|
|
</if>
|
|
|
+ <if test="invoiceTypes != null and invoiceTypes.size() > 0">
|
|
|
+ AND inc.invoice_type IN
|
|
|
+ <foreach collection="invoiceTypes" item="invoiceType" open="(" separator="," close=")">
|
|
|
+ #{invoiceType}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
</where>
|
|
|
) a
|
|
|
- group by a.company_id
|
|
|
+ group by a.company_id
|
|
|
</select>
|
|
|
<select id="queryFollowIncome" resultType="com.jzg.commons.entity.finance.dto.InsPlyIncomeDto">
|
|
|
SELECT
|