|
@@ -84,4 +84,106 @@
|
|
|
order by fi.created DESC
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getInvoiceAmountInfo" parameterType="com.dayou.dto.MajorProductionSimpleDTO" resultType="com.dayou.vo.FinanceInvoiceVo">
|
|
|
+ SELECT
|
|
|
+ pf.*,
|
|
|
+ orderFund.*,
|
|
|
+ invoice.*
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ id,
|
|
|
+ business_type,
|
|
|
+ real_amount AS orderRealAmount,
|
|
|
+ should_amount
|
|
|
+ FROM
|
|
|
+ order_fund
|
|
|
+ WHERE
|
|
|
+ deleted = 0
|
|
|
+ AND business_type = 'MAJOR_BUSINESS'
|
|
|
+ AND business_id = #{dto.majorId}) orderFund
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ order_fund_id,
|
|
|
+ bank_name,
|
|
|
+ real_amount AS invoiceAmount,
|
|
|
+ title AS invoiceTitle,
|
|
|
+ type AS invoiceType,
|
|
|
+ tax_no,
|
|
|
+ tax_amount AS invoiceTaxAmount,
|
|
|
+ tax_rate AS invoiceTaxRate,
|
|
|
+ state AS invoiceState,
|
|
|
+ real_make_date AS invoiceDate
|
|
|
+ FROM
|
|
|
+ finance_invoice
|
|
|
+ WHERE
|
|
|
+ state != '驳回'
|
|
|
+ AND state != '作废'
|
|
|
+ AND deleted = 0
|
|
|
+ ) invoice ON invoice.order_fund_id = orderFund.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ mp.id,
|
|
|
+ p.real_amount AS prodRealAmount,
|
|
|
+ mp.standard_amount,
|
|
|
+ p.order_fund_id,
|
|
|
+ p.business_type,
|
|
|
+ mp.report_no as productionNo,
|
|
|
+ ( CASE mp.production WHEN 'STATEMENT' THEN '价值意见书' WHEN 'REPORT' THEN '报告' ELSE '复评函' END ) AS productionType
|
|
|
+ FROM
|
|
|
+ major_production mp
|
|
|
+ left JOIN production_fund p ON ( mp.report_no = ifnull(p.production_no,mp.report_no) AND mp.major_id = ifnull(p.business_id,mp.major_id ))
|
|
|
+ WHERE
|
|
|
+
|
|
|
+ mp.deleted = 0
|
|
|
+ AND mp.major_id = #{dto.majorId}
|
|
|
+ <if test="dto.productionNos!=null and dto.productionNos.size()>0">
|
|
|
+ and mp.report_no in (
|
|
|
+ <foreach collection="dto.productionNos" separator="," index="index" item="item">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ ) pf on ( orderFund.id = ifnull(pf.order_fund_id,orderFund.id) AND orderFund.business_type = ifnull(pf.business_type,orderFund.business_type) )
|
|
|
+ order by pf.id asc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getInvoiceAmountInfoEmptyProduction" parameterType="com.dayou.dto.MajorProductionSimpleDTO" resultType="com.dayou.vo.FinanceInvoiceVo">
|
|
|
+ SELECT
|
|
|
+ orderFund.*,
|
|
|
+ invoice.*
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ id,
|
|
|
+ business_type,
|
|
|
+ real_amount AS orderRealAmount,
|
|
|
+ should_amount
|
|
|
+ FROM
|
|
|
+ order_fund
|
|
|
+ WHERE
|
|
|
+ deleted = 0
|
|
|
+ AND business_type = 'MAJOR_BUSINESS'
|
|
|
+ AND business_id = #{dto.majorId}) orderFund
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ order_fund_id,
|
|
|
+ bank_name,
|
|
|
+ real_amount AS invoiceAmount,
|
|
|
+ title AS invoiceTitle,
|
|
|
+ type AS invoiceType,
|
|
|
+ tax_no,
|
|
|
+ tax_amount AS invoiceTaxAmount,
|
|
|
+ tax_rate AS invoiceTaxRate,
|
|
|
+ state AS invoiceState,
|
|
|
+ real_make_date AS invoiceDate
|
|
|
+ FROM
|
|
|
+ finance_invoice
|
|
|
+ WHERE
|
|
|
+ state != '驳回'
|
|
|
+ AND state != '作废'
|
|
|
+ AND deleted = 0
|
|
|
+ ) invoice ON invoice.order_fund_id = orderFund.id
|
|
|
+
|
|
|
+ </select>
|
|
|
</mapper>
|