|
|
|
|
@ -26,6 +26,7 @@ use App\Models\User;
|
|
|
|
|
use App\Repositories\DoorRepository;
|
|
|
|
|
use App\Repositories\EntranceRepository;
|
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
|
use App\Models\Course;
|
|
|
|
|
@ -127,6 +128,11 @@ class OtherController extends CommonController
|
|
|
|
|
*/
|
|
|
|
|
public function homeV2()
|
|
|
|
|
{
|
|
|
|
|
// 生成缓存键(该方法无参数,使用固定键名)
|
|
|
|
|
$cacheKey = 'home_v2_data';
|
|
|
|
|
|
|
|
|
|
// 尝试从缓存获取数据,缓存5分钟(300秒)
|
|
|
|
|
$data = Cache::remember($cacheKey, 300, function () {
|
|
|
|
|
// 默认开始时间
|
|
|
|
|
$start_date = CourseType::START_DATE;
|
|
|
|
|
// 默认结束日期一年以后
|
|
|
|
|
@ -301,7 +307,12 @@ class OtherController extends CommonController
|
|
|
|
|
$config->course_signs_unique_total = CourseSign::courseSignsTotalByUnique($configStartDate, $configEndDate, 1, $configCourseIds->unique()->values(), false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->success(compact('list', 'suzhou', 'country', 'monthCourses', 'time_axis', 'article', 'yearConfigs'));
|
|
|
|
|
// 返回数据数组
|
|
|
|
|
return compact('list', 'suzhou', 'country', 'monthCourses', 'time_axis', 'article', 'yearConfigs');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 返回响应
|
|
|
|
|
return $this->success($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -329,6 +340,11 @@ class OtherController extends CommonController
|
|
|
|
|
$course_type_id = $params['course_type_id'];
|
|
|
|
|
$courses = $params['courses'];
|
|
|
|
|
|
|
|
|
|
// 生成缓存键(基于参数)
|
|
|
|
|
$cacheKey = 'courses_home_' . md5($start_date . '_' . $end_date . '_' . implode(',', $course_type_id));
|
|
|
|
|
|
|
|
|
|
// 尝试从缓存获取数据,缓存5分钟(300秒)
|
|
|
|
|
$data = Cache::remember($cacheKey, 300, function () use ($start_date, $end_date, $course_type_id, $courses) {
|
|
|
|
|
// 报名人数
|
|
|
|
|
$list['course_signs_total'] = CourseSign::courseSignsTotal($start_date, $end_date, null, $courses->pluck('id'));
|
|
|
|
|
// 审核通过人数
|
|
|
|
|
@ -450,7 +466,12 @@ class OtherController extends CommonController
|
|
|
|
|
// 获取统计项元数据
|
|
|
|
|
$statistics_metadata = Course::getStatisticsMetadata();
|
|
|
|
|
|
|
|
|
|
return $this->success(compact('list', 'courseTypesSum', 'areas', 'areas_schoolmate', 'statistics_metadata'));
|
|
|
|
|
// 返回数据数组
|
|
|
|
|
return compact('list', 'courseTypesSum', 'areas', 'areas_schoolmate', 'statistics_metadata');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 返回响应
|
|
|
|
|
return $this->success($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|