SELECT t1.*, t2.name as company_name, (select concat(frtd.year, '-', frtd.month) from biz_housing_fund_confirm_detail frtd where frtd.housing_fund_confirm_id = t1.id order by year desc, month desc limit 1) currentDate, t2.tax_type, t3.account_name as from_company_name FROM biz_housing_fund_confirm t1 left join biz_company t2 on t2.id = t1.company_id left join biz_tenant t3 on t3.id = t1.tenant_id t1.deleted = 0 AND t1.id = #{id} AND t1.company_id = #{companyId} AND t1.account_sets_id = #{accountSetsId} AND (t2.name like concat('%', #{keyword}, '%') or t2.code like concat('%', #{keyword}, '%')) AND t2.tax_type = #{taxType} AND (t3.account_name like concat('%', #{fromCompanyName}, '%')) AND t1.current_employee_id = #{currentEmployeeId} AND t1.employee_ids = #{employeeIds} AND t1.create_time = #{createTime} AND t1.creator_id = #{creatorId} AND t1.update_time = #{updateTime} AND t1.updater_id = #{updaterId} AND t1.deleted = #{deleted} AND t1.version = #{version} AND exists (select 1 from biz_entrust eb where eb.deleted = 0 and (eb.to_tenant_id = #{tenantId} or eb.from_tenant_id = #{tenantId}) and date_format(eb.current_month, '%Y%m') = concat(#{year}, #{month}) and eb.work_order_id = t1.work_order_id ) AND exists (select 1 from biz_housing_fund_confirm_detail fsd where fsd.biz_housing_fund_confirm_id = t1.id and fsd.month = #{month} and fsd.year = #{year} and fsd.status = #{status}) AND not exists (select 1 from biz_housing_fund_confirm_detail fsd where fsd.biz_housing_fund_confirm_id = t1.id and fsd.month = #{month} and fsd.year = #{year}) AND