`id`,`tenant_id`,`parent_tenant_id`,`settle_number`,`merchant_id`,`status`,`apply_status`, `receive_money`,`pay_money`,`settletime`,`createtime`,`updatetime`,`has_recorded` where 1=1 and tt.`id` = #{id} and tt.`tenant_id` = #{tenantId} and tt.`parent_tenant_id` = #{parentTenantId} and tt.merchantName like concat('%', #{merchantName},'%') and tt.createtime >= #{starttime} and tt.createtime <= #{endtime} and tt.`settle_number` = #{settleNumber} and tt.`status` = #{status} and tt.`apply_status` = #{applyStatus} and (tt.receiveMoney-tt.payMoney- (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = tt.id) ) >0 and (tt.receiveMoney-tt.payMoney- (select IFNULL(sum(settle_money),0) from wx_bill_settle_record where settle_id = tt.id) ) <0 order by ${sortColumns} update wx_bill_settle set has_recorded = 1 where id = #{id}