`id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`apply_status`,`apply_pay_img`,`apply_update_time`, `tenant_id`,`parent_tenant_id`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`type`,`last_owe_call_time`, `rent_shop_type`,`pay_way`,`price_detail`,`starttime`,`endtime`,freeze,build_way,service_charge_pay,`remark`,`last_owe_call_user`, `create_by`,`create_by_name`,`update_by`,`update_by_name`,`energy_reading_calcuteId`,`energy_reading_id`,`energy_fees_id`,`set_off` where 1 = 1 and `id` = #{id} and `receive_pay` = #{receivePay} and `pay` = #{pay} and `receive_date` = #{receiveDate} and `pay_date` = #{payDate} and `createtime` = #{createtime} and `expired_day` = #{expiredDay} and `tenant_id` = #{tenantId} and `parent_tenant_id` = #{parentTenantId} and `status` = #{status} and `apply_status` = #{applyStatus} and `is_del` = #{isDel} and `merchant_id` = #{merchantId} and `energy_fees_id` = #{energyFeesId} and `user_id` = #{userId} and `updatetime` = #{updatetime} and `type` = #{type} and `rent_shop_type` = #{rentShopType} and `pay_way` = #{payWay} and `build_way` = #{buildWay} and `energy_reading_calcuteId` = #{energyReadingCalcuteId} and `energy_reading_id` = #{energyReadingId} and (`last_owe_call_time` is not null and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7) ) and status in #{stItem} and id in #{idItem} and id not in #{nidItem} order by ${sortColumns} 1 = 1 and br.`id` = #{id} and br.`tenant_id` = #{tenantId} and br.`parent_tenant_id` = #{parentTenantId} and br.`freeze` = #{freeze} and br.`id` = #{id} and br.`merchant_id` = #{merchantId} and br.`energy_fees_id` = #{energyFeesId} and br.`status` = #{status} and br.`apply_status` = #{applyStatus} and br.`is_del` = #{isDel} and br.`type` = #{type} and br.`rent_shop_type` = #{rentShopType} and br.`pay_way` = #{payWay} 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` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7)) and (br.`starttime` > #{oweBillLastTime} and br.`starttime` <= #{nearBillLastTime} and br.`receive_pay` - br.`pay` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7)) and (br.`starttime` <= #{needPayStartDay} and br.`receive_pay` - br.`pay` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7)) and br.`build_way` = #{buildWay} and br.`energy_reading_calcuteId` = #{energyReadingCalcuteId} and br.`energy_reading_id` = #{energyReadingId} and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7) ) and br.`merchant_id` in #{midItem} and br.`id` not in #{nidItem} and br.status in #{stItem} update wx_bill_daily set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) where status!=#{paid} and `tenant_id` = #{tenantId} and `parent_tenant_id` = #{parentTenantId} and DATEDIFF(now(),receive_date)>0 update wx_bill_daily set status=#{waitPay} where status!=#{paid} and `tenant_id` = #{tenantId} and `parent_tenant_id` = #{parentTenantId} and DATEDIFF(now(),receive_date) <=0 delete from wx_bill_daily where id = #{id} and tenant_id = #{tenantId} INSERT INTO wx_bill_daily (`id`,`tenant_id`,`parent_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`status`,`is_del`, `merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`type`,`rent_shop_type`,`apply_status`,`pay_way`,`price_detail`, `starttime`,`endtime`,`freeze`,`build_way`,`service_charge_pay`,`apply_pay_img`,`apply_update_time`,`remark`,`create_by`,`update_by`, `create_by_name`,`update_by_name`,`energy_reading_calcuteId`,`energy_reading_id`,`energy_fees_id`) VALUES ( #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime},#{item.expiredDay},#{item.status},#{item.isDel}, #{item.merchantId},#{item.userId},#{item.shopId},#{item.shopName},#{item.updatetime},#{item.type},#{item.rentShopType},#{item.applyStatus},#{item.payWay},#{item.priceDetail}, #{item.starttime},#{item.endtime},#{item.freeze},#{item.buildWay},#{item.serviceChargePay},#{item.applyPayImg},#{item.applyUpdateTime},#{item.remark},#{item.createBy},#{item.updateBy}, #{item.createByName},#{item.updateByName},#{item.energyReadingCalcuteId},#{item.energyReadingId},#{item.energyFeesId} ) delete from wx_bill_daily where energy_reading_calcuteId = #{energyReadingCalcuteId} and tenant_id = #{tenantId} and status = 2 and pay <= 0 and IFNULL(`set_off`,'0') <= 0 delete from wx_bill_daily where merchant_id = #{merchantId} and status = 2 and starttime > #{shopEndtime} and IFNULL(`pay`,'0') <= 0 AND IFNULL(`set_off`,'0') <= 0