<if test=" null == nearBillLastTime and null != oweBillLastTime">
and (
(`starttime` <= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and status not in (3,6,7,9) and bill_type not in (13,21,5))
(`starttime` <= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and bill_type not in (13,21,5))
or
(`starttime` <= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7,9) and bill_type in (13,21,5))
(`starttime` <= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and bill_type in (13,21,5))
)
</if>
<if test=" null != nearBillLastTime and null != oweBillLastTime">
and (
(`starttime` > #{oweBillLastTime} and `starttime` <= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and status not in (3,6,7,9) and bill_type not in (13,21,5))
(`starttime` > #{oweBillLastTime} and `starttime` <= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and bill_type not in (13,21,5))
or
(`starttime` > #{oweBillLastTime} and `starttime` <= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7,9) and bill_type in (13,21,5))
(`starttime` > #{oweBillLastTime} and `starttime` <= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and bill_type in (13,21,5))
)
</if>
<if test=" null != needPayStartDay">
and (
(`starttime` <= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and status not in (3,6,7,9) and bill_type not in (13,21,5))
(`starttime` <= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and bill_type not in (13,21,5))
or
(`starttime` <= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7,9) and bill_type in (13,21,5))
(`starttime` <= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and bill_type in (13,21,5))
)
</if>
<if test=" null != needPayNoDays">
and (
( `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and status not in (3,6,7) and bill_type not in (13,21,5))
( `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and bill_type not in (13,21,5))
or
( `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7,9) and bill_type in (13,21,5))
( `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and bill_type in (13,21,5))
)
</if>
<if test=" null != toPayMerchant">
@@ -116,9 +116,9 @@
</if>
<if test=" 1 == notifyed ">
and (
(`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and status not in (3,6,7,9) and bill_type not in (13,21,5))
(`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') > 0 and bill_type not in (13,21,5))
or
(`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') > 0 and status not in (3,6,7,9) and bill_type in (13,21,5))
(`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') > 0 and bill_type in (13,21,5))
)
</if>
<if test=" null != hasMerchant ">and `merchant_id` is not null</if>
and starttime >= #{shopEndtime} and IFNULL(`pay`,'0') <= 0 AND IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0
delete from wx_all_bill where starttime >= #{shopEndtime} and IFNULL(`pay`,'0') <= 0 AND IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0
<if test=" null != rentContractId">
and rent_contract_id = #{rentContractId}
</if>
@@ -354,14 +353,8 @@
</delete>
<delete id = "deleteEnergyReadingBills" parameterType="HashMap">
delete from wx_all_bill where energy_reading_calcuteId = #{energyReadingCalcuteId} and tenant_id = #{tenantId} and status = 2 and pay <= 0 and IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0
delete from wx_all_bill where energy_reading_calcuteId = #{energyReadingCalcuteId} and tenant_id = #{tenantId} and pay <= 0 and IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0