From 9ed40a41c03a6aceeb8c09fbcb72848037edf703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=90=A6?= Date: Mon, 13 Jul 2026 14:34:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=8C=BB=E7=94=9F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=8C=BB=E7=94=9F=202.=20=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=88=86=E8=B4=A6=E9=93=BE=E8=B7=AF=E7=9A=84=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=203.=20=E5=87=8F=E5=B0=91=E9=A6=96=E9=A1=B5=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=95=B0=E6=8D=AE=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1/controllers/DoctorController.php | 2 + .../v1/controllers/ProductOrderController.php | 55 ++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/member/modules/v1/controllers/DoctorController.php b/member/modules/v1/controllers/DoctorController.php index 39a5440..fe11366 100644 --- a/member/modules/v1/controllers/DoctorController.php +++ b/member/modules/v1/controllers/DoctorController.php @@ -85,6 +85,8 @@ class DoctorController extends BaseAppController $query->joinWith(['docInfo' => function ($q) use ($id, $keyword, $depart_arr, $title_arr) { $q->alias('i'); + // 患者端列表不展示测试医生 + $q->andWhere(['i.is_test' => 0]); //搜索框搜索姓名和科室 if (!empty($keyword)) { $q->andWhere([ diff --git a/member/modules/v1/controllers/ProductOrderController.php b/member/modules/v1/controllers/ProductOrderController.php index 4bfe2c9..0ae44e7 100644 --- a/member/modules/v1/controllers/ProductOrderController.php +++ b/member/modules/v1/controllers/ProductOrderController.php @@ -21,6 +21,7 @@ use common\models\oldDb\ServicePackageRepice; use common\models\oldDb\Store; use common\models\oldDb\SystemConfig; use common\models\oldDb\User; +use common\models\oldDb\UserPatient; use common\models\oldDb\WestRepice; use common\modelsgii\oldDb\RefundReason; use common\services\ExpressService; @@ -151,7 +152,7 @@ class ProductOrderController extends BaseAppController $this->requestValidate($post, [ ['prescription_id', 'required'] ]); - $ProductOrder = ProductOrder::find()->select('id,order_no,is_online,su_id,p_id,user_id,is_pay,prescription_type,address_id,address,decoct_price,order_type,items_price,process_price,treatement_price,total_pay_price,pay_method,trans_expenses,created_at,received_time,cancel_status,refund_status,status')->where([ + $ProductOrder = ProductOrder::find()->select('id,order_no,is_online,su_id,p_id,up_id,user_id,is_pay,prescription_type,address_id,address,decoct_price,order_type,items_price,process_price,treatement_price,total_pay_price,pay_method,trans_expenses,created_at,received_time,cancel_status,refund_status,status')->where([ 'p_id' => $post['prescription_id'], 'user_id' => \Yii::$app->user->identity->getId(), // 'store_id' => $post['store_id'] @@ -249,6 +250,7 @@ class ProductOrderController extends BaseAppController 'chinese' => $chinese ?? null, 'granular' => $granular ?? null, 'store' => $prescriptionStore ? ['store' => $prescriptionStore] : null, + 'patient' => $this->getOrderPatientInfo((int) ($ProductOrder['up_id'] ?? 0), (int) ($ProductOrder['p_id'] ?? 0)), ]; } @@ -406,7 +408,7 @@ class ProductOrderController extends BaseAppController $this->requestValidate($post, [ ['order_id', 'required'] ]); - $ProductOrder = ProductOrder::find()->select('id,store_id,is_online,order_no,delivery_method,su_id,p_id,user_id,is_pay,prescription_type,address_id,address,decoct_price,items_price,process_price,treatement_price,total_pay_price,pay_method,trans_expenses,created_at,cancel_status,refund_status,status,pay_time')->where([ + $ProductOrder = ProductOrder::find()->select('id,store_id,is_online,order_no,delivery_method,su_id,p_id,up_id,user_id,is_pay,prescription_type,address_id,address,decoct_price,items_price,process_price,treatement_price,total_pay_price,pay_method,trans_expenses,created_at,cancel_status,refund_status,status,pay_time')->where([ 'id' => $post['order_id'], 'user_id' => \Yii::$app->user->identity->getId(), // 'store_id' => $post['store_id'] @@ -457,6 +459,7 @@ class ProductOrderController extends BaseAppController 'hospital' => $hospital, 'ProductOrderItems' => $ProductOrderItems, 'store' => $prescriptionStore ? ['store' => $prescriptionStore] : null, + 'patient' => $this->getOrderPatientInfo((int) ($ProductOrder['up_id'] ?? 0), (int) ($ProductOrder['p_id'] ?? 0)), ]; } @@ -593,4 +596,52 @@ class ProductOrderController extends BaseAppController return $express; } + /** + * 获取产品订单关联的就诊人信息 + * 优先订单 up_id,其次处方 up_id,最后从处方 content 兜底(兼容历史数据) + * + * @param int $upId 订单就诊人 id + * @param int $prescriptionId 处方 id + * @return array|null + */ + private function getOrderPatientInfo(int $upId, int $prescriptionId = 0): ?array + { + $patientUpId = $upId; + $prescription = null; + + if (!$patientUpId && $prescriptionId > 0) { + $prescription = Prescription::find()->select('up_id,content')->where(['id' => $prescriptionId])->asArray()->one(); + if ($prescription && !empty($prescription['up_id'])) { + $patientUpId = (int) $prescription['up_id']; + } + } + + if ($patientUpId > 0) { + $patient = UserPatient::find()->select('id,name,mobile')->where([ + 'id' => $patientUpId, + 'is_delete' => 0, + ])->asArray()->one(); + if ($patient) { + return $patient; + } + } + + if (!$prescription && $prescriptionId > 0) { + $prescription = Prescription::find()->select('content')->where(['id' => $prescriptionId])->asArray()->one(); + } + + if ($prescription && !empty($prescription['content'])) { + $content = Json::decode($prescription['content']); + if (!empty($content['patient']['name'])) { + return [ + 'id' => (int) ($content['patient']['id'] ?? 0), + 'name' => $content['patient']['name'], + 'mobile' => $content['patient']['mobile'] ?? '', + ]; + } + } + + return null; + } + } \ No newline at end of file