|
|
|
|
@ -87,6 +87,26 @@ class Calendar extends SoftDeletesModel
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取开课统计(场次数量或天数总和)
|
|
|
|
|
* @param string|null $start_date 开始日期
|
|
|
|
|
* @param string|null $end_date 结束日期
|
|
|
|
|
* @param array|null $course_type_id 课程体系ID数组
|
|
|
|
|
* @param string $type 统计类型:'count' 统计次数,'sum' 统计天数总和
|
|
|
|
|
* @return int|float
|
|
|
|
|
*/
|
|
|
|
|
public static function getCourseStatistics($start_date = null, $end_date = null, $course_type_id = null, $type = 'count')
|
|
|
|
|
{
|
|
|
|
|
$query = self::getCalendarsByDateRange($start_date, $end_date, $course_type_id)
|
|
|
|
|
->where('is_count_days', 1);
|
|
|
|
|
|
|
|
|
|
if ($type === 'sum') {
|
|
|
|
|
return $query->sum('days');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $query->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取开课场次数量
|
|
|
|
|
* @param string|null $start_date 开始日期
|
|
|
|
|
@ -96,7 +116,7 @@ class Calendar extends SoftDeletesModel
|
|
|
|
|
*/
|
|
|
|
|
public static function getCourseTotal($start_date = null, $end_date = null, $course_type_id = null)
|
|
|
|
|
{
|
|
|
|
|
return self::getCalendarsByDateRange($start_date, $end_date, $course_type_id)->count();
|
|
|
|
|
return self::getCourseStatistics($start_date, $end_date, $course_type_id, 'count');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -108,9 +128,7 @@ class Calendar extends SoftDeletesModel
|
|
|
|
|
*/
|
|
|
|
|
public static function getCourseDayTotal($start_date = null, $end_date = null, $course_type_id = null)
|
|
|
|
|
{
|
|
|
|
|
return self::getCalendarsByDateRange($start_date, $end_date, $course_type_id)
|
|
|
|
|
->where('is_count_days', 1)
|
|
|
|
|
->sum('days');
|
|
|
|
|
return self::getCourseStatistics($start_date, $end_date, $course_type_id, 'sum');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|