|
|
|
@ -240,36 +240,9 @@ class OtherController extends CommonController
|
|
|
|
// 审核通过人数去重
|
|
|
|
// 审核通过人数去重
|
|
|
|
$list['course_signs_pass_unique'] = CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $courses->pluck('id'), null);
|
|
|
|
$list['course_signs_pass_unique'] = CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $courses->pluck('id'), null);
|
|
|
|
// 开课场次
|
|
|
|
// 开课场次
|
|
|
|
// 开课场次
|
|
|
|
$list['course_total'] = Calendar::getCourseTotal($start_date, $end_date, $course_type_id);
|
|
|
|
$calendar = Calendar::where(function ($query) use ($start_date, $end_date) {
|
|
|
|
|
|
|
|
$query->whereBetween('start_time', [$start_date, $end_date])
|
|
|
|
|
|
|
|
->orWhereBetween('end_time', [$start_date, $end_date]);
|
|
|
|
|
|
|
|
})->where(function ($query) use ($course_type_id) {
|
|
|
|
|
|
|
|
// 条件1:有 course_id 的数据,通过 course.type 匹配课程体系
|
|
|
|
|
|
|
|
// 条件2:没有 course_id 的数据,直接用 course_type_id 字段匹配
|
|
|
|
|
|
|
|
// 两个条件是或关系
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
|
|
|
$course_type_id_array = is_array($course_type_id) ? $course_type_id : explode(',', $course_type_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 条件1:有 course_id 时,通过关联的 course.type 匹配
|
|
|
|
|
|
|
|
$query->where(function ($q) use ($course_type_id_array) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$q->whereHas('course', function ($subQ) use ($course_type_id_array) {
|
|
|
|
|
|
|
|
$subQ->whereIn('type', $course_type_id_array);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 条件2:没有 course_id 时,直接用 course_type_id 字段匹配(或关系)
|
|
|
|
|
|
|
|
$query->orWhere(function ($q) use ($course_type_id_array) {
|
|
|
|
|
|
|
|
$q->whereIn('course_type_id', $course_type_id_array);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$list['course_total'] = (clone $calendar)->count();
|
|
|
|
|
|
|
|
// 开课天数
|
|
|
|
// 开课天数
|
|
|
|
$list['course_day_total'] = (clone $calendar)->where('is_count_days', 1)->sum('days');
|
|
|
|
$list['course_day_total'] = Calendar::getCourseDayTotal($start_date, $end_date, $course_type_id);
|
|
|
|
|
|
|
|
|
|
|
|
$course_ids = $courses->pluck('id');
|
|
|
|
$course_ids = $courses->pluck('id');
|
|
|
|
|
|
|
|
|
|
|
|
@ -955,14 +928,8 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
|
|
case 'course_total':
|
|
|
|
case 'course_total':
|
|
|
|
// 开课场次明细 - 与coursesHome算法一致
|
|
|
|
// 开课场次明细 - 与coursesHome算法一致
|
|
|
|
$calendars = Calendar::whereBetween('date', [$start_date, $end_date])
|
|
|
|
$calendars = Calendar::getCalendarsByDateRange($start_date, $end_date, $course_type_id)
|
|
|
|
->where(function ($query) use ($course_ids) {
|
|
|
|
->with('course')
|
|
|
|
$course_type_id = request('course_type_id');
|
|
|
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
|
|
|
|
$query->whereIn('course_type_id', $course_type_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})->with('course')
|
|
|
|
|
|
|
|
->get();
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($calendars as $calendar) {
|
|
|
|
foreach ($calendars as $calendar) {
|
|
|
|
@ -988,14 +955,8 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
|
|
case 'course_day_total':
|
|
|
|
case 'course_day_total':
|
|
|
|
// 开课天数明细 - 与coursesHome算法一致
|
|
|
|
// 开课天数明细 - 与coursesHome算法一致
|
|
|
|
$calendars = Calendar::whereBetween('date', [$start_date, $end_date])
|
|
|
|
$calendars = Calendar::getCalendarsByDateRange($start_date, $end_date, $course_type_id)
|
|
|
|
->where(function ($query) use ($course_ids) {
|
|
|
|
->where('is_count_days', 1)
|
|
|
|
$course_type_id = request('course_type_id');
|
|
|
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
|
|
|
|
$query->whereIn('course_type_id', $course_type_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})->where('is_count_days', 1)
|
|
|
|
|
|
|
|
->with('course')
|
|
|
|
->with('course')
|
|
|
|
->get();
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
|
|
|