diff --git a/app/Controller/DetectionController.php b/app/Controller/DetectionController.php index 47538d1..63b759d 100644 --- a/app/Controller/DetectionController.php +++ b/app/Controller/DetectionController.php @@ -54,7 +54,12 @@ class DetectionController extends AbstractController return $this->response->json($data); } - // 创建检测订单 + /** + * 创建检测订单 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ public function addDetectionOrder(): ResponseInterface { $request = $this->container->get(DetectionRequest::class); @@ -64,4 +69,20 @@ class DetectionController extends AbstractController $data = $detectionService->addDetectionOrder(); return $this->response->json($data); } + + /** + * 获取患者进行中的检测订单 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDetectionDoctorOrderFirst(): ResponseInterface + { + $request = $this->container->get(DetectionRequest::class); + $request->scene('getDetectionDoctorOrderFirst')->validateResolved(); + + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionDoctorOrderFirst(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Request/DetectionRequest.php b/app/Request/DetectionRequest.php index eccc0d4..c3329dc 100644 --- a/app/Request/DetectionRequest.php +++ b/app/Request/DetectionRequest.php @@ -21,6 +21,9 @@ class DetectionRequest extends FormRequest 'doctor_id', // 医生id 'client_type', // 客户端类型(1:手机 2:电脑) ], + 'getDetectionDoctorOrderFirst' => [ // 创建检测订单 + 'family_id', + ], ]; /** diff --git a/app/Services/DetectionService.php b/app/Services/DetectionService.php index b04ca59..0f2ebfa 100644 --- a/app/Services/DetectionService.php +++ b/app/Services/DetectionService.php @@ -470,6 +470,29 @@ class DetectionService extends BaseService return success($result); } + /** + * 获取患者进行中的检测订单 + * @return array + */ + public function getDetectionDoctorOrderFirst(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $family_id = $this->request->input("family_id"); + + // 检测是否存在同类型未完成的检测订单 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['family_id'] = $family_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)){ + return success(); + } + + return success($order_detection['order_detection_id']); + + } + /** * 取消未支付检测订单 * @param string|int $order_no 订单编号 diff --git a/config/routes.php b/config/routes.php index 7225f10..f753a31 100644 --- a/config/routes.php +++ b/config/routes.php @@ -275,6 +275,9 @@ Router::addGroup('/patient', function () { ] ); + // 获取患者进行中的检测订单 + Router::get('', [DetectionController::class, 'getDetectionDoctorOrderFirst']); + // 获取检测机构合作医生列表 Router::get('/doctor', [DetectionController::class, 'getDetectionDoctorList']);