diff --git a/app/Controller/PatientOrderController.php b/app/Controller/PatientOrderController.php index d6b7be9..c446f31 100644 --- a/app/Controller/PatientOrderController.php +++ b/app/Controller/PatientOrderController.php @@ -263,4 +263,15 @@ class PatientOrderController extends AbstractController $data = $PatientOrderService->getPatientDetectionOrderInfo(); return $this->response->json($data); } + + /** + * 删除检测订单 + * @return ResponseInterface + */ + public function deletePatientDetectionOrder(): ResponseInterface + { + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->deletePatientDetectionOrder(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index 7f61c16..761bed5 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -1742,6 +1742,44 @@ class PatientOrderService extends BaseService return success($order_detection); } + /** + * 删除检测订单 + * @return array + */ + public function deletePatientDetectionOrder(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_detection_id = $this->request->route('order_detection_id'); + + // 获取订单数据 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['order_detection_id'] = $order_detection_id; + $params['is_delete'] = 0; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + return fail(); + } + + // 检测订单状态 + if (!in_array($order_detection['detection_status'], [5])) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + return fail(HttpEnumCode::HTTP_ERROR, "订单无法删除"); + } + + // 修改订单删除状态 + $data = array(); + $data['is_delete'] = 1; + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + + OrderDetection::editOrderDetection($params, $data); + + return success(); + } + /** * 获取患者未完成订单