From ca29695c77dd697a6b6253b6e4d46ad70ca40c41 Mon Sep 17 00:00:00 2001 From: linfso Date: Fri, 30 May 2025 08:01:16 +0800 Subject: [PATCH] md --- .../resources/mapper/EmisSettleBillMapper.xml | 79 ++++++++++++++++--- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml index 0a13945fb..b9520e586 100644 --- a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml @@ -146,15 +146,16 @@ tba.salesmen as salesmen, tba.payee as payee, tba.create_time as createTime, - tbb.satisfyMoney as satisfyMoney, - tbb.allowanceMoney as allowanceMoney, - tbb.deductionMoney as deductionMoney, - tbb.otherMoney as otherMoney, - if( tbb.totalPayMoney > 0,tbb.totalPayMoney-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney), 0 ) AS totalPayMoney, - if( tbb.recdMoneyIn > 0,tbb.recdMoneyIn-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney),0) AS recdMoneyIn, - if( tbb.recdPayMoney60D > 0,tbb.recdPayMoney60D-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney),0) recdPayMoney60D, - if( tbb.recdPayMoneyGreat60D >0,tbb.recdPayMoneyGreat60D-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney),0) recdPayMoneyGreat60D, - ( tba.rec_money - tba.reced_money - (tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney) ) AS noRecMoney + tbc.satisfyMoney as satisfyMoney, + tbc.allowanceMoney as allowanceMoney, + tbc.deductionMoney as deductionMoney, + tbc.otherMoney as otherMoney, + tbc.totalOtherMoney as totalOtherMoney, + if( tbb.totalPayMoney > 0,tbb.totalPayMoney-tbc.totalOtherMoney, 0 ) AS totalPayMoney, + if( tbb.recdMoneyIn > 0,tbb.recdMoneyIn-tbc.totalOtherMoney,0) AS recdMoneyIn, + if( tbb.recdPayMoney60D > 0,tbb.recdPayMoney60D-tbc.totalOtherMoney,0) recdPayMoney60D, + if( tbb.recdPayMoneyGreat60D >0,tbb.recdPayMoneyGreat60D-tbc.totalOtherMoney,0) recdPayMoneyGreat60D, + ( tba.rec_money - tba.reced_money - tbc.totalOtherMoney ) AS noRecMoney FROM ( SELECT @@ -237,10 +238,6 @@ LEFT JOIN ( SELECT a.settle_bill_no, - sum( ifnull(b.satisfy_money,0) ) AS satisfyMoney, - sum( ifnull(b.allowance_money,0) ) AS allowanceMoney, - sum( ifnull(b.deduction_money,0) ) AS deductionMoney, - sum( ifnull(b.other_money,0) ) AS otherMoney, sum( ifnull(d.pay_money,0) ) AS totalPayMoney, sum( if(b.trade_date a.payment_due_date,ifnull(d.pay_money,0) ,0) ) AS recdMoneyIn, sum( if(a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date ]]> a.payment_due_date and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D, @@ -295,6 +292,62 @@ GROUP BY a.settle_bill_no ) tbb ON tba.settle_bill_no = tbb.settle_bill_no + LEFT JOIN ( + SELECT + a.settle_bill_no, + sum( ifnull(b.satisfy_money,0) ) AS satisfyMoney, + sum( ifnull(b.allowance_money,0) ) AS allowanceMoney, + sum( ifnull(b.deduction_money,0) ) AS deductionMoney, + sum( ifnull(b.other_money,0) ) AS otherMoney, + sum(ifnull(b.satisfy_money,0)+ifnull(b.allowance_money,0)+ifnull(b.deduction_money,0)+ifnull(b.other_money,0) ) as totalOtherMoney + FROM + emis_settle_bill a, + emis_settle_pay_record b, + emis_settle_pay_bill_rel c + + a.del_flag = '0' + AND b.del_flag = '0' + AND c.del_flag = '0' + AND a.settle_bill_no = c.settle_bill_no + AND b.pay_id = c.pay_id + and FIND_IN_SET(a.`settle_bill_no`,#{settleBillNo}) + and a.cust_no = #{custNo} + and a.salesmen = #{salesmen} + and a.payee = #{payee} + and a.settle_type= #{settleType} + and FIND_IN_SET(a.`bill_month`,#{billMonth}) + and a.open_bill_status = #{openBillStatus} + and a.payment_status = #{paymentStatus} + + + and b.create_by = #{params.payCreateBy} + + + and b.trade_date = ]]> #{params.beginTradeDate} + + + and b.trade_date #{params.endTradeDate} + + + and pay_id in( + select pay_id from emis_settle_pay_rel espr + where espr.del_flag='0' + and FIND_IN_SET(espr.`bill_no`,#{params.billCode}) + ) + + + + and ( + a.salesmen=#{params.privEmpName} + or a.payee=#{params.privEmpName} + or a.salesmen in( + select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() = ]]> esr.start_date and now() esr.end_date and esr.sales_ass=#{params.privEmpName} + ) + ) + + + GROUP BY a.settle_bill_no + ) tbc ON tba.settle_bill_no = tbc.settle_bill_no