Merge branch 'master' of ssh://47.101.48.251:/data/git/wx.sstbc.com

master
lion 2 months ago
commit 1626daaa6b

@ -581,7 +581,10 @@ 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="giveup_reason", in="query", @OA\Schema(type="string"), required=false, description="放弃原因"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
@ -614,7 +617,38 @@ 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'];
}
}
// 更新 giveup_reason 放弃原因
if (isset($all['giveup_reason'])) {
$model->giveup_reason = $all['giveup_reason'];
}
$model->save();
if ($model->status == 1) {
Notification::send(User::find($model->user_id), new AuditNotify($data));

@ -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'));
// 审核通过人数

@ -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'];

Loading…
Cancel
Save