|
|
|
|
@ -169,6 +169,51 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 累计被投企业统计
|
|
|
|
|
* @param string|null $start_date 开始日期
|
|
|
|
|
* @param string|null $end_date 结束日期
|
|
|
|
|
* @param array|null $course_ids 课程ID(仅在自定义时间时生效)
|
|
|
|
|
* @param bool $retList 是否返回列表
|
|
|
|
|
*/
|
|
|
|
|
public static function yhInvestedTotal($start_date, $end_date = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
// 默认时间:获取所有学员,不限制课程
|
|
|
|
|
$userIds = self::getStudentList($start_date, $end_date, 1, null)->get()->pluck('user_id');
|
|
|
|
|
|
|
|
|
|
// 获取这些学员所在的被投企业
|
|
|
|
|
$companies = Company::whereHas('users', function ($query) use ($userIds) {
|
|
|
|
|
$query->whereIn('id', $userIds);
|
|
|
|
|
})->where('is_yh_invested', 1)->get();
|
|
|
|
|
// 自定义时间:需要按被投时间筛选
|
|
|
|
|
|
|
|
|
|
$startDate = substr($start_date, 0, 10);
|
|
|
|
|
$endDate = substr($end_date, 0, 10);
|
|
|
|
|
dd($startDate, $endDate);
|
|
|
|
|
// 筛选出被投时间在范围内的企业
|
|
|
|
|
$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 开始日期
|
|
|
|
|
@ -195,8 +240,8 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
})->where('is_yh_invested', 1)->get();
|
|
|
|
|
// 自定义时间:需要按被投时间筛选
|
|
|
|
|
if (!$isDefaultDate) {
|
|
|
|
|
// $startDate = substr($start_date, 0, 10);
|
|
|
|
|
// $endDate = substr($end_date, 0, 10);
|
|
|
|
|
// $startDate = substr($start_date, 0, 10);
|
|
|
|
|
// $endDate = substr($end_date, 0, 10);
|
|
|
|
|
dd($start_date, $end_date);
|
|
|
|
|
// 筛选出被投时间在范围内的企业
|
|
|
|
|
$filteredCompanies = [];
|
|
|
|
|
|