getId(); $userId = $this->user_id; Log::info('用户切换皮肤请求', [ 'user_id' => $userId, 'skin_id' => $skinId ]); // 验证参数 $validation = new SkinValidation(); $validation->skinId = $skinId; $validation->userId = $userId; $validationResult = $validation->changeSkin(); if (!$validationResult->success) { Log::warning('皮肤切换验证失败', [ 'user_id' => $userId, 'skin_id' => $skinId, 'error' => $validationResult->message ]); // 设置错误响应 $this->response->setCode(RESPONSE_CODE::VALIDATE_ERROR); $this->response->setMsg($validationResult->message); return $response; } // 切换皮肤 $result = SkinService::changeSkin($userId, $skinId); if ($result->success) { Log::info('皮肤切换成功', [ 'user_id' => $userId, 'skin_id' => $skinId ]); // 设置成功响应 $this->response->setCode(RESPONSE_CODE::OK); $this->response->setMsg('皮肤切换成功'); } else { Log::error('皮肤切换失败', [ 'user_id' => $userId, 'skin_id' => $skinId, 'error' => $result->message ]); // 设置错误响应 $this->response->setCode(RESPONSE_CODE::SERVER_ERROR); $this->response->setMsg($result->message); } return $response; } catch (\Exception $e) { Log::error('处理用户游戏皮肤请求异常', [ 'user_id' => $this->user_id ?? 0, 'skin_id' => $data->getId() ?? 0, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); // 创建错误响应 $response = new ResponseUserGameSkin(); $this->response->setCode(RESPONSE_CODE::SERVER_ERROR); $this->response->setMsg('系统错误,请稍后重试'); return $response; } } }