master
cody 1 week ago
parent 8332e8dbc8
commit 6bcb81eac0

@ -214,10 +214,10 @@ class CompanyController extends BaseController
if ($start_date && $end_date) {
// 累计被投企业数(从起始日期到结束日期)
$statistics['course_signs_invested'] = Company::yhInvestedTotal($end_date);
// 年份范围内被投企业数(在指定时间范围内报名的学员所在公司中,被投时间在年份范围内的公司数量)
$statistics['company_invested_year_total'] = Company::yhInvested($start_date, $end_date);
// 今年年份范围内被投企业数
$statistics['company_invested_year_total'] = Company::companyInvestedYear($start_date, $end_date);
// 入学后被投企业数量(在指定时间范围内报名的学员所在公司中,在入学后被投的公司数量)
$statistics['company_invested_after_enrollment_total'] = Company::companyInvestedYear($start_date, $end_date);
$statistics['company_invested_after_enrollment_total'] = CourseSign::companyInvestedAfterEnrollment($start_date, $end_date);
}
// 将统计数据添加到返回结果中

@ -106,41 +106,7 @@ class Company extends SoftDeletesModel
}
/**
* 被投企业统计
* @param string|null $start_date 开始日期
* @param string|null $end_date 结束日期
* @param array|null $course_ids 课程ID仅在自定义时间时生效
* @param bool $retList 是否返回列表
*/
public static function yhInvested($startDate = null, $endDate = null, $retList = false)
{
// 获取这些学员所在的被投企业
$companies = Company::where('is_yh_invested', 1)->get();
// 筛选出被投时间在范围内的企业
$filteredCompanies = [];
foreach ($companies as $company) {
$projectUsers = $company->project_users ?? [];
foreach ($projectUsers as $item) {
$investDate = $item['investDate'] ?? null;
// 检查被投时间是否在范围内
if ($investDate && $investDate >= $startDate && $investDate <= $endDate) {
$filteredCompanies[] = $company;
break; // 只要有一条满足就加入
}
}
}
$companies = collect($filteredCompanies);
// 返回结果
if ($retList) {
return $companies->values();
} else {
return $companies->count();
}
}
/**
* 被投企业统计(统计或列表)- 按年份范围统计
* 今年被投企业统计(统计或列表)- 按年份范围统计
* @param string|null $start_date 开始日期
* @param string|null $end_date 结束日期
* @param array|null $course_ids 课程ID数组不传则统计所有课程

Loading…
Cancel
Save