|
|
|
|
@ -6,6 +6,7 @@ use App\Helpers\ResponseCode;
|
|
|
|
|
use App\Models\Admin;
|
|
|
|
|
use App\Models\Appointment;
|
|
|
|
|
use App\Models\AppointmentConfig;
|
|
|
|
|
use App\Models\Calendar;
|
|
|
|
|
use App\Models\CarparkLog;
|
|
|
|
|
use App\Models\Company;
|
|
|
|
|
use App\Models\CourseSign;
|
|
|
|
|
@ -125,28 +126,22 @@ class OtherController extends CommonController
|
|
|
|
|
$query->whereIn('course_id', $courses->pluck('id'));
|
|
|
|
|
})->count();
|
|
|
|
|
// 审核通过人数
|
|
|
|
|
$list['course_signs_pass'] = CourseSign::where('status', 1)
|
|
|
|
|
$courseSign = 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();
|
|
|
|
|
})->get();
|
|
|
|
|
$list['course_signs_pass'] = $courseSign->count();
|
|
|
|
|
// 审核通过人数去重
|
|
|
|
|
$list['course_signs_pass_unique'] = 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'));
|
|
|
|
|
})->select('user_id')
|
|
|
|
|
->distinct()
|
|
|
|
|
->count();
|
|
|
|
|
$list['course_signs_pass_unique'] = User::whereIn('id', $courseSign->pluck('user_id'))->groupBy('mobile')->count();
|
|
|
|
|
// 开课场次
|
|
|
|
|
$list['course_total'] = $courses->count();
|
|
|
|
|
$calendar = Calendar::whereIn('course_id', $courses->pluck('id'))->whereBetween('date', [$start_date, $end_date])->get();
|
|
|
|
|
$list['course_total'] = $calendar->count();
|
|
|
|
|
// 开课天数
|
|
|
|
|
$list['course_day_total'] = $courses->sum(function ($course) {
|
|
|
|
|
$start = Carbon::parse($course->start_date);
|
|
|
|
|
$end = Carbon::parse($course->end_date);
|
|
|
|
|
$list['course_day_total'] = $calendar->sum(function ($course) {
|
|
|
|
|
$start = Carbon::parse($course->start_time);
|
|
|
|
|
$end = Carbon::parse($course->end_time);
|
|
|
|
|
return $end->diffInDays($start) + 1; // 包含起始和结束日期
|
|
|
|
|
});
|
|
|
|
|
// 返回所有sql语句
|
|
|
|
|
@ -160,20 +155,15 @@ class OtherController extends CommonController
|
|
|
|
|
->where('start_date', '<=', $end_date)
|
|
|
|
|
->where('type', $courseType->id)
|
|
|
|
|
->get();
|
|
|
|
|
// 培养人数
|
|
|
|
|
$courseTypeSignsPass = CourseSign::where('status', 1)
|
|
|
|
|
$courseSignByType = CourseSign::where('status', 1)
|
|
|
|
|
->whereIn('course_id', $courses2->pluck('id'))
|
|
|
|
|
->whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->count();
|
|
|
|
|
->get();
|
|
|
|
|
// 培养人数
|
|
|
|
|
$courseTypeSignsPass = $courseSignByType->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();
|
|
|
|
|
$courseTypeSignsPassUnique = User::whereIn('id', $courseSignByType->pluck('user_id'))->groupBy('mobile')->count();
|
|
|
|
|
foreach ($courses2 as $course) {
|
|
|
|
|
$courseTypesSum[] = [
|
|
|
|
|
'course_type' => $courseType->name,
|
|
|
|
|
|