From 226e3530b6158e09a9240f42369abeb697dee003 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Fri, 5 May 2023 10:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/PatientHistoryInquiry.php | 11 ++++++++ app/Services/IndexService.php | 10 +++---- app/Services/PatientDoctorService.php | 40 +++++++++++++++++++-------- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/app/Model/PatientHistoryInquiry.php b/app/Model/PatientHistoryInquiry.php index 81bba8b..27cc20b 100644 --- a/app/Model/PatientHistoryInquiry.php +++ b/app/Model/PatientHistoryInquiry.php @@ -156,6 +156,17 @@ class PatientHistoryInquiry extends Model } + /** + * 获取信息-多条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getListOrder(array $params, array $fields = ['*']): object|null + { + return self::where($params)->orderBy('created_at','desc')->get($fields); + } + /** * 修改 * @param array $params diff --git a/app/Services/IndexService.php b/app/Services/IndexService.php index 374f1f8..8c9630c 100644 --- a/app/Services/IndexService.php +++ b/app/Services/IndexService.php @@ -177,11 +177,11 @@ class IndexService extends BaseService defer(function() use ($wg) { $wg->done(); }); -// $PatientDoctorService = new PatientDoctorService(); -// -// if (!empty($user_info)) { -// $my_doctor = $PatientDoctorService->getIndexPatientDoctorLimit($user_info['client_user_id']); -// } + $PatientDoctorService = new PatientDoctorService(); + + if (!empty($user_info)) { + $my_doctor = $PatientDoctorService->getIndexPatientDoctorLimit($user_info['client_user_id']); + } }); // 推荐医生 diff --git a/app/Services/PatientDoctorService.php b/app/Services/PatientDoctorService.php index bbefb06..bb94e67 100644 --- a/app/Services/PatientDoctorService.php +++ b/app/Services/PatientDoctorService.php @@ -758,11 +758,11 @@ class PatientDoctorService extends BaseService $params = array(); $params['patient_id'] = $patient_id; $params['history_status'] = 1; - $patient_history_doctors = PatientHistoryInquiryModel::getIndexHistoryDoctorList($params); + $patient_history_doctors = PatientHistoryInquiryModel::getListOrder($params); if (!empty($patient_history_doctors)) { foreach ($patient_history_doctors as $patient_history_doctor) { - if (empty($patient_history_doctor['userDoctor'])) { - continue; + if (count($results) >= 5){ + break; } foreach ($results as $item){ @@ -771,17 +771,33 @@ class PatientDoctorService extends BaseService } } - // 组合数据 - $data = array(); - $data['doctor_id'] = $patient_history_doctor['userDoctor']['doctor_id']; - $data['user_name'] = $patient_history_doctor['userDoctor']['user_name']; - $data['avatar'] = addAliyunOssWebsite($patient_history_doctor['userDoctor']['avatar']); - $data['hospital_name'] = ""; - if (!empty($patient_history_doctor['userDoctor']['Hospital'])) { - $data['hospital_name'] = $patient_history_doctor['userDoctor']['Hospital']['hospital_name']; + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $patient_history_doctor['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + continue; } - $data['doctor_title'] = empty($patient_history_doctor['userDoctor']['doctor_title']) ? "" : DoctorTitleCode::getMessage($patient_history_doctor['userDoctor']['doctor_title']); + // 获取医生医院 + $hospital_name = ""; + if (!empty($user_doctor['hospital_id'])){ + $params = array(); + $params['hospital_id'] = $user_doctor['hospital_id']; + $hospital = Hospital::getOne($params); + if (!empty($hospital)){ + $hospital_name = $hospital['hospital_name']; + } + } + + // 组合数据 + $data = array(); + $data['doctor_id'] = $user_doctor['doctor_id']; + $data['user_name'] = $user_doctor['user_name']; + $data['avatar'] = addAliyunOssWebsite($user_doctor['avatar']); + $data['hospital_name'] = $hospital_name; + + $data['doctor_title'] = empty($user_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($user_doctor['doctor_title']); // 按照天来计算,当日为1,前一天为2 未服务过为0 if (empty($patient_history_doctor['created_at'])) {