column('admin_id'); if (empty($adminIds)) { return [ 'lists' => [], 'count' => 0, 'page_no' => $page_no, 'page_size' => $page_size ]; } $query = Admin::whereIn('id', $adminIds) ->where('disable', 0); // 搜索关键词 if (!empty($keyword)) { $query->where('name|account', 'like', '%' . $keyword . '%'); } $lists = $query->field(['id', 'name', 'account', 'avatar', 'title','specialty']) ->limit($offset, $page_size) ->order('id asc') ->select() ->toArray(); // 处理医生数据 $doctors = []; foreach ($lists as $doctor) { $doctors[] = [ 'id' => $doctor['id'], 'name' => $doctor['name'], 'account' => $doctor['account'], 'avatar' => $doctor['avatar'] ?? '', 'specialty' => $doctor['specialty'], // 可根据需要扩展 'title' => $doctor['title'], // 可根据需要扩展 'rating' => '9.8', // 可根据需要从其他表获取 ]; } // 获取总数 $countQuery = Admin::whereIn('id', $adminIds) ->where('disable', 0); if (!empty($keyword)) { $countQuery->where('name|account', 'like', '%' . $keyword . '%'); } $count = $countQuery->count(); return [ 'lists' => $doctors, 'count' => $count, 'page_no' => $page_no, 'page_size' => $page_size ]; } /** * @notes 获取医生详情(含完整档案信息) * @param int $doctorId * @return array|null */ public static function getDoctorDetail($doctorId) { // 检查该医生是否有医生角色(role_id = 1) $hasRole = AdminRole::where('admin_id', $doctorId) ->where('role_id', 1) ->count() > 0; if (!$hasRole) { return null; } $doctor = Admin::where('id', $doctorId) ->where('disable', 0) ->field(['id', 'name', 'account', 'qualification_images','avatar','specialty','license_no','qualification_images','enable_image_consult','enable_video_consult','enable_charge']) ->find(); if (!$doctor) { return null; } $doctorData = $doctor->toArray(); // 统计患者数(已完成预约,去重) $patientIds = Appointment::where('doctor_id', $doctorId) ->where('status', 3) ->column('patient_id'); $patientCount = count(array_unique(array_filter($patientIds))); return [ 'id' => $doctorData['id'], 'name' => $doctorData['name'], 'account' => $doctorData['account'], 'avatar' => $doctorData['avatar'] ?? '', 'mobile' => $doctorData['mobile'] ?? '', 'email' => $doctorData['email'] ?? '', 'license_no' => $doctorData['license_no'] ?? '', 'qualification_images' => $doctorData['qualification_images'] ?? '', 'enable_image_consult' => $doctorData['enable_image_consult'] ?? 1, 'enable_video_consult' => $doctorData['enable_video_consult'] ?? 1, 'enable_charge' => $doctorData['enable_charge'] ?? 0, 'specialty' => '中医', 'title' => '主任医师', 'hospital' => '甄养堂互联网医院', 'experience' => '24年临床经验', 'rating' => '4.9', 'patient_count' => $patientCount, 'papers' => 15, 'about' => $doctorData['specialty'] ?? '擅长运用传统中医理论与现代诊断相结合,专注于慢性炎症及呼吸系统健康的调理。精通草本方剂,致力于为患者提供个性化的整体康复方案。', 'expertise' => [ ['icon' => 'psychiatry', 'title' => '草本药方', 'desc' => '为整体康复提供量身定制的草本处方。'], ['icon' => 'eco', 'title' => '草本药方', 'desc' => '为整体康复提供量身定制的草本处方。'], ['icon' => 'vital_signs', 'title' => '切脉诊断', 'desc' => '运用传统方法对全身平衡和器官健康进行深度触诊评估。', 'wide' => true], ], ]; } /** * @notes 获取医生评价列表 * @param int $doctorId * @param int $pageNo * @param int $pageSize * @return array */ public static function getDoctorReviews($doctorId, $pageNo = 1, $pageSize = 10) { $hasRole = AdminRole::where('admin_id', $doctorId) ->where('role_id', 1) ->count() > 0; if (!$hasRole) { return ['lists' => [], 'count' => 0]; } // 默认评价数据(后续可扩展为独立评价表) $defaultReviews = [ [ 'id' => 1, 'patient_initials' => 'JS', 'patient_name' => 'James S.', 'rating' => 5, 'content' => '李医生对我慢性疲劳的治疗改变了我的生活。他在建议方剂之前足足听我倾诉了45分钟。真是一位大师级的人物。', 'create_time' => '2天前', ], [ 'id' => 2, 'patient_initials' => 'ML', 'patient_name' => 'Mei Ling', 'rating' => 5, 'content' => '非常专业,知识渊博。针灸疗程显著缓解了我的偏头痛。非常推荐这家医院。', 'create_time' => '1周前', ], ]; $offset = ($pageNo - 1) * $pageSize; $lists = array_slice($defaultReviews, $offset, $pageSize); return [ 'lists' => $lists, 'count' => count($defaultReviews), 'page_no' => $pageNo, 'page_size' => $pageSize, ]; } /** * @notes 获取医生排班 * @param int $doctorId * @param string $date * @return array */ public static function getDoctorRoster($doctorId, $date) { // 检查该医生是否有医生角色 $hasRole = AdminRole::where('admin_id', $doctorId) ->where('role_id', 1) ->count() > 0; if (!$hasRole) { return []; } $rosters = Roster::where('doctor_id', $doctorId) ->where('date', $date) ->select() ->toArray(); return $rosters; } }