From 8f6b15e66b1bf478d03866ee7b6fa38e8f6a9ec5 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 4 Dec 2025 14:25:55 +0800 Subject: [PATCH] update --- app/Console/Commands/UpdateUserNo.php | 2 +- .../Controllers/Admin/OtherController.php | 8 +++---- app/Models/CourseSign.php | 22 ++++++++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/Console/Commands/UpdateUserNo.php b/app/Console/Commands/UpdateUserNo.php index 4e56e31..4984525 100755 --- a/app/Console/Commands/UpdateUserNo.php +++ b/app/Console/Commands/UpdateUserNo.php @@ -104,7 +104,7 @@ class UpdateUserNo extends Command $tag = '元禾同事'; // 获取元和员工用户列表 - $users = CourseSign::companyJoin(null, null, null, true); + $users = CourseSign::companyJoin(null, null, null, true, false); $count = 0; foreach ($users as $user) { diff --git a/app/Http/Controllers/Admin/OtherController.php b/app/Http/Controllers/Admin/OtherController.php index 0120636..d105485 100755 --- a/app/Http/Controllers/Admin/OtherController.php +++ b/app/Http/Controllers/Admin/OtherController.php @@ -290,7 +290,7 @@ class OtherController extends CommonController $list['company_invested_year_total'] = CourseSign::companyInvestedYear($start_date, $end_date, $course_ids); // 元和员工参与人数 - // $list['company_join_total'] = CourseSign::companyJoin($start_date, $end_date, $course_ids); + // $list['company_join_total'] = CourseSign::companyJoin($start_date, $end_date, $course_ids); // 全市干部参与企业 $list['company_ganbu_total'] = CourseSign::ganbu($start_date, $end_date, $course_ids); // 苏州头部企业 @@ -328,7 +328,7 @@ class OtherController extends CommonController // 被投企业数 'yh_invested_total' => CourseSign::yhInvested($start_date, $end_date, [$course->id]), // 元禾同事数 - 'company_join_total' => CourseSign::companyJoin($start_date, $end_date, [$course->id]), + 'company_join_total' => CourseSign::companyJoin($start_date, $end_date, [$course->id], false, false, false), ]; } } @@ -557,7 +557,7 @@ class OtherController extends CommonController 'course_signs_pass' => CourseSign::courseSignsTotal($start_date, $end_date, 1, [$course->id], false, false), 'genban_total' => CourseSign::genban($start_date, $end_date, [$course->id]), 'yh_invested_total' => CourseSign::yhInvested($start_date, $end_date, [$course->id]), - 'company_join_total' => CourseSign::companyJoin($start_date, $end_date, [$course->id]), + 'company_join_total' => CourseSign::companyJoin($start_date, $end_date, [$course->id], false, false), ]; } } @@ -1045,7 +1045,7 @@ class OtherController extends CommonController case 'company_join_total': // 元和员工参与人员明细 - 使用模型方法(现在返回的是用户列表) - $users = CourseSign::companyJoin($start_date, $end_date, $course_ids, true); + $users = CourseSign::companyJoin($start_date, $end_date, $course_ids, true, false); // 加载关联关系 $users->load('company'); foreach ($users as $user) { diff --git a/app/Models/CourseSign.php b/app/Models/CourseSign.php index 32bdaa6..6db8b29 100755 --- a/app/Models/CourseSign.php +++ b/app/Models/CourseSign.php @@ -584,7 +584,7 @@ class CourseSign extends SoftDeletesModel /** * 元和员工参人员 */ - public static function companyJoin($start_date = null, $end_date = null, $course_ids = null, $retList = false) + public static function companyJoin($start_date = null, $end_date = null, $course_ids = null, $retList = false, $needHistory = true) { $courseSignsQuery = self::getStudentList($start_date, $end_date, null, $course_ids); $courseSignByType = $courseSignsQuery->get(); @@ -607,7 +607,6 @@ class CourseSign extends SoftDeletesModel '常州团队', '国器元禾' ]; - // dd($courseSignByType->pluck('user_id')); $list = User::whereIn('id', $courseSignByType->pluck('user_id')) ->where(function ($query) use ($companyNameKeyword) { foreach ($companyNameKeyword as $item) { @@ -621,14 +620,17 @@ class CourseSign extends SoftDeletesModel } else { // 基础数据 $baseCount = $list->count(); - // 额外数据 - $employeeParticipations = EmployeeParticipation::where(function ($query) use ($start_date, $end_date) { - // 开始结束日期的筛选。or查询 - if ($start_date && $end_date) { - $query->whereBetween('start_date', [$start_date, $end_date]) - ->orWhereBetween('end_date', [$start_date, $end_date]); - } - })->where('type', 1)->sum('total'); + $employeeParticipations = 0; + if ($needHistory) { + // 额外数据 + $employeeParticipations = EmployeeParticipation::where(function ($query) use ($start_date, $end_date) { + // 开始结束日期的筛选。or查询 + if ($start_date && $end_date) { + $query->whereBetween('start_date', [$start_date, $end_date]) + ->orWhereBetween('end_date', [$start_date, $end_date]); + } + })->where('type', 1)->sum('total'); + } // 返回统计数据 return $baseCount + $employeeParticipations; }