md
This commit is contained in:
parent
034ad477ce
commit
ca29695c77
@ -146,15 +146,16 @@
|
|||||||
tba.salesmen as salesmen,
|
tba.salesmen as salesmen,
|
||||||
tba.payee as payee,
|
tba.payee as payee,
|
||||||
tba.create_time as createTime,
|
tba.create_time as createTime,
|
||||||
tbb.satisfyMoney as satisfyMoney,
|
tbc.satisfyMoney as satisfyMoney,
|
||||||
tbb.allowanceMoney as allowanceMoney,
|
tbc.allowanceMoney as allowanceMoney,
|
||||||
tbb.deductionMoney as deductionMoney,
|
tbc.deductionMoney as deductionMoney,
|
||||||
tbb.otherMoney as otherMoney,
|
tbc.otherMoney as otherMoney,
|
||||||
if( tbb.totalPayMoney > 0,tbb.totalPayMoney-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney), 0 ) AS totalPayMoney,
|
tbc.totalOtherMoney as totalOtherMoney,
|
||||||
if( tbb.recdMoneyIn > 0,tbb.recdMoneyIn-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney),0) AS recdMoneyIn,
|
if( tbb.totalPayMoney > 0,tbb.totalPayMoney-tbc.totalOtherMoney, 0 ) AS totalPayMoney,
|
||||||
if( tbb.recdPayMoney60D > 0,tbb.recdPayMoney60D-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney),0) recdPayMoney60D,
|
if( tbb.recdMoneyIn > 0,tbb.recdMoneyIn-tbc.totalOtherMoney,0) AS recdMoneyIn,
|
||||||
if( tbb.recdPayMoneyGreat60D >0,tbb.recdPayMoneyGreat60D-(tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney),0) recdPayMoneyGreat60D,
|
if( tbb.recdPayMoney60D > 0,tbb.recdPayMoney60D-tbc.totalOtherMoney,0) recdPayMoney60D,
|
||||||
( tba.rec_money - tba.reced_money - (tbb.satisfyMoney + tbb.allowanceMoney + tbb.deductionMoney + tbb.otherMoney) ) AS noRecMoney
|
if( tbb.recdPayMoneyGreat60D >0,tbb.recdPayMoneyGreat60D-tbc.totalOtherMoney,0) recdPayMoneyGreat60D,
|
||||||
|
( tba.rec_money - tba.reced_money - tbc.totalOtherMoney ) AS noRecMoney
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
@ -237,10 +238,6 @@
|
|||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
a.settle_bill_no,
|
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( ifnull(d.pay_money,0) ) AS totalPayMoney,
|
||||||
sum( if(b.trade_date <![CDATA[ <= ]]> a.payment_due_date,ifnull(d.pay_money,0) ,0) ) AS recdMoneyIn,
|
sum( if(b.trade_date <![CDATA[ <= ]]> a.payment_due_date,ifnull(d.pay_money,0) ,0) ) AS recdMoneyIn,
|
||||||
sum( if(a.settle_type='2' and a.credit_period <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ < ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
|
sum( if(a.settle_type='2' and a.credit_period <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ < ]]> 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
|
GROUP BY a.settle_bill_no
|
||||||
) tbb ON tba.settle_bill_no = tbb.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
|
||||||
|
<where>
|
||||||
|
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
|
||||||
|
<if test="settleBillNo != null and settleBillNo != ''"> and FIND_IN_SET(a.`settle_bill_no`,#{settleBillNo})</if>
|
||||||
|
<if test="custNo != null and custNo != ''"> and a.cust_no = #{custNo}</if>
|
||||||
|
<if test="salesmen != null and salesmen!='' "> and a.salesmen = #{salesmen}</if>
|
||||||
|
<if test="payee != null and payee!='' "> and a.payee = #{payee}</if>
|
||||||
|
<if test="settleType != null and settleType != ''"> and a.settle_type= #{settleType}</if>
|
||||||
|
<if test="billMonth != null and billMonth!='' "> and FIND_IN_SET(a.`bill_month`,#{billMonth})</if>
|
||||||
|
<if test="openBillStatus != null and openBillStatus != ''"> and a.open_bill_status = #{openBillStatus}</if>
|
||||||
|
<if test="paymentStatus != null and paymentStatus != ''"> and a.payment_status = #{paymentStatus}</if>
|
||||||
|
|
||||||
|
<if test="params.payCreateBy != null and params.payCreateBy != ''">
|
||||||
|
and b.create_by = #{params.payCreateBy}
|
||||||
|
</if>
|
||||||
|
<if test="params.beginTradeDate != null and params.beginTradeDate != ''">
|
||||||
|
and b.trade_date <![CDATA[ >= ]]> #{params.beginTradeDate}
|
||||||
|
</if>
|
||||||
|
<if test="params.endTradeDate != null and params.endTradeDate != ''">
|
||||||
|
and b.trade_date <![CDATA[ <= ]]> #{params.endTradeDate}
|
||||||
|
</if>
|
||||||
|
<if test="params.billCode != null and params.billCode != ''">
|
||||||
|
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})
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
|
||||||
|
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() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY a.settle_bill_no
|
||||||
|
) tbc ON tba.settle_bill_no = tbc.settle_bill_no
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user