From 20faf6f59ee69b21c52ed36093dc8f87d996f953 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Fri, 4 Aug 2023 11:30:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A3=80=E6=B5=8B=E8=AE=A2?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/PatientOrderController.php | 11 +++++++ app/Services/PatientOrderService.php | 38 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) 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(); + } + /** * 获取患者未完成订单