|
|
|
|
@ -134,8 +134,8 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
// 校友总数
|
|
|
|
|
$list['schoolmate_total'] = User::where('is_schoolmate', 1)->count();
|
|
|
|
|
// 今年新增校友数
|
|
|
|
|
$list['schoolmate_year'] = User::where('is_schoolmate', 1)->where('created_at', 'like', '%' . date('Y') . '%')->count();
|
|
|
|
|
// 今年新增校友数(根据schoolmate_time字段统计)
|
|
|
|
|
$list['schoolmate_year'] = User::where('is_schoolmate', 1)->whereYear('schoolmate_time', date('Y'))->count();
|
|
|
|
|
// 投后企业
|
|
|
|
|
$list['company_invested_total'] = CourseSign::yhInvestedTotal(CourseType::START_DATE, date('Y-m-d'), null);
|
|
|
|
|
// 元和员工参与人数
|
|
|
|
|
@ -165,17 +165,13 @@ class OtherController extends CommonController
|
|
|
|
|
->where('start_time', 'like', '%' . date('Y-m') . '%')
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
// 苏州区域数据
|
|
|
|
|
$suzhouArea = Company::approvedStudents()->where('company_city', '苏州市')->groupBy('company_area')
|
|
|
|
|
->whereNotNull('company_area')
|
|
|
|
|
->get(['company_area']);
|
|
|
|
|
// 苏州区域数据 - 使用 CourseSign::area 方法实现数据一致
|
|
|
|
|
$areasData = CourseSign::area($start_date, $end_date, null, null, true, true);
|
|
|
|
|
$suzhou = [];
|
|
|
|
|
foreach ($suzhouArea as $item) {
|
|
|
|
|
foreach ($areasData as $item) {
|
|
|
|
|
$suzhou[] = [
|
|
|
|
|
'area' => $item->company_area,
|
|
|
|
|
'total' => User::whereHas('company', function ($query) use ($item) {
|
|
|
|
|
$query->where('company_area', $item->company_area);
|
|
|
|
|
})->where('is_schoolmate', 1)->count()
|
|
|
|
|
'area' => $item['area'],
|
|
|
|
|
'total' => $item['total_unique'] ?? $item['total']
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -258,18 +254,28 @@ class OtherController extends CommonController
|
|
|
|
|
$courseType->course_signs_total = $courseType->history_course_signs_total + $courseType->now_course_signs_total;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 统计 is_chart=0 的课程类型数据,组成"其他"统计项
|
|
|
|
|
$otherCourseType = CourseType::getOtherStatistics($configStartDate, $configEndDate);
|
|
|
|
|
|
|
|
|
|
// 将"其他"添加到 courseTypes 集合中
|
|
|
|
|
$courseTypes->push($otherCourseType);
|
|
|
|
|
|
|
|
|
|
// 将统计数据直接组合到配置对象中
|
|
|
|
|
$config->courseTypes = $courseTypes;
|
|
|
|
|
// 总期数
|
|
|
|
|
// 总期数(包含"其他")
|
|
|
|
|
$config->course_periods_total = $courseTypes->sum('course_periods_total');
|
|
|
|
|
// 总去重人数
|
|
|
|
|
// 总去重人数(包含"其他")
|
|
|
|
|
$coursesAll = Course::whereIn('type', $allCourseTypes->pluck('id'))
|
|
|
|
|
->where('is_chart', 1)
|
|
|
|
|
->where(function ($query) use ($configStartDate, $configEndDate) {
|
|
|
|
|
$query->whereBetween('start_date', [$configStartDate, $configEndDate])
|
|
|
|
|
->orWhereBetween('end_date', [$configStartDate, $configEndDate]);
|
|
|
|
|
})->get();
|
|
|
|
|
$config->course_signs_unique_total = $courseTypes->sum('history_course_signs_total') + CourseSign::courseSignsTotalByUnique($configStartDate, $configEndDate, 1, $coursesAll->pluck('id'), false, false);
|
|
|
|
|
|
|
|
|
|
// 获取"其他"课程类型的课程ID列表
|
|
|
|
|
$otherCourseIds = CourseType::getOtherCourseIds($configStartDate, $configEndDate);
|
|
|
|
|
|
|
|
|
|
$config->course_signs_unique_total = $courseTypes->sum('history_course_signs_total') + CourseSign::courseSignsTotalByUnique($configStartDate, $configEndDate, 1, $coursesAll->pluck('id')->merge($otherCourseIds), false, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->success(compact('list', 'suzhou', 'country', 'monthCourses', 'time_axis', 'article', 'yearConfigs'));
|
|
|
|
|
@ -318,20 +324,25 @@ class OtherController extends CommonController
|
|
|
|
|
// 跟班学员数(在指定时间范围内报名的学员中,from为'跟班学员'的数量)
|
|
|
|
|
$list['ganbu_total'] = CourseSign::genban($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 今年上市公司数量(从stock_companys表获取,stock_date在今年)
|
|
|
|
|
$currentYear = date('Y');
|
|
|
|
|
$list['company_market_year_total'] = StockCompany::whereYear('stock_date', $currentYear)->count();
|
|
|
|
|
// 当前上市公司数量(从stock_companys表获取,stock_date在指定时间范围内)
|
|
|
|
|
$list['company_market_year_total'] = StockCompany::getByDateRange($start_date, $end_date);
|
|
|
|
|
|
|
|
|
|
// 入学后上市公司数量(从stock_companys表获取,is_after_enrollment = 1)
|
|
|
|
|
$list['company_market_after_enrollment_total'] = StockCompany::where('is_after_enrollment', 1)->count();
|
|
|
|
|
// 入学后上市公司数量(从stock_companys表获取,is_after_enrollment = 1,stock_date在指定时间范围内)
|
|
|
|
|
$list['company_market_after_enrollment_total'] = StockCompany::getAfterEnrollment($start_date, $end_date);
|
|
|
|
|
|
|
|
|
|
// 累计被投企业数
|
|
|
|
|
// 累计被投企业数,被投企业覆盖数
|
|
|
|
|
$list['course_signs_invested'] = CourseSign::yhInvestedTotal(CourseType::START_DATE, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 入学后被投企业数量(在指定时间范围内报名的学员所在公司中,在入学后被投的公司数量)
|
|
|
|
|
// 当前被投企业覆盖数(根据传入的开始结束时间统计)
|
|
|
|
|
$list['course_signs_invested_current'] = CourseSign::yhInvestedTotal($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 当前入学后被投企业数量(在指定时间范围内报名的学员所在公司中,在入学后被投的公司数量)
|
|
|
|
|
$list['company_invested_after_enrollment_total'] = CourseSign::companyInvestedAfterEnrollment($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 今年被投企业数
|
|
|
|
|
// 累计入学后被投企业数量(从CourseType::START_DATE开始的入学后被投企业数量)
|
|
|
|
|
$list['company_invested_after_enrollment_total_cumulative'] = CourseSign::companyInvestedAfterEnrollment(CourseType::START_DATE, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 当前被投企业数
|
|
|
|
|
$list['company_invested_year_total'] = CourseSign::companyInvestedYear($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 元和员工参与人数
|
|
|
|
|
@ -373,7 +384,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], false, false, false),
|
|
|
|
|
'company_join_total' => CourseSign::companyJoin($start_date, $end_date, [$course->id], false, false),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -410,10 +421,13 @@ class OtherController extends CommonController
|
|
|
|
|
// 区域明细统计
|
|
|
|
|
$areas = CourseSign::area($start_date, $end_date, 1, $courses->pluck('id'), true);
|
|
|
|
|
|
|
|
|
|
// 校友的区域明细统计
|
|
|
|
|
$areas_schoolmate = CourseSign::area($start_date, $end_date, 1, $courses->pluck('id'), true, true);
|
|
|
|
|
|
|
|
|
|
// 获取统计项元数据
|
|
|
|
|
$statistics_metadata = Course::getStatisticsMetadata();
|
|
|
|
|
|
|
|
|
|
return $this->success(compact('list', 'courseTypesSum', 'areas', 'statistics_metadata'));
|
|
|
|
|
return $this->success(compact('list', 'courseTypesSum', 'areas', 'areas_schoolmate', 'statistics_metadata'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -457,107 +471,119 @@ class OtherController extends CommonController
|
|
|
|
|
// 被投企业明细 - 使用与coursesHome相同的算法
|
|
|
|
|
// 确保 $course_ids 是数组格式
|
|
|
|
|
$courseIdsArray = $course_ids ? (is_array($course_ids) ? $course_ids : $course_ids->toArray()) : null;
|
|
|
|
|
$companies = CourseSign::yhInvestedTotal(CourseType::START_DATE, $end_date, $courseIdsArray, true);
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
// 获取该公司的学员信息
|
|
|
|
|
// 使用与yhInvestedTotal相同的筛选逻辑:status=1,筛选course_ids和日期范围
|
|
|
|
|
// 直接通过公司ID查询学员
|
|
|
|
|
$userIds = User::where('company_id', $company->id)->pluck('id')->toArray();
|
|
|
|
|
|
|
|
|
|
// 公司基本信息
|
|
|
|
|
$companyInfo = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'business_scope' => $company->business_scope ?? '',
|
|
|
|
|
'contact_phone' => $company->contact_phone ?? '',
|
|
|
|
|
'contact_mail' => $company->contact_mail ?? '',
|
|
|
|
|
'company_tag' => $company->company_tag ?? '',
|
|
|
|
|
// 'credit_code' => ($company->credit_code ? ' ' . $company->credit_code : ''),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (empty($userIds)) {
|
|
|
|
|
// 如果没有学员,仍然导出公司基本信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => '',
|
|
|
|
|
'course_names' => '',
|
|
|
|
|
'course_types' => '',
|
|
|
|
|
'course_count' => 0,
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
$userCourseSigns = CourseSign::getStudentList(CourseType::START_DATE, $end_date, 1, $courseIdsArray)
|
|
|
|
|
->whereIn('user_id', $userIds)
|
|
|
|
|
->with(['user', 'course.typeDetail'])
|
|
|
|
|
->get();
|
|
|
|
|
// 辅助函数:构建被投企业数据
|
|
|
|
|
$buildInvestedCompanyData = function ($start_date, $end_date, $courseIdsArray) {
|
|
|
|
|
$data = [];
|
|
|
|
|
$companies = CourseSign::yhInvestedTotal($start_date, $end_date, $courseIdsArray, true);
|
|
|
|
|
|
|
|
|
|
foreach ($companies as $company) {
|
|
|
|
|
// 获取该公司的学员信息
|
|
|
|
|
$userIds = User::where('company_id', $company->id)->pluck('id')->toArray();
|
|
|
|
|
|
|
|
|
|
// 公司基本信息
|
|
|
|
|
$companyInfo = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'business_scope' => $company->business_scope ?? '',
|
|
|
|
|
'contact_phone' => $company->contact_phone ?? '',
|
|
|
|
|
'contact_mail' => $company->contact_mail ?? '',
|
|
|
|
|
'company_tag' => $company->company_tag ?? '',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 按学员分组
|
|
|
|
|
$usersData = [];
|
|
|
|
|
foreach ($userCourseSigns as $sign) {
|
|
|
|
|
if (!$sign->user) {
|
|
|
|
|
continue;
|
|
|
|
|
if (empty($userIds)) {
|
|
|
|
|
// 如果没有学员,仍然导出公司基本信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => '',
|
|
|
|
|
'course_names' => '',
|
|
|
|
|
'course_types' => '',
|
|
|
|
|
'course_count' => 0,
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
$userCourseSigns = CourseSign::getStudentList($start_date, $end_date, 1, $courseIdsArray)
|
|
|
|
|
->whereIn('user_id', $userIds)
|
|
|
|
|
->with(['user', 'course.typeDetail'])
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
// 按学员分组
|
|
|
|
|
$usersData = [];
|
|
|
|
|
foreach ($userCourseSigns as $sign) {
|
|
|
|
|
if (!$sign->user) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$userId = $sign->user_id;
|
|
|
|
|
if (!isset($usersData[$userId])) {
|
|
|
|
|
$usersData[$userId] = [
|
|
|
|
|
'user' => $sign->user,
|
|
|
|
|
'courseSigns' => [],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$usersData[$userId]['courseSigns'][] = $sign;
|
|
|
|
|
}
|
|
|
|
|
$userId = $sign->user_id;
|
|
|
|
|
if (!isset($usersData[$userId])) {
|
|
|
|
|
$usersData[$userId] = [
|
|
|
|
|
'user' => $sign->user,
|
|
|
|
|
'courseSigns' => [],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 每个学员一行,公司信息只在第一行显示,后续行公司信息为空
|
|
|
|
|
$isFirstRow = true;
|
|
|
|
|
foreach ($usersData as $userData) {
|
|
|
|
|
$user = $userData['user'];
|
|
|
|
|
$courseSigns = collect($userData['courseSigns']);
|
|
|
|
|
|
|
|
|
|
if ($courseSigns->isNotEmpty()) {
|
|
|
|
|
// 获取课程名称列表,用中文顿号分隔
|
|
|
|
|
$courseNames = $courseSigns->pluck('course.name')->filter()->unique()->values()->implode('、');
|
|
|
|
|
|
|
|
|
|
// 获取课程体系列表,用中文顿号分隔
|
|
|
|
|
$courseTypes = $courseSigns->pluck('course.typeDetail.name')
|
|
|
|
|
->filter()
|
|
|
|
|
->unique()
|
|
|
|
|
->values()
|
|
|
|
|
->implode('、');
|
|
|
|
|
|
|
|
|
|
// 报名课程数
|
|
|
|
|
$courseCount = $courseSigns->count();
|
|
|
|
|
|
|
|
|
|
if ($isFirstRow) {
|
|
|
|
|
// 第一行:显示公司信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => $user->name ?? '',
|
|
|
|
|
'course_names' => $courseNames,
|
|
|
|
|
'course_types' => $courseTypes,
|
|
|
|
|
'course_count' => $courseCount,
|
|
|
|
|
]);
|
|
|
|
|
$isFirstRow = false;
|
|
|
|
|
} else {
|
|
|
|
|
// 后续行:公司信息为空
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => '',
|
|
|
|
|
'company_legal_representative' => '',
|
|
|
|
|
'company_date' => '',
|
|
|
|
|
'company_address' => '',
|
|
|
|
|
'business_scope' => '',
|
|
|
|
|
'contact_phone' => '',
|
|
|
|
|
'contact_mail' => '',
|
|
|
|
|
'company_tag' => '',
|
|
|
|
|
'credit_code' => '',
|
|
|
|
|
'user_name' => $user->name ?? '',
|
|
|
|
|
'course_names' => $courseNames,
|
|
|
|
|
'course_types' => $courseTypes,
|
|
|
|
|
'course_count' => $courseCount,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$usersData[$userId]['courseSigns'][] = $sign;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 每个学员一行,公司信息只在第一行显示,后续行公司信息为空
|
|
|
|
|
$isFirstRow = true;
|
|
|
|
|
foreach ($usersData as $userData) {
|
|
|
|
|
$user = $userData['user'];
|
|
|
|
|
$courseSigns = collect($userData['courseSigns']);
|
|
|
|
|
return $data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if ($courseSigns->isNotEmpty()) {
|
|
|
|
|
// 获取课程名称列表,用中文顿号分隔
|
|
|
|
|
$courseNames = $courseSigns->pluck('course.name')->filter()->unique()->values()->implode('、');
|
|
|
|
|
// 第一个 sheet:累计被投企业覆盖数(从 CourseType::START_DATE 开始)
|
|
|
|
|
$cumulativeData = $buildInvestedCompanyData(CourseType::START_DATE, $end_date, $courseIdsArray);
|
|
|
|
|
|
|
|
|
|
// 获取课程体系列表,用中文顿号分隔
|
|
|
|
|
$courseTypes = $courseSigns->pluck('course.typeDetail.name')
|
|
|
|
|
->filter()
|
|
|
|
|
->unique()
|
|
|
|
|
->values()
|
|
|
|
|
->implode('、');
|
|
|
|
|
// 第二个 sheet:当前被投企业覆盖数(从传入的开始日期开始)
|
|
|
|
|
$currentData = $buildInvestedCompanyData($start_date, $end_date, $courseIdsArray);
|
|
|
|
|
|
|
|
|
|
// 报名课程数
|
|
|
|
|
$courseCount = $courseSigns->count();
|
|
|
|
|
|
|
|
|
|
if ($isFirstRow) {
|
|
|
|
|
// 第一行:显示公司信息
|
|
|
|
|
$data[] = array_merge($companyInfo, [
|
|
|
|
|
'user_name' => $user->name ?? '',
|
|
|
|
|
'course_names' => $courseNames,
|
|
|
|
|
'course_types' => $courseTypes,
|
|
|
|
|
'course_count' => $courseCount,
|
|
|
|
|
]);
|
|
|
|
|
$isFirstRow = false;
|
|
|
|
|
} else {
|
|
|
|
|
// 后续行:公司信息为空
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => '',
|
|
|
|
|
'company_legal_representative' => '',
|
|
|
|
|
'company_date' => '',
|
|
|
|
|
'company_address' => '',
|
|
|
|
|
'business_scope' => '',
|
|
|
|
|
'contact_phone' => '',
|
|
|
|
|
'contact_mail' => '',
|
|
|
|
|
'company_tag' => '',
|
|
|
|
|
'credit_code' => '',
|
|
|
|
|
'user_name' => $user->name ?? '',
|
|
|
|
|
'course_names' => $courseNames,
|
|
|
|
|
'course_types' => $courseTypes,
|
|
|
|
|
'course_count' => $courseCount,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_legal_representative' => '法人',
|
|
|
|
|
@ -567,13 +593,25 @@ class OtherController extends CommonController
|
|
|
|
|
'contact_phone' => '联系电话',
|
|
|
|
|
'contact_mail' => '联系邮箱',
|
|
|
|
|
'company_tag' => '企业资质',
|
|
|
|
|
// 'credit_code' => '统一社会信用代码',
|
|
|
|
|
'user_name' => '学员姓名',
|
|
|
|
|
'course_names' => '课程名称',
|
|
|
|
|
'course_types' => '课程体系',
|
|
|
|
|
'course_count' => '报名课程数',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 创建多 sheet 导出
|
|
|
|
|
$sheets = [
|
|
|
|
|
new SheetExport($cumulativeData, $fields, '被投企业覆盖数'),
|
|
|
|
|
new SheetExport($currentData, $fields, '当前被投企业覆盖数'),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$filename = '被投企业明细';
|
|
|
|
|
|
|
|
|
|
// 直接返回多 sheet 导出
|
|
|
|
|
return Excel::download(
|
|
|
|
|
new MultiSheetExport($sheets),
|
|
|
|
|
$filename . '_' . date('YmdHis') . '.xlsx'
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'course_signs_total':
|
|
|
|
|
@ -668,7 +706,7 @@ class OtherController extends CommonController
|
|
|
|
|
'course_name' => '课程名称',
|
|
|
|
|
'start_time' => '开始时间',
|
|
|
|
|
'end_time' => '结束时间',
|
|
|
|
|
'course_type_signs_pass' => '培养人数未去重',
|
|
|
|
|
'course_type_signs_pass' => '培养人次未去重',
|
|
|
|
|
'course_type_signs_pass_unique' => '培养人数去重',
|
|
|
|
|
'course_signs_pass' => '课程培养人数',
|
|
|
|
|
];
|
|
|
|
|
@ -806,7 +844,7 @@ class OtherController extends CommonController
|
|
|
|
|
'course_name' => '课程名称',
|
|
|
|
|
'start_time' => '开始时间',
|
|
|
|
|
'end_time' => '结束时间',
|
|
|
|
|
'course_type_signs_pass' => '培养人数未去重',
|
|
|
|
|
'course_type_signs_pass' => '培养人次未去重',
|
|
|
|
|
'course_type_signs_pass_unique' => '培养人数去重',
|
|
|
|
|
'course_signs_pass' => '课程培养人数',
|
|
|
|
|
];
|
|
|
|
|
@ -838,7 +876,7 @@ class OtherController extends CommonController
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
}
|
|
|
|
|
})->orderBy('start_date', 'asc')->get();
|
|
|
|
|
})->where('is_chart', 1)->orderBy('start_date', 'asc')->get();
|
|
|
|
|
foreach ($courses2 as $course) {
|
|
|
|
|
$data[] = [
|
|
|
|
|
'course_type' => $courseType->name,
|
|
|
|
|
@ -1101,8 +1139,7 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
case 'company_market_year_total':
|
|
|
|
|
// 今年上市公司明细 - 从stock_companys表获取,与coursesHome统计逻辑保持一致
|
|
|
|
|
$currentYear = date('Y');
|
|
|
|
|
$stockCompanies = StockCompany::with('company')->whereYear('stock_date', $currentYear)->get();
|
|
|
|
|
$stockCompanies = StockCompany::getByDateRange($start_date, $end_date, true)->load('company');
|
|
|
|
|
|
|
|
|
|
foreach ($stockCompanies as $stockCompany) {
|
|
|
|
|
// 通过company_id关联到Company表获取详细信息
|
|
|
|
|
@ -1222,7 +1259,7 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
case 'company_market_after_enrollment_total':
|
|
|
|
|
// 入学后上市公司明细 - 从stock_companys表获取,与coursesHome统计逻辑保持一致
|
|
|
|
|
$stockCompanies = StockCompany::with('company')->where('is_after_enrollment', 1)->get();
|
|
|
|
|
$stockCompanies = StockCompany::getAfterEnrollment($start_date, $end_date, true)->load('company');
|
|
|
|
|
|
|
|
|
|
foreach ($stockCompanies as $stockCompany) {
|
|
|
|
|
// 通过company_id关联到Company表获取详细信息
|
|
|
|
|
@ -1345,23 +1382,36 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
case 'company_invested_after_enrollment_total':
|
|
|
|
|
// 入学后被投企业明细 - 使用模型方法
|
|
|
|
|
$companiesAfterEnrollment = CourseSign::companyInvestedAfterEnrollment($start_date, $end_date, $course_ids, true);
|
|
|
|
|
// 辅助函数:构建入学后被投企业数据
|
|
|
|
|
$buildAfterEnrollmentData = function ($start_date, $end_date, $course_ids) {
|
|
|
|
|
$data = [];
|
|
|
|
|
$companiesAfterEnrollment = CourseSign::companyInvestedAfterEnrollment($start_date, $end_date, $course_ids, true);
|
|
|
|
|
|
|
|
|
|
foreach ($companiesAfterEnrollment as $item) {
|
|
|
|
|
$company = $item['company'];
|
|
|
|
|
$userNames = collect($item['users'])->pluck('name')->filter()->unique()->implode("\n\r");
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
'invest_date' => $item['invest_date'] ?? '',
|
|
|
|
|
'first_sign_date' => $item['first_enrollment_date'] ?? '',
|
|
|
|
|
'user_names' => $userNames,
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'company_city' => $company->company_city ?? '',
|
|
|
|
|
'company_area' => $company->company_area ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 第一个 sheet:当前入学后被投企业(从传入的开始日期开始)
|
|
|
|
|
$currentData = $buildAfterEnrollmentData($start_date, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
// 第二个 sheet:累计入学后被投企业(从 CourseType::START_DATE 开始)
|
|
|
|
|
$cumulativeData = $buildAfterEnrollmentData(CourseType::START_DATE, $end_date, $course_ids);
|
|
|
|
|
|
|
|
|
|
foreach ($companiesAfterEnrollment as $item) {
|
|
|
|
|
$company = $item['company'];
|
|
|
|
|
$userNames = collect($item['users'])->pluck('name')->filter()->unique()->implode("\n\r");
|
|
|
|
|
$data[] = [
|
|
|
|
|
'company_name' => $company->company_name,
|
|
|
|
|
'company_legal_representative' => $company->company_legal_representative ?? '',
|
|
|
|
|
'company_date' => $company->company_date ?? '',
|
|
|
|
|
'invest_date' => $item['invest_date'] ?? '',
|
|
|
|
|
'first_sign_date' => $item['first_enrollment_date'] ?? '',
|
|
|
|
|
'user_names' => $userNames,
|
|
|
|
|
'company_address' => $company->company_address ?? '',
|
|
|
|
|
'company_city' => $company->company_city ?? '',
|
|
|
|
|
'company_area' => $company->company_area ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$fields = [
|
|
|
|
|
'company_name' => '企业名称',
|
|
|
|
|
'company_legal_representative' => '法人',
|
|
|
|
|
@ -1373,7 +1423,20 @@ class OtherController extends CommonController
|
|
|
|
|
'company_city' => '所在城市',
|
|
|
|
|
'company_area' => '所在区域',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 创建多 sheet 导出
|
|
|
|
|
$sheets = [
|
|
|
|
|
new SheetExport($currentData, $fields, '当前入学后被投企业'),
|
|
|
|
|
new SheetExport($cumulativeData, $fields, '累计入学后被投企业'),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$filename = '入学后被投企业明细';
|
|
|
|
|
|
|
|
|
|
// 直接返回多 sheet 导出
|
|
|
|
|
return Excel::download(
|
|
|
|
|
new MultiSheetExport($sheets),
|
|
|
|
|
$filename . '_' . date('YmdHis') . '.xlsx'
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'company_invested_year_total':
|
|
|
|
|
|