|
|
|
|
@ -118,9 +118,6 @@ class OtherController extends CommonController
|
|
|
|
|
*/
|
|
|
|
|
public function coursesHome()
|
|
|
|
|
{
|
|
|
|
|
// 启用查询日志记录
|
|
|
|
|
DB::enableQueryLog();
|
|
|
|
|
|
|
|
|
|
$start_date = request('start_date', '2020-01-01');
|
|
|
|
|
$end_date = request('end_date', date('Y-m-d'));
|
|
|
|
|
$course_type_id = request('course_type_id', '');
|
|
|
|
|
@ -137,25 +134,11 @@ class OtherController extends CommonController
|
|
|
|
|
->whereIn('type', $course_type_id)
|
|
|
|
|
->get();
|
|
|
|
|
// 报名人数
|
|
|
|
|
$list['course_signs_total'] = CourseSign::whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->whereNotIn('status', [4, 5])
|
|
|
|
|
->distinct('user_id')
|
|
|
|
|
// ->where(function ($query) use ($courses) {
|
|
|
|
|
// $query->whereIn('course_id', $courses->pluck('id'));
|
|
|
|
|
// })
|
|
|
|
|
->count();
|
|
|
|
|
$list['course_signs_total'] = CourseSign::courseSignsTotal($start_date, $end_date);
|
|
|
|
|
// 审核通过人数
|
|
|
|
|
$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'));
|
|
|
|
|
// })
|
|
|
|
|
->get();
|
|
|
|
|
$list['course_signs_pass'] = $courseSign->count();
|
|
|
|
|
$list['course_signs_pass'] = CourseSign::courseSignsTotal($start_date, $end_date, 1);
|
|
|
|
|
// 审核通过人数去重
|
|
|
|
|
$list['course_signs_pass_unique'] = User::whereIn('id', $courseSign->pluck('user_id'))->distinct('mobile')->count();
|
|
|
|
|
$list['course_signs_pass_unique'] = CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1);
|
|
|
|
|
// 开课场次
|
|
|
|
|
$calendar = Calendar::whereIn('course_id', $courses->pluck('id'))->whereBetween('date', [$start_date, $end_date])->get();
|
|
|
|
|
$list['course_total'] = $calendar->count();
|
|
|
|
|
@ -165,8 +148,6 @@ class OtherController extends CommonController
|
|
|
|
|
$end = Carbon::parse($course->end_time);
|
|
|
|
|
return $end->diffInDays($start) + 1; // 包含起始和结束日期
|
|
|
|
|
});
|
|
|
|
|
// 返回所有sql语句
|
|
|
|
|
$sql = DB::getQueryLog();
|
|
|
|
|
// 课程分类明细统计
|
|
|
|
|
$courseTypesSum = [];
|
|
|
|
|
$courseTypes = CourseType::whereIn('id', $course_type_id)->get();
|
|
|
|
|
|