From 66dd47c3b33c0e02edff25c6bb987a56b9cb95f1 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 13 Apr 2023 18:06:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/PatientOrderController.php | 11 +++++ app/Services/PatientOrderService.php | 53 +++++++++++++++++++++++ config/routes.php | 3 ++ 3 files changed, 67 insertions(+) diff --git a/app/Controller/PatientOrderController.php b/app/Controller/PatientOrderController.php index 6f10f1d..324bad8 100644 --- a/app/Controller/PatientOrderController.php +++ b/app/Controller/PatientOrderController.php @@ -175,6 +175,17 @@ class PatientOrderController extends AbstractController return $this->response->json($data); } + /** + * 获取药品订单物流数据 + * @return ResponseInterface + */ + public function getPatientProductOrderLogistics(): ResponseInterface + { + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->getPatientProductOrderLogistics(); + return $this->response->json($data); + } + /** * 获取处方订单列表 * @return ResponseInterface diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index faa1141..2aab9fc 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -13,6 +13,7 @@ use App\Model\OrderPrescription; use App\Model\OrderPrescriptionProduct; use App\Model\OrderProduct; use App\Model\OrderProductItem; +use App\Model\OrderProductLogistic; use App\Model\PatientFollow; use App\Model\Product; use App\Model\ProductPlatformAmount; @@ -1079,6 +1080,58 @@ class PatientOrderService extends BaseService return success($result); } + /** + * 获取药品订单物流数据 + * @return array + */ + public function getPatientProductOrderLogistics(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_product_id = $this->request->route('order_product_id'); + + // 获取药品订单数据 + $params = array(); + $params['order_product_id'] = $order_product_id; + $params['patient_id'] = $user_info['client_user_id']; + $order_product = OrderProduct::getOne($params); + if (empty($order_product)){ + return fail(); + } + + // 获取物流数据 + $params = array(); + $params['order_product_id'] = $order_product_id; + $order_product_logistics = OrderProductLogistic::getOne($params); + if (empty($order_product_logistics)){ + return success(null); + } + + $order_product_logistics = $order_product_logistics->toArray(); + + $order_product_logistics['logistics_content'] = json_decode($order_product_logistics['logistics_content'],true); + + // 地址数据 + $address = array(); + $address['province_id'] = $order_product['province_id']; + $address['province'] = $order_product['province']; + $address['city_id'] = $order_product['city_id']; + $address['city'] = $order_product['city']; + $address['county_id'] = $order_product['county_id']; + $address['county'] = $order_product['county']; + $address['address'] = $order_product['address']; + $address['address_mask'] = $order_product['address_mask']; + $address['consignee_name'] = $order_product['consignee_name']; + $address['consignee_name_mask'] = $order_product['consignee_name_mask']; + $address['consignee_tel'] = $order_product['consignee_tel']; + $address['consignee_tel_mask'] = $order_product['consignee_tel_mask']; + + $result = array(); + $result['logistics'] = $order_product_logistics; + $result['address'] = $address; + + return success($result); + } /** * 获取处方订单列表 * @return array diff --git a/config/routes.php b/config/routes.php index 165d61c..641b9a1 100644 --- a/config/routes.php +++ b/config/routes.php @@ -381,6 +381,9 @@ Router::addGroup('/patient', function () { // 创建药品订单 Router::post('', [PatientOrderController::class, 'addPatientProductOrder']); + + // 获取药品订单物流数据 + Router::get('/logistics/{order_product_id:\d+}', [PatientOrderController::class, 'getPatientProductOrderLogistics']); }); // 处方订单