|
|
|
@ -16,6 +16,7 @@ use App\Models\ParameterDetail;
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Repositories\DoorRepository;
|
|
|
|
use App\Repositories\DoorRepository;
|
|
|
|
use App\Repositories\EntranceRepository;
|
|
|
|
use App\Repositories\EntranceRepository;
|
|
|
|
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
use App\Models\Course;
|
|
|
|
use App\Models\Course;
|
|
|
|
@ -81,6 +82,108 @@ class OtherController extends CommonController
|
|
|
|
return $this->success(compact('courseTypes', 'schoolmate', 'company', 'industryTotal', 'suzhou', 'country'));
|
|
|
|
return $this->success(compact('courseTypes', 'schoolmate', 'company', 'industryTotal', 'suzhou', 'country'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
|
|
|
* path="/api/admin/other/courses-home",
|
|
|
|
|
|
|
|
* tags={"其他"},
|
|
|
|
|
|
|
|
* summary="课程统计",
|
|
|
|
|
|
|
|
* 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="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
|
|
|
* response="200",
|
|
|
|
|
|
|
|
* description="暂无"
|
|
|
|
|
|
|
|
* )
|
|
|
|
|
|
|
|
* )
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function coursesHome()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$start_date = request('start_date', '2020-01-01');
|
|
|
|
|
|
|
|
$end_date = request('end_date', date('Y-m-d'));
|
|
|
|
|
|
|
|
// 报名人数
|
|
|
|
|
|
|
|
$list['course_signs_total'] = CourseSign::whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
// 审核通过人数
|
|
|
|
|
|
|
|
$list['course_signs_pass'] = CourseSign::where('status', 1)
|
|
|
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
// 审核通过人数去重
|
|
|
|
|
|
|
|
$list['course_signs_pass_unique'] = CourseSign::where('status', 1)
|
|
|
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->select('user_id')
|
|
|
|
|
|
|
|
->distinct()
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
// 课程
|
|
|
|
|
|
|
|
$courses = Course::whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
// 开课场次
|
|
|
|
|
|
|
|
$list['course_total'] = $courses->count();
|
|
|
|
|
|
|
|
// 开课天数
|
|
|
|
|
|
|
|
$list['course_day_total'] = $courses->sum(function ($course) {
|
|
|
|
|
|
|
|
$start = Carbon::parse($course->start_date);
|
|
|
|
|
|
|
|
$end = Carbon::parse($course->end_date);
|
|
|
|
|
|
|
|
return $end->diffInDays($start) + 1; // 包含起始和结束日期
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 课程分类明细统计
|
|
|
|
|
|
|
|
$courseTypesSum = [];
|
|
|
|
|
|
|
|
$courseTypes = CourseType::get();
|
|
|
|
|
|
|
|
foreach ($courseTypes as $courseType) {
|
|
|
|
|
|
|
|
// 获取课程
|
|
|
|
|
|
|
|
$courses = Course::where('type', $courseType->id)->get();
|
|
|
|
|
|
|
|
// 培养人数
|
|
|
|
|
|
|
|
$courseTypeSignsPass = CourseSign::where('status', 1)
|
|
|
|
|
|
|
|
->whereIn('course_id', $courses->pluck('id'))
|
|
|
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
// 去重培养人数
|
|
|
|
|
|
|
|
$courseTypeSignsPassUnique = CourseSign::where('status', 1)
|
|
|
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->select('user_id')
|
|
|
|
|
|
|
|
->distinct()
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
foreach ($courses as $course) {
|
|
|
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
|
|
|
'course_type' => $courseType->name,
|
|
|
|
|
|
|
|
'course_type_signs_pass' => $courseTypeSignsPass,
|
|
|
|
|
|
|
|
'course_type_signs_pass_unique' => $courseTypeSignsPassUnique,
|
|
|
|
|
|
|
|
'course_name' => $course->name,
|
|
|
|
|
|
|
|
'course_signs_pass' => CourseSign::where('status', 1)
|
|
|
|
|
|
|
|
->where('course_id', $course->id)
|
|
|
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->count()
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 区域明细统计
|
|
|
|
|
|
|
|
$areas = ParameterDetail::where('parameter_id', 5)->get();
|
|
|
|
|
|
|
|
foreach ($areas as $area) {
|
|
|
|
|
|
|
|
$area->course_signs_pass = CourseSign::where('status', 1)
|
|
|
|
|
|
|
|
->whereHas('user', function ($query) use ($area) {
|
|
|
|
|
|
|
|
$query->where('company_area', $area->value);
|
|
|
|
|
|
|
|
})->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
$area->course_signs_pass_unique = CourseSign::where('status', 1)
|
|
|
|
|
|
|
|
->whereHas('user', function ($query) use ($area) {
|
|
|
|
|
|
|
|
$query->where('company_area', $area->value);
|
|
|
|
|
|
|
|
})->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
|
|
|
->select('user_id')
|
|
|
|
|
|
|
|
->distinct()
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success(compact('list', 'courseTypesSum', 'areas'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @OA\Post(
|
|
|
|
* @OA\Post(
|
|
|
|
* path="/api/admin/other/admin-user-list",
|
|
|
|
* path="/api/admin/other/admin-user-list",
|
|
|
|
|