`id`,`tenant_id`,`parent_tenant_id`,`shop_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`, `price_detail`,`need_pay`,`receive_pay`,`history_receive_pay`,`pay`,`pay_way`,`pay_date`,`set_off`,`use_money`,`starttime`,`endtime`,`status`,`energy_fees_id`, `return_pay`,`bill_remark`,`last_owe_call_time`,`last_owe_call_user`,`bussiness_manage_fee_need_pay`,`operating_manage_fee_need_pay`,`receive_date`,`period`, `is_preview`,`shop_info`,`rent_contract_id`,`rent_contract_agile_fees_type`,`property_contract_id`,`parent_bill_id`,`virtual_compose_id`,`parent_virtual_compose_id`, `energy_reading_calcuteId`,`energy_reading_id`,`extra_create_from`,`rent_area`,`can_edit`,`cus_name`,`fees_type` where `tenant_id` = #{tenantId} and `id` = #{id} and `parent_tenant_id` = #{parentTenantId} and `shop_id` = #{shopId} and `create_by` = #{createBy} and `create_by_name` like concat('%',#{createByName},'%') and `pay_way` = #{payWay} and `status` = #{status} and `fees_type` = #{feesType} and `energy_fees_id` = #{energyFeesId} and `rent_contract_id` = #{rentContractId} and `rent_contract_agile_fees_type` = #{rentContractAgileFeesType} and `property_contract_id` = #{propertyContractId} and `parent_bill_id` = #{parentBillId} and `virtual_compose_id` = #{virtualComposeId} and `parent_virtual_compose_id` = #{parentVirtualComposeId} and `is_preview` = #{isPreview} and `starttime` >= #{starttime} and `endtime` <= #{endtime} and `receive_date` <= #{receiveDate} and `starttime` = #{starttimeEqual} and `endtime` = #{endtimeEqual} and `extra_create_from` = #{extraCreateFrom} and `extra_create_from` is null and fees_type = 2 and IFNULL(`pay`,'0') -IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') > 0 and `can_edit` = #{canEdit} and date_format(starttime,'%Y-%m') <= #{month} and date_format(endtime,'%Y-%m') >= #{month} and (`receive_date` <= #{oweBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and fees_type = 1) and (`receive_date` > #{oweBillLastTime} and `receive_date` <= #{nearBillLastTime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and fees_type = 1) and (`receive_date` <= #{needPayStartDay} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and fees_type = 1) and ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and fees_type = 1) and ( ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') < 0 and fees_type = 1) or ( `pay` - IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') > 0 and fees_type = 2) ) and (`last_owe_call_time` is not null and `receive_pay` - `pay`- IFNULL(`set_off`,'0') > 0 ) and `parent_bill_id` is not null and `parent_bill_id` is null and `energy_reading_calcuteId` = #{energyReadingCalcuteId} and `energy_reading_id` = #{energyReadingId} and ( cus_name like concat('%',#{cusName},'%') or `shop_id` in #{cusShopidItem} ) and `shop_id` in #{shopidItem} and `energy_fees_id` in #{eidItem} and `rent_contract_id` in #{ridItem} and property_contract_id in #{pidItem} and `status` in #{stItem} and id not in #{nidItem} and id in #{idItem} order by ${sortColumns} limit #{limitStart},#{limitEnd} delete from wx_all_bill where rent_contract_id = #{id} delete from wx_all_bill where is_preview = 1 and rent_contract_id = #{rentContractId} and property_contract_id = #{propertyContractId} and rent_contract_agile_fees_type = #{rentContractAgileFeesType} and energy_fees_id = #{energyFeesId} 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 and IFNULL(`use_money`,'0') <= 0 and rent_contract_id = #{rentContractId} and property_contract_id = #{propertyContractId} delete from wx_all_bill where rent_contract_id = #{rentContractId} and IFNULL(`pay`,'0') <= 0 AND IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0 and IFNULL(`use_money`,'0') <= 0 and extra_create_from = #{extraCreateFrom} and `starttime` = #{starttimeEqual} delete from wx_all_bill where extra_create_from = #{extraCreateFrom} and IFNULL(`pay`,'0') <= 0 AND IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0 and IFNULL(`use_money`,'0') <= 0 and `starttime` = #{starttimeEqual} and rent_contract_id = #{rentContractId} and property_contract_id = #{propertyContractId} update wx_all_bill set is_preview = #{isPreview} where rent_contract_id = #{rentContractId} where property_contract_id = #{propertyContractId} INSERT INTO wx_all_bill ( ) VALUES ( #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.shopId},#{item.createtime}, #{item.createBy},#{item.createByName},#{item.updatetime},#{item.updateBy},#{item.updateByName},#{item.priceDetail}, #{item.needPay},#{item.receivePay},#{item.historyReceivePay},#{item.pay},#{item.billType},#{item.payWay},#{item.payDate},#{item.setOff},#{item.useMoney}, #{item.starttime},#{item.endtime},#{item.status},#{item.energyFeesId},#{item.returnPay},#{item.billRemark}, #{item.lastOweCallTime},#{item.lastOweCallUser},#{item.bussinessManageFeeNeedPay},#{item.operatingManageFeeNeedPay}, #{item.receiveDate},#{item.period},#{item.isPreview},#{item.shopInfo},#{item.rentContractId},#{item.rentContractAgileFeesType},#{item.propertyContractId}, #{item.parentBillId},#{item.virtualComposeId},#{item.parentVirtualComposeId},#{item.energyReadingCalcuteId}, #{item.energyReadingId},#{item.extraCreateFrom},#{item.rentArea},#{item.canEdit},#{item.cusName} ) delete from wx_all_bill where id = #{id} and tenant_id = #{tenantId} and ( ( pay <= 0 and IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0 and IFNULL(`use_money`,'0') <= 0) or ( IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0 and IFNULL(`use_money`,'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 and IFNULL(`use_money`,'0') <= 0 update wx_all_bill set cus_name = #{cusName} where cus_name is null and rent_contract_id = #{rentContractId} and property_contract_id = #{propertyContractId} update wx_all_bill set cus_name = #{cusName} where tenant_id = #{tenantId} and rent_contract_id = #{rentContractId} and property_contract_id = #{propertyContractId} and( ( IFNULL(`pay`,'0') <= 0 or ( starttime >= #{starttime} and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 ) or ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 ) ) or ( ( `receive_pay` - `pay` - IFNULL(`set_off`,'0') + IFNULL(`return_pay`,'0') < 0 ) or ( `pay` - IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') > 0 ) ) )