master
cody 2 months ago
parent 0c352fc7ee
commit 2bf6c9a529

@ -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="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="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="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\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response( * @OA\Response(
* response="200", * response="200",
@ -614,7 +616,33 @@ class CourseSignController extends BaseController
continue; continue;
$data = ['course_id' => $all['course_id'], 'course_sign_id' => $id, 'status_text' => CourseSign::$intToString['status'][$all['status']]]; $data = ['course_id' => $all['course_id'], 'course_sign_id' => $id, 'status_text' => CourseSign::$intToString['status'][$all['status']]];
$model->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(); $model->save();
if ($model->status == 1) { if ($model->status == 1) {
Notification::send(User::find($model->user_id), new AuditNotify($data)); Notification::send(User::find($model->user_id), new AuditNotify($data));

@ -131,8 +131,8 @@ class OtherController extends CommonController
// 生成缓存键(该方法无参数,使用固定键名) // 生成缓存键(该方法无参数,使用固定键名)
$cacheKey = 'home_v2_data'; $cacheKey = 'home_v2_data';
// 尝试从缓存获取数据,缓存5分钟300秒 // 尝试从缓存获取数据,使用 CourseSign 模型定义的缓存时间
$data = Cache::remember($cacheKey, 300, function () { $data = Cache::remember($cacheKey, CourseSign::CACHE_TIME_STATISTICS, function () {
// 默认开始时间 // 默认开始时间
$start_date = CourseType::START_DATE; $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)); $cacheKey = 'courses_home_' . md5($start_date . '_' . $end_date . '_' . implode(',', $course_type_id));
// 尝试从缓存获取数据,缓存5分钟300秒 // 尝试从缓存获取数据,使用 CourseSign 模型定义的缓存时间
$data = Cache::remember($cacheKey, 300, function () use ($start_date, $end_date, $course_type_id, $courses) { $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')); $list['course_signs_total'] = CourseSign::courseSignsTotal($start_date, $end_date, null, $courses->pluck('id'));
// 审核通过人数 // 审核通过人数

@ -9,6 +9,9 @@ use OwenIt\Auditing\Models\Audit;
class CourseSign extends SoftDeletesModel 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 $casts = ['file_ids' => 'json', 'fee_file_ids' => 'json', 'data' => 'json', 'change_data' => 'json'];
protected $appends = ['files', 'fee_files', 'status_text', 'fee_status_text']; protected $appends = ['files', 'fee_files', 'status_text', 'fee_status_text'];

Loading…
Cancel
Save