|
|
|
|
@ -205,10 +205,9 @@ class OtherController extends CommonController
|
|
|
|
|
->orderBy('sort', 'asc')
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
// 2. 查询对应的 CourseType
|
|
|
|
|
// 2. 查询对应的 CourseType(含 is_chart=1 的 is_history=0 与 is_history=1,与 courses-home 口径一致)
|
|
|
|
|
$allCourseTypes = CourseType::where('is_chart', 1)
|
|
|
|
|
->orderBy('sort', 'asc')
|
|
|
|
|
->where('is_history', 0)
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
// 3. 循环所有配置,对每个配置进行统计
|
|
|
|
|
@ -222,34 +221,34 @@ class OtherController extends CommonController
|
|
|
|
|
return clone $item;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 对每个 CourseType 进行统计
|
|
|
|
|
// 对每个 CourseType 进行统计(与 courses-home 口径一致)
|
|
|
|
|
foreach ($courseTypes as $courseType) {
|
|
|
|
|
// 历史课程数据(添加时间范围限制)
|
|
|
|
|
$historyCourse = HistoryCourse::whereHas('typeDetail', function ($query) use ($courseType) {
|
|
|
|
|
$query->where('name', 'like', '%' . $courseType->name . '%');
|
|
|
|
|
})->where(function ($query) use ($configStartDate, $configEndDate) {
|
|
|
|
|
$query->whereBetween('start_time', [$configStartDate, $configEndDate])
|
|
|
|
|
->orWhereBetween('end_time', [$configStartDate, $configEndDate]);
|
|
|
|
|
})->get();
|
|
|
|
|
// 实际课程数据(添加时间范围限制)
|
|
|
|
|
// 实际课程数据(与 courses-home 一致)
|
|
|
|
|
$courses = Course::where('type', $courseType->id)->where('is_chart', 1)
|
|
|
|
|
->where(function ($query) use ($configStartDate, $configEndDate) {
|
|
|
|
|
$query->whereBetween('start_date', [$configStartDate, $configEndDate])
|
|
|
|
|
->orWhereBetween('end_date', [$configStartDate, $configEndDate]);
|
|
|
|
|
})->get();
|
|
|
|
|
// 历史课程期数
|
|
|
|
|
|
|
|
|
|
// 历史课程:仅 is_history=1 类型统计,且与 courses-home 一致(type=id + calendar.is_count_people=1)
|
|
|
|
|
if (($courseType->is_history ?? 0) == 1) {
|
|
|
|
|
$historyCourse = HistoryCourse::where('type', $courseType->id)
|
|
|
|
|
->whereHas('calendar', function ($query) {
|
|
|
|
|
$query->where('is_count_people', 1);
|
|
|
|
|
})
|
|
|
|
|
->where(function ($query) use ($configStartDate, $configEndDate) {
|
|
|
|
|
$query->whereBetween('start_time', [$configStartDate, $configEndDate])
|
|
|
|
|
->orWhereBetween('end_time', [$configStartDate, $configEndDate]);
|
|
|
|
|
})->get();
|
|
|
|
|
} else {
|
|
|
|
|
$historyCourse = collect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$courseType->history_course_periods_total = $historyCourse->count();
|
|
|
|
|
// 现在课程期数(添加时间范围限制)
|
|
|
|
|
$courseType->now_course_periods_total = $courses->count();
|
|
|
|
|
|
|
|
|
|
// 历史课程培养人数去重
|
|
|
|
|
$courseType->history_course_signs_total = $historyCourse->sum('course_type_signs_pass_unique');
|
|
|
|
|
// 现在课程培养人数(使用配置的日期范围)
|
|
|
|
|
$courseType->now_course_signs_total = CourseSign::courseSignsTotalByUnique($configStartDate, $configEndDate, 1, $courses->pluck('id'), false, false);
|
|
|
|
|
|
|
|
|
|
// 已开设期数
|
|
|
|
|
$courseType->course_periods_total = $courseType->now_course_periods_total + $courseType->history_course_periods_total;
|
|
|
|
|
// 培养人数去重
|
|
|
|
|
$courseType->course_signs_total = $courseType->history_course_signs_total + $courseType->now_course_signs_total;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|