getModel()::findOrFail($id); // 检查状态 if ((int)$record->state != TechnicianAuthStatus::AUDITING->value) { throw new \Exception('该认证已审核'); } // 更新认证记录 $record->update([ 'state' => $state, 'audit_remark' => $remark, 'auditor' => $adminId, 'audit_time' => now(), ]); // 如果审核通过,更新技师状态 if ($state == TechnicianAuthStatus::PASSED->value) { CoachUser::where('id', $record->coach_id)->update([ 'qualification_record_id' => $record->id ]); } DB::commit(); return true; } catch (\Exception $e) { DB::rollBack(); throw $e; } } }