Browse Source

fixed:用户端-用户信息(包含技师信息)

刘学玺 4 months ago
parent
commit
ff945cd7ea
1 changed files with 14 additions and 5 deletions
  1. 14 5
      app/Services/Client/UserService.php

+ 14 - 5
app/Services/Client/UserService.php

@@ -36,9 +36,10 @@ class UserService
      *
      * 业务逻辑:
      * 1. 通过 Auth 门面获取当前登录用户信息
-     * 2. 返回用户基本信息
+     * 2. 加载用户的技师信息
+     * 3. 翻译技师状态
      *
-     * @return \Illuminate\Http\JsonResponse 返回用户信息
+     * @return MemberUser 返回用户信息
      *
      * @throws \Exception 获取用户信息失败时抛出异常
      */
@@ -46,9 +47,17 @@ class UserService
     {
         try {
             /** @var MemberUser $user */
-            // 通过 Auth 门面获取当前登录用户信息
             $user = Auth::user();
 
+            // 加载技师信息
+            $user->load('coach:id,user_id,state');
+
+            // 如果有技师信息,添加状态文本
+            if ($user->coach) {
+                $user->coach->makeVisible(['state']);
+                $user->coach->state_text = TechnicianStatus::fromValue($user->coach->state)?->label() ?? '未知状态';
+            }
+
             return $user;
         } catch (\Exception $e) {
             // 记录错误日志
@@ -217,7 +226,7 @@ class UserService
      * 申请成为技师
      *
      * 业务逻辑:
-     * 1. 检查户申请资格
+     * 1. 检查���户申请资格
      * 2. 创建或更新技师基础信息
      * 3. 创建申请记录
      *
@@ -350,7 +359,7 @@ class UserService
      *
      * @param  \App\Models\Coach  $coach  技师模型
      *
-     * @throws \Illuminate\Http\Exceptions\HttpResponseException 存在未成申请时抛出异常
+     * @throws \Illuminate\Http\Exceptions\HttpResponseException 存在未��成申请时抛出异常
      */
     private function validateExistingApplication($coach): void
     {