|
|
|
@ -410,7 +410,7 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
'常州团队',
|
|
|
|
'常州团队',
|
|
|
|
'国企元禾'
|
|
|
|
'国企元禾'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
// $company = Company::where(function ($query) use ($companyNameKeyword) {
|
|
|
|
// $company = Company::where(function ($query) use ($companyNameKeyword) {
|
|
|
|
// foreach ($companyNameKeyword as $item) {
|
|
|
|
// foreach ($companyNameKeyword as $item) {
|
|
|
|
// $query->orWhere('company_name', 'like', '%' . $item . '%');
|
|
|
|
// $query->orWhere('company_name', 'like', '%' . $item . '%');
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
@ -495,20 +495,64 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 上市公司
|
|
|
|
* 上市公司(统计或列表)
|
|
|
|
|
|
|
|
* @param string|null $start_date 开始日期
|
|
|
|
|
|
|
|
* @param string|null $end_date 结束日期
|
|
|
|
|
|
|
|
* @param array|null $course_ids 课程ID数组,不传则统计所有课程
|
|
|
|
|
|
|
|
* @param bool $retList 是否返回列表,false返回数量,true返回列表(包含学员、课程信息)
|
|
|
|
|
|
|
|
* @return int|array
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static function shangshi($start_date = null, $end_date = null, $course_ids = null, $retList = false)
|
|
|
|
public static function shangshi($start_date = null, $end_date = null, $course_ids = null, $retList = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignsQuery) {
|
|
|
|
$courseSigns = $courseSignsQuery->with(['user.company', 'course.typeDetail'])->get();
|
|
|
|
$query->whereIn('id', $courseSignsQuery->get()->pluck('user_id'));
|
|
|
|
|
|
|
|
})->where('company_market', 1)->get();
|
|
|
|
// 获取所有上市公司的ID
|
|
|
|
|
|
|
|
$companyIds = $courseSigns->pluck('user.company.id')
|
|
|
|
|
|
|
|
->filter()
|
|
|
|
|
|
|
|
->unique()
|
|
|
|
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取这些公司中标记为上市的公司
|
|
|
|
|
|
|
|
$companies = Company::whereIn('id', $companyIds)
|
|
|
|
|
|
|
|
->where('company_market', 1)
|
|
|
|
|
|
|
|
->get()
|
|
|
|
|
|
|
|
->keyBy('id');
|
|
|
|
|
|
|
|
|
|
|
|
if ($retList) {
|
|
|
|
if ($retList) {
|
|
|
|
return $list;
|
|
|
|
// 返回详细列表,包含学员、课程信息
|
|
|
|
} else {
|
|
|
|
$result = [];
|
|
|
|
return $list->count();
|
|
|
|
foreach ($courseSigns as $courseSign) {
|
|
|
|
|
|
|
|
if (!$courseSign->user || !$courseSign->user->company) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$companyId = $courseSign->user->company->id;
|
|
|
|
|
|
|
|
// 只处理上市公司的记录
|
|
|
|
|
|
|
|
if (!isset($companies[$companyId])) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$company = $companies[$companyId];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果公司还没有在结果中,初始化
|
|
|
|
|
|
|
|
if (!isset($result[$companyId])) {
|
|
|
|
|
|
|
|
$result[$companyId] = [
|
|
|
|
|
|
|
|
'company' => $company,
|
|
|
|
|
|
|
|
'courseSigns' => [],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加学员报名记录(包含学员、课程信息)
|
|
|
|
|
|
|
|
$result[$companyId]['courseSigns'][] = $courseSign;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 转换为数组并返回
|
|
|
|
|
|
|
|
return array_values($result);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 返回统计数据
|
|
|
|
|
|
|
|
return $companies->count();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|