|
|
|
|
@ -90,6 +90,7 @@ class OtherController extends CommonController
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=true, description="开始日期"),
|
|
|
|
|
* @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=true, description="结束日期"),
|
|
|
|
|
* @OA\Parameter(name="course_type_id", in="query", @OA\Schema(type="string"), required=true, description="课程体系id,多个英文逗号"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
@ -104,26 +105,42 @@ class OtherController extends CommonController
|
|
|
|
|
|
|
|
|
|
$start_date = request('start_date', '2020-01-01');
|
|
|
|
|
$end_date = request('end_date', date('Y-m-d'));
|
|
|
|
|
$course_type_id = request('course_type_id', '');
|
|
|
|
|
if ($course_type_id) {
|
|
|
|
|
// 部分
|
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
|
} else {
|
|
|
|
|
// 全部
|
|
|
|
|
$course_type_id = CourseType::pluck('id')->toArray();
|
|
|
|
|
}
|
|
|
|
|
// 课程
|
|
|
|
|
$courses = Course::where('start_date', '>=', $start_date)
|
|
|
|
|
->where('start_date', '<=', $end_date)
|
|
|
|
|
->whereIn('type', $course_type_id)
|
|
|
|
|
->get();
|
|
|
|
|
// 报名人数
|
|
|
|
|
$list['course_signs_total'] = CourseSign::whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->count();
|
|
|
|
|
->where(function ($query) use ($courses) {
|
|
|
|
|
$query->whereIn('course_id', $courses->pluck('id'));
|
|
|
|
|
})->count();
|
|
|
|
|
// 审核通过人数
|
|
|
|
|
$list['course_signs_pass'] = CourseSign::where('status', 1)
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->where(function ($query) use ($courses) {
|
|
|
|
|
$query->whereIn('course_id', $courses->pluck('id'));
|
|
|
|
|
})
|
|
|
|
|
->count();
|
|
|
|
|
// 审核通过人数去重
|
|
|
|
|
$list['course_signs_pass_unique'] = CourseSign::where('status', 1)
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->select('user_id')
|
|
|
|
|
->where(function ($query) use ($courses) {
|
|
|
|
|
$query->whereIn('course_id', $courses->pluck('id'));
|
|
|
|
|
})->select('user_id')
|
|
|
|
|
->distinct()
|
|
|
|
|
->count();
|
|
|
|
|
// 课程
|
|
|
|
|
$courses = Course::whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->get();
|
|
|
|
|
// 开课场次
|
|
|
|
|
$list['course_total'] = $courses->count();
|
|
|
|
|
// 开课天数
|
|
|
|
|
@ -136,24 +153,28 @@ class OtherController extends CommonController
|
|
|
|
|
$sql = DB::getQueryLog();
|
|
|
|
|
// 课程分类明细统计
|
|
|
|
|
$courseTypesSum = [];
|
|
|
|
|
$courseTypes = CourseType::get();
|
|
|
|
|
$courseTypes = CourseType::whereIn('id', $course_type_id)->get();
|
|
|
|
|
foreach ($courseTypes as $courseType) {
|
|
|
|
|
// 获取课程
|
|
|
|
|
$courses = Course::where('type', $courseType->id)->get();
|
|
|
|
|
$courses2 = Course::where('start_date', '>=', $start_date)
|
|
|
|
|
->where('start_date', '<=', $end_date)
|
|
|
|
|
->where('type', $courseType->id)
|
|
|
|
|
->get();
|
|
|
|
|
// 培养人数
|
|
|
|
|
$courseTypeSignsPass = CourseSign::where('status', 1)
|
|
|
|
|
->whereIn('course_id', $courses->pluck('id'))
|
|
|
|
|
->whereIn('course_id', $courses2->pluck('id'))
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->count();
|
|
|
|
|
// 去重培养人数
|
|
|
|
|
$courseTypeSignsPassUnique = CourseSign::where('status', 1)
|
|
|
|
|
->whereIn('course_id', $courses2->pluck('id'))
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->select('user_id')
|
|
|
|
|
->distinct()
|
|
|
|
|
->count();
|
|
|
|
|
foreach ($courses as $course) {
|
|
|
|
|
foreach ($courses2 as $course) {
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
'course_type' => $courseType->name,
|
|
|
|
|
'course_type_signs_pass' => $courseTypeSignsPass,
|
|
|
|
|
|