diff --git a/app/Http/Controllers/Admin/CompanyController.php b/app/Http/Controllers/Admin/CompanyController.php index fcd0fed..684e1bc 100644 --- a/app/Http/Controllers/Admin/CompanyController.php +++ b/app/Http/Controllers/Admin/CompanyController.php @@ -125,7 +125,7 @@ class CompanyController extends BaseController if ($start_year && $end_year) { // 使用 LIKE 匹配 JSON 字符串中的年份范围 $query->where(function ($q) use ($start_year, $end_year) { - for ($year = (int)$start_year; $year <= (int)$end_year; $year++) { + for ($year = (int) $start_year; $year <= (int) $end_year; $year++) { $q->orWhere('project_users', 'like', '%' . $year . '%'); } }); @@ -208,16 +208,35 @@ class CompanyController extends BaseController 'course_signs_invested' => 0, 'company_invested_after_enrollment_total' => 0, 'company_invested_year_total' => 0, + 'course_signs_invested_companies' => [], + 'company_invested_after_enrollment_companies' => [], + 'company_invested_year_companies' => [], ]; $start_date = $start_year ? $start_year . '-01-01' : date('Y-01-01'); $end_date = $end_year ? $end_year . '-12-31' : date('Y-m-d'); if ($start_date && $end_date) { // 累计被投企业数(从起始日期到结束日期) - $statistics['course_signs_invested'] = Company::yhInvestedTotal($end_date); + $investedCompanies = Company::yhInvestedTotal($end_date, true); + if ($investedCompanies) { + $investedCompaniesCollection = collect($investedCompanies); + $statistics['course_signs_invested'] = $investedCompaniesCollection->count(); + $statistics['course_signs_invested_companies'] = $investedCompaniesCollection->pluck('company_name')->filter()->unique()->values()->toArray(); + } + // 今年年份范围内被投企业数 - $statistics['company_invested_year_total'] = Company::companyInvestedYear($start_date, $end_date); + $yearInvestedCompanies = Company::companyInvestedYear($start_date, $end_date, true); + if ($yearInvestedCompanies) { + $yearInvestedCompaniesCollection = collect($yearInvestedCompanies); + $statistics['company_invested_year_total'] = $yearInvestedCompaniesCollection->count(); + $statistics['company_invested_year_companies'] = $yearInvestedCompaniesCollection->pluck('company_name')->filter()->unique()->values()->toArray(); + } + // 入学后被投企业数量(在指定时间范围内报名的学员所在公司中,在入学后被投的公司数量) - $statistics['company_invested_after_enrollment_total'] = CourseSign::companyInvestedAfterEnrollment($start_date, $end_date); + $afterEnrollmentCompanies = CourseSign::companyInvestedAfterEnrollment($start_date, $end_date, null, true); + if ($afterEnrollmentCompanies) { + $statistics['company_invested_after_enrollment_total'] = count($afterEnrollmentCompanies); + $statistics['company_invested_after_enrollment_companies'] = collect($afterEnrollmentCompanies)->pluck('company.company_name')->filter()->unique()->values()->toArray(); + } } // 将统计数据添加到返回结果中