|
|
|
|
@ -292,8 +292,10 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
// 3. 总计 = 现在课程去重人数 + 历史课程去重人数
|
|
|
|
|
$config->course_signs_unique_total = $nowCourseSignsUniqueTotal + $historyCourseSignsUniqueTotal;
|
|
|
|
|
// 去重总计
|
|
|
|
|
$config->course_signs_unique_total = Course::where('type', $courseType->id)
|
|
|
|
|
|
|
|
|
|
// 计算总期数统计
|
|
|
|
|
// 1. 现在课程的总期数(所有课程类型,在配置的日期范围内)
|
|
|
|
|
$nowCoursePeriodsTotal = Course::whereIn('type', $allCourseTypes->pluck('id'))
|
|
|
|
|
->where('is_chart', 1)
|
|
|
|
|
->where(function ($query) use ($configStartDate, $configEndDate) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
@ -301,7 +303,29 @@ class OtherController extends CommonController
|
|
|
|
|
$query->whereBetween('start_date', [$configStartDate, $configEndDate])
|
|
|
|
|
->orWhereBetween('end_date', [$configStartDate, $configEndDate]);
|
|
|
|
|
}
|
|
|
|
|
})->count();
|
|
|
|
|
})
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
// 2. 历史课程的总期数(在配置的日期范围内,针对所有课程类型)
|
|
|
|
|
$historyCoursePeriodsTotal = HistoryCourse::whereHas('typeDetail', function ($query) use ($courseTypeNames) {
|
|
|
|
|
// 使用名称匹配所有课程类型(与循环中的逻辑保持一致)
|
|
|
|
|
$query->where(function ($q) use ($courseTypeNames) {
|
|
|
|
|
foreach ($courseTypeNames as $name) {
|
|
|
|
|
$q->orWhere('name', 'like', '%' . $name . '%');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
->where(function ($query) use ($configStartDate, $configEndDate) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
if ($configStartDate && $configEndDate) {
|
|
|
|
|
$query->whereBetween('start_time', [$configStartDate, $configEndDate])
|
|
|
|
|
->orWhereBetween('end_time', [$configStartDate, $configEndDate]);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
// 3. 总期数 = 现在课程期数 + 历史课程期数
|
|
|
|
|
$config->course_periods_total = $nowCoursePeriodsTotal + $historyCoursePeriodsTotal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->success(compact('list', 'suzhou', 'country', 'monthCourses', 'time_axis', 'article', 'yearConfigs'));
|
|
|
|
|
|