From 2e56ddf7008648650a6b575e40a7fc8990e137d0 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Tue, 18 Apr 2023 13:43:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=93=E5=AE=B6=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=9C=8D=E5=8A=A1=E5=A4=A9=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/PatientHistoryInquiry.php | 11 +++++++++++ app/Services/InquiryService.php | 7 +++++++ app/Services/PatientDoctorService.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Model/PatientHistoryInquiry.php b/app/Model/PatientHistoryInquiry.php index 8f7f176..81bba8b 100644 --- a/app/Model/PatientHistoryInquiry.php +++ b/app/Model/PatientHistoryInquiry.php @@ -86,6 +86,17 @@ class PatientHistoryInquiry extends Model return self::where($params)->first($fields); } + /** + * 获取信息-单条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getOrderOne(array $params, array $fields = ['*']): object|null + { + return self::where($params)->orderBy('created_at','desc')->first($fields); + } + /** * 获取信息-多条 * @param array $params diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index f412ff8..a460b70 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -117,6 +117,13 @@ class InquiryService extends BaseService if ($doctor['iden_auth_status'] != 1) { return fail(HttpEnumCode::HTTP_ERROR, "当前医生无法接诊,请重新选择"); } + + // 检测当前医生是否和患者存在未完成问诊订单 + $InquiryService = new InquiryService(); + $order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($user_info['client_user_id'],$request_params['doctor_id']); + if (!empty($order_inquiry)){ + return fail(HttpEnumCode::HTTP_ERROR, "您和当前医生存在问诊中订单,无法再次发起问诊"); + } } // 检测当前是否符合系统问诊时间 diff --git a/app/Services/PatientDoctorService.php b/app/Services/PatientDoctorService.php index b28a9b0..6a378d2 100644 --- a/app/Services/PatientDoctorService.php +++ b/app/Services/PatientDoctorService.php @@ -223,7 +223,7 @@ class PatientDoctorService extends BaseService $params['patient_id'] = $user_info['client_user_id']; $params['doctor_id'] = $doctor_id; $params['history_status'] = 1; - $patient_history_doctor = PatientHistoryInquiryModel::getOne($params); + $patient_history_doctor = PatientHistoryInquiryModel::getOrderOne($params); // 按照天来计算,当日为1,前一天为2 未服务过为0 if (!empty($patient_history_doctor['created_at'])) { $result['days'] = ceil((strtotime(date('Y-m-d', strtotime('+1 day'))) - strtotime($patient_history_doctor['created_at'])) / 86400);