`id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`last_owe_call_time`, `expired_day`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`apply_status`,`apply_pay_img`,`apply_update_time`,`energy_fees_id`, `last_owe_call_user`,`rent_shop_type`,`return_price`,`pay_way`,service_charge_pay,contract_depoist_detail,`create_by`,`create_by_name`,`update_by`,`update_by_name` where 1 = 1 and `id` = #{id} and `tenant_id` = #{tenantId} and `parent_tenant_id` = #{parentTenantId} and `rent_contract_id` = #{rentContractId} and `energy_fees_id` = #{energyFeesId} and `receive_pay` = #{receivePay} and `pay` = #{pay} and `receive_date` = #{receiveDate} and `pay_date` = #{payDate} and `createtime` = #{createtime} and `expired_day` = #{expiredDay} and `status` = #{status} and `apply_status` = #{applyStatus} and `is_del` = #{isDel} and `need_pay` = #{needPay} and `merchant_id` = #{merchantId} and `user_id` = #{userId} and `shop_id` = #{shopId} and `updatetime` = #{updatetime} and `rent_shop_type` = #{rentShopType} and `pay_way` = #{payWay} and `contract_depoist_detail` like concat('%', #{contractDepoistDetail},'%') and `starttime` <= #{starttime} and `endtime` >= #{endtime} and date_format(starttime,'%Y-%m') <= #{month} and date_format(endtime,'%Y-%m') >= #{month} and (`starttime` <= #{oweBillLastTime} and `receive_pay` - `pay` > 0 and status not in (3,6,7)) and (`starttime` > #{oweBillLastTime} and `starttime` <= #{nearBillLastTime} and status not in (3,6,7)) and (`last_owe_call_time` is not null and `receive_pay` - `pay` > 0 and status not in (3,6,7) ) and `merchant_id` in #{midItem} and rent_contract_id in #{rdItem} and status in #{stItem} and id in #{idItem} order by ${sortColumns} 1 = 1 and br.`id` = #{id} and br.`merchant_id` = #{merchantId} and br.`tenant_id` = #{tenantId} and br.`parent_tenant_id` = #{parentTenantId} and br.`status` = #{status} and br.`apply_status` = #{applyStatus} and br.`is_del` = #{isDel} and br.`rent_shop_type` = #{rentShopType} and br.`rent_contract_id` = #{rentContractId} and br.`energy_fees_id` = #{energyFeesId} and br.`pay_way` = #{payWay} and br.`contract_depoist_detail` like concat('%', #{contractDepoistDetail},'%') and br.`starttime` <= #{starttime} and br.`endtime` >= #{endtime} and date_format(br.starttime,'%Y-%m') <= #{month} and date_format(br.endtime,'%Y-%m') >= #{month} and (br.`starttime` <= #{oweBillLastTime} and br.`receive_pay` - br.`pay` > 0 and br.status not in (3,6,7)) and (br.`starttime` > #{oweBillLastTime} and br.`starttime` <= #{nearBillLastTime} and br.status not in (3,6,7)) and (br.`starttime` <= #{needPayStartDay} and br.`receive_pay` - br.`pay` > 0 and br.status not in (3,6,7)) and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` > 0 and br.status not in (3,6,7) ) and br.`merchant_id` in #{midItem} and br.status in #{stItem} update wx_bill_rent_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) where status!=#{paid} and `tenant_id` = #{tenantId} and `parent_tenant_id` = #{parentTenantId} and status!=5 and DATEDIFF(now(),receive_date)>0 update wx_bill_rent_deposit set status=#{waitPay} where id in( select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_deposit br left join wx_rent_contract rc on br.rent_contract_id=rc.id where br.status!=#{paid} and br.`tenant_id` = #{tenantId} and br.`parent_tenant_id` = #{parentTenantId} and br.status!=5 and now() < br.receive_date and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a) delete from wx_bill_rent_deposit where id = #{id} and tenant_id = #{tenantId} INSERT INTO wx_bill_rent_deposit (id,rent_contract_id, receive_pay, pay, receive_date, pay_date, createtime, expired_day,tenant_id, parent_tenant_id,status,is_del,need_pay, merchant_id, user_id, shop_id, updatetime, starttime, endtime,rent_shop_type,return_price,shop_info,pay_way,freeze,service_charge_pay, contract_depoist_detail,create_by,create_by_name,update_by,update_by_name,energy_fees_id ) VALUES ( #{item.id},#{item.rentContractId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime}, #{item.expiredDay},#{item.tenantId},#{item.parentTenantId},#{item.status},#{item.isDel},#{item.needPay}, #{item.merchantId},#{item.userId},#{item.shopId},#{item.updatetime},#{item.starttime}, #{item.endtime},#{item.rentShopType},#{item.returnPrice},#{item.shopInfo},#{item.payWay},#{item.freeze},#{item.serviceChargePay}, #{item.contractDepoistDetail},#{item.createBy},#{item.createByName},#{item.updateBy},#{item.updateByName},#{item.energyFeesId} )