|
|
@@ -755,6 +755,9 @@
|
|
|
<if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
|
|
|
AND ipii.company_id = #{settlementQueryVo.companyId}
|
|
|
</if>
|
|
|
+ <if test="settlementQueryVo.partnerCompanyId != null and settlementQueryVo.partnerCompanyId != ''">
|
|
|
+ AND fo.partner_company_id = #{settlementQueryVo.partnerCompanyId}
|
|
|
+ </if>
|
|
|
<if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
|
|
|
AND ipii.invoice_party = #{settlementQueryVo.invoiceParty}
|
|
|
</if>
|
|
|
@@ -784,6 +787,91 @@
|
|
|
order by ipiis.create_time desc
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ <select id="followSettlementDetailExcel" resultType="com.jzg.commons.entity.finance.vo.InvoiceRecordResult">
|
|
|
+ SELECT
|
|
|
+ ipii.id,
|
|
|
+ ipii.company_id,
|
|
|
+ ipii.invoice_no,
|
|
|
+ ipii.invoice_type,
|
|
|
+ ipii.invoice_risk_type,
|
|
|
+ CASE
|
|
|
+ WHEN ipii.invoice_party = '1' THEN
|
|
|
+ '我方开票' ELSE '保司开票'
|
|
|
+ END as invoice_party,
|
|
|
+ ipii.overinflated_amount,
|
|
|
+ ipii.receivable_supervise_premium,
|
|
|
+ ipii.tax_point,
|
|
|
+ ipii.create_time,
|
|
|
+ ipii.create_by,
|
|
|
+ ipii.update_time,
|
|
|
+ ipii.update_by,
|
|
|
+ eic.name as company_name,
|
|
|
+ eic.name_simple as companyNameSimple,
|
|
|
+ sum( ipiis.actual_received_amount ) AS actual_received_amount,
|
|
|
+ ipii.status,
|
|
|
+ ipii.payment_reason,
|
|
|
+ GROUP_CONCAT(DISTINCT iffo.year SEPARATOR ',') AS year,
|
|
|
+ GROUP_CONCAT(DISTINCT iffo.month SEPARATOR ',') AS month,
|
|
|
+ iffo.partner_company_id,
|
|
|
+ ( select cp.name from esm_ins_company cp where cp.id = iffo.partner_company_id) as partner_company_name
|
|
|
+ FROM
|
|
|
+ ins_ply_income_invoice ipii
|
|
|
+ LEFT JOIN ins_ply_follow_invoice_link ipfii ON ipii.id = ipfii.invoice_id AND ipfii.is_delete = 0
|
|
|
+ LEFT JOIN ins_fee_follow_order iffo ON iffo.id = ipfii.follow_id AND iffo.is_delete = 0
|
|
|
+ LEFT JOIN ins_ply_income_invoice_settlement ipiis ON ipii.id = ipiis.invoice_id AND ipiis.is_delete = 0
|
|
|
+ LEFT JOIN esm_ins_company eic on eic.id = ipii.company_id AND eic.is_delete = 0
|
|
|
+ <where>
|
|
|
+ ipii.is_delete = 0
|
|
|
+ AND ipii.system_code = #{settlementQueryVo.systemCode}
|
|
|
+ <if test="settlementQueryVo.invoicePerson != null and settlementQueryVo.invoicePerson != ''">
|
|
|
+ AND ipiis.create_by like concat('%',#{settlementQueryVo.invoicePerson},'%')
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
|
|
|
+ AND ipii.invoice_party = #{settlementQueryVo.invoiceParty}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
|
|
|
+ AND ipii.id = #{settlementQueryVo.invoiceId}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
|
|
|
+ AND ipii.company_id = #{settlementQueryVo.companyId}
|
|
|
+ </if>
|
|
|
+ <!-- 这里重复了invoiceParty判断,可以删掉重复的if标签 -->
|
|
|
+ <if test="settlementQueryVo.status != null and settlementQueryVo.status != ''">
|
|
|
+ AND ipii.status = #{settlementQueryVo.status}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.partnerCompanyId != null and settlementQueryVo.partnerCompanyId != ''">
|
|
|
+ AND iffo.partner_company_id = #{settlementQueryVo.partnerCompanyId}
|
|
|
+ </if>
|
|
|
+ <!-- 严重逻辑错误:时间字段对比了金额字段 -->
|
|
|
+ <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != '' and settlementQueryVo.settlementTimeEnd != null and settlementQueryVo.settlementTimeEnd != '' ">
|
|
|
+ AND ipiis.create_time between #{settlementQueryVo.settlementTimeStart} and #{settlementQueryVo.settlementTimeEnd}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
|
|
|
+ AND ipii.invoice_type IN
|
|
|
+ <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
|
|
|
+ #{invoiceType}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ <if test="settlementQueryVo.settlementStatus != null and settlementQueryVo.settlementStatus != ''">
|
|
|
+ HAVING CASE
|
|
|
+ WHEN ipii.receivable_supervise_premium = SUM(ipiis.actual_received_amount) THEN '1'
|
|
|
+ ELSE '0'
|
|
|
+ END = #{settlementQueryVo.settlementStatus}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ ipii.id,
|
|
|
+ ipii.receivable_supervise_premium,
|
|
|
+ ipii.invoice_type,
|
|
|
+ ipii.company_id,
|
|
|
+ ipii.invoice_party,
|
|
|
+ iffo.partner_company_id
|
|
|
+ ORDER BY ipii.create_time DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
<select id="getSuperviseSettlementDetailExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailExcelDto">
|
|
|
select ipi.contact_person, ipi.contact_person_phone,
|
|
|
ipiis.id as settlementId,
|
|
|
@@ -855,6 +943,78 @@
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
+ <select id="getPlatFormSettlementDetailExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailExcelDto">
|
|
|
+ select ipi.contact_person, ipi.contact_person_phone,
|
|
|
+ ipiis.id as settlementId,
|
|
|
+ ipiis.invoice_id as invoiceId,
|
|
|
+ io.company_name as companyName,
|
|
|
+ io.signing_time as signingTime,
|
|
|
+ ipii.status as status,
|
|
|
+ ipi.license_no as licenseNo,
|
|
|
+ io.product_name as productName,
|
|
|
+ ipii.invoice_type as invoiceType,
|
|
|
+ ipii.invoice_party as invoiceParty,
|
|
|
+ ipii.tax_point as taxPoint,
|
|
|
+ COALESCE(ipi.jq_supervise_costs_premiums, 0) + COALESCE(ipi.sy_supervise_costs_premiums, 0) + COALESCE(ipi.jy_supervise_costs_premiums, 0) + COALESCE(ipi.jq_other_costs_premiums, 0) + COALESCE(ipi.sy_other_costs_premiums, 0) + COALESCE(ipi.jy_other_costs_premiums, 0) AS receivableSuperviseCosts,
|
|
|
+ ipi.jq_premium as jqPremium,
|
|
|
+ ipi.jq_supervise_costs_proportion as jqSuperviseCostsProportion,
|
|
|
+ ipi.jq_policy_no as jqPolicyNo,
|
|
|
+ ipi.sy_premium as syPremium,
|
|
|
+ ipi.sy_supervise_costs_proportion as sySuperviseCostsProportion,
|
|
|
+ ipi.sy_policy_no as syPolicyNo,
|
|
|
+ ipi.jy_premium as jyPremium,
|
|
|
+ ipi.jy_supervise_costs_proportion as jySuperviseCostsProportion,
|
|
|
+ ipi.jy_policy_no as jyPolicyNo,
|
|
|
+ ipi.tax_premium as taxPremium,
|
|
|
+ ipii.create_by as invoicePerson,
|
|
|
+ ipii.create_time as invoiceTime,
|
|
|
+ ipiis.create_by as settlementPerson,
|
|
|
+ ipiis.create_time as settlementTime
|
|
|
+ FROM
|
|
|
+ ins_ply_income_invoice ipii
|
|
|
+ LEFT JOIN ins_ply_income_invoice_settlement ipiis ON ipiis.invoice_id = ipii.id AND ipiis.is_delete = 0
|
|
|
+ LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id AND ipil.is_delete = 0
|
|
|
+ LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id AND ipi.is_delete = 0
|
|
|
+ LEFT JOIN ins_orders io ON ipi.order_no = io.id AND io.is_delete = 0
|
|
|
+ <where>
|
|
|
+ ipii.is_delete = 0
|
|
|
+ AND ipii.system_code = #{settlementQueryVo.systemCode}
|
|
|
+ <if test="settlementQueryVo.settlementId != null and settlementQueryVo.settlementId != ''">
|
|
|
+ AND ipiis.id = #{settlementQueryVo.settlementId}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
|
|
|
+ AND ipiis.id IN
|
|
|
+ <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
|
|
|
+ #{settlementId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
|
|
|
+ AND ipii.invoice_type IN
|
|
|
+ <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
|
|
|
+ #{invoiceType}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
|
|
|
+ AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
|
|
|
+ AND ipi.company_id = #{settlementQueryVo.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
|
|
|
+ AND ipii.invoice_party = #{settlementQueryVo.invoiceParty}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.settlementPerson != null and settlementQueryVo.settlementPerson != ''">
|
|
|
+ AND ipiis.create_by = #{settlementQueryVo.settlementPerson}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != ''">
|
|
|
+ AND ipiis.create_time between #{settlementQueryVo.signingTimeStart} and #{settlementQueryVo.signingTimeEnd}
|
|
|
+ </if>
|
|
|
+ <if test="settlementQueryVo.agreementType != null and settlementQueryVo.agreementType != ''">
|
|
|
+ AND ipi.agreement_type = #{settlementQueryVo.agreementType}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
|
|
|
<select id="getSuperviseSettlementDetailJyExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailJyExcelDto">
|
|
|
select
|
|
|
@@ -1908,8 +2068,12 @@
|
|
|
</where>
|
|
|
</select>
|
|
|
<!-- 查询发票结算的金额 2026年6月22日15:48:33 lipf -->
|
|
|
- <select id="querySettledAmountByInvoiceIds" resultType="java.math.BigDecimal">
|
|
|
- select sum(ipiis.actual_received_amount ) from ins_ply_income_invoice_settlement ipiis
|
|
|
+ <select id="querySettledAmountByInvoiceIds" resultType="com.jzg.commons.entity.finance.vo.InsPlyIncomeInvoiceSettlementVo">
|
|
|
+ select
|
|
|
+ sum(ipiis.actual_received_amount ) as actual_received_amount,
|
|
|
+ sum(ipiis.settlement_payment_difference ) as settlement_payment_difference
|
|
|
+ from
|
|
|
+ ins_ply_income_invoice_settlement ipiis
|
|
|
<where>
|
|
|
<if test="invoiceIdList != null and invoiceIdList.size() > 0">
|
|
|
and ipiis.invoice_id in
|
|
|
@@ -1920,4 +2084,49 @@
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+ <select id="selectPlatformCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO">
|
|
|
+ SELECT
|
|
|
+ ipi.company_id,
|
|
|
+ ipii.contact_person,
|
|
|
+ ipii.contact_person_phone,
|
|
|
+ COALESCE(SUM(sett.actual_received_amount), 0.00) AS totalSettlementAmount,
|
|
|
+ COALESCE(SUM(ipii.receivable_supervise_premium), 0.00) AS totalReceivable,
|
|
|
+ COALESCE(SUM(sett.settlement_payment_difference), 0.00) AS totalPaymentDifference
|
|
|
+ FROM ins_ply_income ipi
|
|
|
+ LEFT JOIN ins_ply_income_invoice_link ipil ON ipi.id = ipil.income_id AND ipil.is_delete = 0
|
|
|
+ LEFT JOIN ins_ply_income_invoice ipii ON ipil.invoice_id = ipii.id AND ipii.is_delete = 0
|
|
|
+ LEFT JOIN ins_ply_income_invoice_settlement sett ON ipii.id = sett.invoice_id AND sett.is_delete = 0
|
|
|
+ <where>
|
|
|
+ ipi.is_delete = 0
|
|
|
+ <if test="query.companyId != null and query.companyId != ''">
|
|
|
+ AND ipi.company_id = #{query.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="query.contactPersonPhone != null and query.contactPersonPhone != ''">
|
|
|
+ AND ipii.contact_person_phone LIKE CONCAT('%', #{query.contactPersonPhone}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="query.contactPerson != null and query.contactPerson != ''">
|
|
|
+ AND ipii.contact_person LIKE CONCAT('%', #{query.contactPerson}, '%')
|
|
|
+ </if>
|
|
|
+ -- 跟单订单创建时间范围
|
|
|
+ <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
|
|
|
+ AND ipii.create_time BETWEEN #{query.startTime} AND #{query.endTime}
|
|
|
+ </if>
|
|
|
+ -- 发票状态筛选
|
|
|
+ <if test="query.status != null">
|
|
|
+ AND ipii.status = #{query.status}
|
|
|
+ </if>
|
|
|
+ -- 开票时间范围
|
|
|
+ <if test="query.invoiceStartTime != null and query.invoiceStartTime != '' and query.invoiceEndTime != null and query.invoiceEndTime != ''">
|
|
|
+ AND ipii.invoice_time BETWEEN #{query.invoiceStartTime} AND #{query.invoiceEndTime}
|
|
|
+ </if>
|
|
|
+ -- 结算创建时间范围(子查询过滤结算时间)
|
|
|
+ <if test="query.settlementStartTime != null and query.settlementStartTime != '' and query.settlementEndTime != null and query.settlementEndTime != ''">
|
|
|
+ AND sett.create_time BETWEEN #{query.settlementStartTime} AND #{query.settlementEndTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY ipii.contact_person_phone, ipii.contact_person, ipi.company_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
</mapper>
|