<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) and bill_type not in (13,21,5))
(`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))
or
(`starttime` <= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7) and bill_type in (13,21,5))
(`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))
)
</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) 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 status not in (3,6,7,9) 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) and bill_type in (13,21,5))
(`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))
)
</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) and bill_type not in (13,21,5))
(`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))
or
(`starttime` <= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7) and bill_type in (13,21,5))
(`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))
)
</if>
<if test=" null != toPayMerchant">
@@ -105,9 +105,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) 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 status not in (3,6,7,9) 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) and bill_type in (13,21,5))
(`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))
)
</if>
<if test=" null != hasMerchant ">and `merchant_id` is not null</if>