From 2bf6c9a529f0994be9d8e773d7c02370e64f3e14 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Fri, 23 Jan 2026 10:58:19 +0800 Subject: [PATCH] update --- .../Admin/CourseSignController.php | 32 +++++++++++++++++-- .../Controllers/Admin/OtherController.php | 8 ++--- app/Models/CourseSign.php | 3 ++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/CourseSignController.php b/app/Http/Controllers/Admin/CourseSignController.php index 812ac14..25fdbc7 100755 --- a/app/Http/Controllers/Admin/CourseSignController.php +++ b/app/Http/Controllers/Admin/CourseSignController.php @@ -581,7 +581,9 @@ class CourseSignController extends BaseController * @OA\Parameter(name="course_id", in="query", @OA\Schema(type="string"), required=true, description="课程id"), * @OA\Parameter(name="ids", in="query", @OA\Schema(type="string"), required=true, description="英文逗号分隔的id数组"), * @OA\Parameter(name="status", in="query", @OA\Schema(type="string"), required=true, description="状态0待审核1通过2拒绝"), - * @OA\Parameter(name="reason", in="query", @OA\Schema(type="string"), required=true, description="reason"), + * @OA\Parameter(name="reason", in="query", @OA\Schema(type="string"), required=false, description="备注"), + * @OA\Parameter(name="score", in="query", @OA\Schema(type="integer"), required=false, description="分数"), + * @OA\Parameter(name="file_ids", in="query", @OA\Schema(type="string"), required=false, description="文件id数组,JSON格式字符串或英文逗号分隔的字符串"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", @@ -614,7 +616,33 @@ class CourseSignController extends BaseController continue; $data = ['course_id' => $all['course_id'], 'course_sign_id' => $id, 'status_text' => CourseSign::$intToString['status'][$all['status']]]; $model->status = $all['status']; - $model->reason = $all['reason'] ?? ''; + + // 更新 reason 备注 + if (isset($all['reason'])) { + $model->reason = $all['reason']; + } + + // 更新 score 分数 + if (isset($all['score'])) { + $model->score = $all['score']; + } + + // 更新 file_ids 文件数组 + if (isset($all['file_ids'])) { + // 如果传入的是字符串,尝试解析为 JSON + if (is_string($all['file_ids'])) { + $fileIds = json_decode($all['file_ids'], true); + if (json_last_error() === JSON_ERROR_NONE) { + $model->file_ids = $fileIds; + } else { + // 如果不是 JSON,可能是逗号分隔的字符串 + $model->file_ids = array_filter(array_map('trim', explode(',', $all['file_ids']))); + } + } elseif (is_array($all['file_ids'])) { + $model->file_ids = $all['file_ids']; + } + } + $model->save(); if ($model->status == 1) { Notification::send(User::find($model->user_id), new AuditNotify($data)); diff --git a/app/Http/Controllers/Admin/OtherController.php b/app/Http/Controllers/Admin/OtherController.php index bad4cc9..77bf84d 100755 --- a/app/Http/Controllers/Admin/OtherController.php +++ b/app/Http/Controllers/Admin/OtherController.php @@ -131,8 +131,8 @@ class OtherController extends CommonController // 生成缓存键(该方法无参数,使用固定键名) $cacheKey = 'home_v2_data'; - // 尝试从缓存获取数据,缓存5分钟(300秒) - $data = Cache::remember($cacheKey, 300, function () { + // 尝试从缓存获取数据,使用 CourseSign 模型定义的缓存时间 + $data = Cache::remember($cacheKey, CourseSign::CACHE_TIME_STATISTICS, function () { // 默认开始时间 $start_date = CourseType::START_DATE; // 默认结束日期一年以后 @@ -343,8 +343,8 @@ class OtherController extends CommonController // 生成缓存键(基于参数) $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) { + // 尝试从缓存获取数据,使用 CourseSign 模型定义的缓存时间 + $data = Cache::remember($cacheKey, CourseSign::CACHE_TIME_STATISTICS, function () use ($start_date, $end_date, $course_type_id, $courses) { // 报名人数 $list['course_signs_total'] = CourseSign::courseSignsTotal($start_date, $end_date, null, $courses->pluck('id')); // 审核通过人数 diff --git a/app/Models/CourseSign.php b/app/Models/CourseSign.php index f89682e..aed9673 100755 --- a/app/Models/CourseSign.php +++ b/app/Models/CourseSign.php @@ -9,6 +9,9 @@ use OwenIt\Auditing\Models\Audit; class CourseSign extends SoftDeletesModel { + // 统计接口缓存时间(秒) + const CACHE_TIME_STATISTICS = 600; // 10分钟 + protected $casts = ['file_ids' => 'json', 'fee_file_ids' => 'json', 'data' => 'json', 'change_data' => 'json']; protected $appends = ['files', 'fee_files', 'status_text', 'fee_status_text'];