From 6cb3cda74ba1726db0d95faf7dbf77659b7a3b25 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 13 Mar 2023 17:42:33 +0800 Subject: [PATCH] 1 --- app/Services/PatientOrderService.php | 36 ++++++++++++++++++++++++---- app/Services/UserDoctorService.php | 4 ++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index ea83aaa..1a7fc7f 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -11,6 +11,7 @@ use App\Model\OrderPrescription; use App\Model\OrderPrescriptionProduct; use App\Model\OrderProduct; use App\Model\OrderProductItem; +use App\Model\Product; use App\Model\UserDoctor; use App\Model\UserShipAddress; use Extend\Wechat\WechatPay; @@ -756,12 +757,37 @@ class PatientOrderService extends BaseService return fail(HttpEnumCode::HTTP_ERROR,"处方药品错误"); } - dump($order_prescription_product->toArray()); + // 检测药品是否存在,库存是否足够 + foreach ($order_prescription_product as $value){ + $params = array(); + $params['product_id'] = $value['product_id']; + $product = Product::getOne($params); + if (empty($product)){ + return fail(HttpEnumCode::HTTP_ERROR,"处方存在未知药品"); + } + } + + Db::beginTransaction(); + try { + // 新增药品订单 + $data = array(); + $data['order_inquiry_id'] = $order_prescription['order_inquiry_id']; + $data['order_prescription_id'] = $order_prescription['order_prescription_id']; + $data['doctor_id'] = $order_prescription['doctor_id']; + $data['patient_id'] = $order_prescription['patient_id']; + + // 新增药品订单详情 + // 修正处方使用状态 + // 新增取消订单队列 + + Db::commit(); + } catch (\Exception $e) { + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); + } + + - // 新增药品订单 - // 新增药品订单详情 - // 修正处方使用状态 - // 新增取消订单队列 return success(); } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 557d938..98f3cdc 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -1389,9 +1389,9 @@ class UserDoctorService extends BaseService return success(); } - $result = array(); + $result = []; foreach ($order_inquiry as $value){ - $result[$value['order_inquiry_id']] = $value; + $result[] = $value; } return success($result);