|
|
@@ -58,10 +58,11 @@
|
|
|
|
|
|
<select id="selBillBalance" resultType="org.springblade.finance.vojo.Acc">
|
|
|
SELECT
|
|
|
+ FC.Corpid AS corpId,
|
|
|
BCD.cname AS corpName,
|
|
|
IFNULL( BC.amount, 0 ) AS amount,
|
|
|
- IFNULL( BC.settlementAmount, 0 ) AS settlementAmount,
|
|
|
- IFNULL( (SUM( FC.Amount ) - SUM( FC.Settlement_Amount )), 0 )AS balance,
|
|
|
+ IFNULL( FS.settlementAmount, 0 ) AS settlementAmount,
|
|
|
+ IFNULL( IFNULL( BC.amount, 0 ) - IFNULL( FS.settlementAmount, 0 ), 0 ) AS balance,
|
|
|
IFNULL( BO.in_overpayment, 0 ) AS inOverpayment
|
|
|
FROM finance_acc FC
|
|
|
LEFT JOIN basic_corps_desc BCD ON BCD.id = FC.Corpid
|
|
|
@@ -82,16 +83,35 @@
|
|
|
<if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
|
|
|
and FC.create_time <= #{acc.createDateList[1]}
|
|
|
</if>
|
|
|
- <if test='acc.createStartDate != null and acc.createStartDate != ""'>
|
|
|
- and FC.create_time >= #{acc.createStartDate}
|
|
|
- </if>
|
|
|
- <if test='acc.createEndDate != null and acc.createEndDate != ""'>
|
|
|
- and FC.create_time <= #{acc.createEndDate}
|
|
|
- </if>
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
FC.Corpid
|
|
|
) BC ON BC.corpId = FC.Corpid
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ FS.Corp_id AS corpId,
|
|
|
+ sum( FS.Amount ) AS settlementAmount
|
|
|
+ FROM finance_settlement FS
|
|
|
+ <where>
|
|
|
+ FS.tenant_id = #{acc.tenantId}
|
|
|
+ AND FS.is_deleted = 0
|
|
|
+ AND FS.finance_status = '结算完成'
|
|
|
+ <if test='acc.billType != null and acc.billType != "" and acc.billType == "申请"'>
|
|
|
+ AND FS.bill_type = '付费'
|
|
|
+ </if>
|
|
|
+ <if test='acc.billType != null and acc.billType != "" and acc.billType == "收费"'>
|
|
|
+ AND FS.bill_type = #{acc.billType}
|
|
|
+ </if>
|
|
|
+ <if test='acc.createDateList != null and acc.createDateList[0] != null and acc.createDateList[0]!= ""'>
|
|
|
+ and FS.completion_time >= #{acc.createDateList[0]}
|
|
|
+ </if>
|
|
|
+ <if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
|
|
|
+ and FS.completion_time <= #{acc.createDateList[1]}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ FS.Corp_id
|
|
|
+ ) FS ON FS.corpId = FC.Corpid
|
|
|
<where>
|
|
|
FC.tenant_id = #{acc.tenantId}
|
|
|
and FC.is_deleted = 0
|
|
|
@@ -101,7 +121,39 @@
|
|
|
</if>
|
|
|
</where>
|
|
|
GROUP BY FC.Corpid
|
|
|
- HAVING SUM(FC.Amount-FC.Settlement_Amount) >= 100
|
|
|
+ HAVING SUM(IFNULL( IFNULL( BC.amount, 0 ) - IFNULL( FS.settlementAmount, 0 ), 0 )) >= 100
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="SelAccItem" resultType="org.springblade.finance.vojo.Acc">
|
|
|
+ SELECT DISTINCT
|
|
|
+ FA.AccSysNo AS accSysNo,
|
|
|
+ FA.quantity AS quantity,
|
|
|
+ FA.Amount AS amount,
|
|
|
+ FA.Settlement_Amount AS settlementAmount,
|
|
|
+ IFNULL( IFNULL( FA.Amount, 0 ) - IFNULL( FA.Settlement_Amount, 0 ), 0 ) AS balance,
|
|
|
+ FS.subject_number as subjectNumber,
|
|
|
+ FS.ACCOUNT_bank AS accountBank,
|
|
|
+ FS.ACCOUNT_NAME AS accountName,
|
|
|
+ FS.ACCOUNT_no AS accountNo,
|
|
|
+ FS.over_payment AS overPayment,
|
|
|
+ 0 as usedProfit,
|
|
|
+ FS.case_over_payment AS caseOverPayment
|
|
|
+ FROM finance_acc FA
|
|
|
+ LEFT JOIN finance_settlement FS ON FS.Src_OrderNo = FA.AccSysNo
|
|
|
+ <where>
|
|
|
+ FA.tenant_id = #{acc.tenantId}
|
|
|
+ AND FA.is_deleted = 0
|
|
|
+ and FC.bill_type = #{acc.billType}
|
|
|
+ <if test="acc.corpId != null and acc.corpId != ''">
|
|
|
+ and FC.Corpid = #{acc.corpId}
|
|
|
+ </if>
|
|
|
+ <if test="acc.accSysNo != null and acc.accSysNo != ''">
|
|
|
+ and FA.AccSysNo like concat('%', #{acc.accSysNo}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="acc.amount != null and acc.amount != ''">
|
|
|
+ and FA.Amount like concat('%', #{acc.amount}, '%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
|
|
|
<select id="SumBillBalance" resultType="java.util.Map">
|