From 0609f9a07b529218bf28c8509e0027e784e7eedf Mon Sep 17 00:00:00 2001 From: weizong song Date: Sun, 4 Apr 2021 15:38:06 +0800 Subject: [PATCH] up --- .../Controllers/Manager/OrdersController.php | 41 +++++++++++-------- ...04_04_152542_update_patient_add_mobile.php | 30 ++++++++++++++ 2 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 database/migrations/2021_04_04_152542_update_patient_add_mobile.php diff --git a/app/Http/Controllers/Manager/OrdersController.php b/app/Http/Controllers/Manager/OrdersController.php index d706741..2cb389c 100644 --- a/app/Http/Controllers/Manager/OrdersController.php +++ b/app/Http/Controllers/Manager/OrdersController.php @@ -371,7 +371,7 @@ class OrdersController extends CommonController /** * @OA\POST( * path="/manager/create-patient", - * summary="创建被护理人", + * summary="V2-创建被护理人", * description="创建被护理人", * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Parameter(name="name", in="query", @OA\Schema(type="string"), required=true, description="姓名"), @@ -398,20 +398,21 @@ class OrdersController extends CommonController /** * @OA\POST( * path="/manager/create-order", - * summary="创建订单", + * summary="V2-创建订单", * description="创建订单", * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), - * @OA\Parameter(name="project_id", in="query", @OA\Schema(type="integer"), required=true, description="医院/项目id"), * @OA\Parameter(name="product_id", in="query", @OA\Schema(type="integer"), required=true, description="产品id"), * @OA\Parameter(name="product_item_id", in="query", @OA\Schema(type="integer"), required=true, description="产品型号id"), * @OA\Parameter(name="product_paramedic_level_id", in="query", @OA\Schema(type="integer"), required=true, description="产品-护工等级id"), * @OA\Parameter(name="factors", in="query", @OA\Schema(type="object"), required=true, description="价格因子选择,[{id:1,factor_item_id:1},{...}],如果为空数组请传[]"), * @OA\Parameter(name="bed_id", in="query", @OA\Schema(type="integer"), required=true, description="床位id"), - * @OA\Parameter(name="patient_id", in="query", @OA\Schema(type="integer"), required=true, description="被看护人id"), * @OA\Parameter(name="paramedic_id", in="query", @OA\Schema(type="integer"), required=false, description="护工id"), - * @OA\Parameter(name="contact", in="query", @OA\Schema(type="string"), required=true, description="联系人"), - * @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=true, description="联系人电话"), - * @OA\Parameter(name="remark", in="query", @OA\Schema(type="string"), required=false, description="备注"), + * @OA\Parameter(name="patient_name", in="query", @OA\Schema(type="string"), required=true, description="被护理人姓名"), + * @OA\Parameter(name="patient_mobile", in="query", @OA\Schema(type="string"), required=true, description="被护理人电话"), + * @OA\Parameter(name="patient_sex", in="query", @OA\Schema(type="string"), required=true, description="被护理人性别:男,女"), + * @OA\Parameter(name="patient_age", in="query", @OA\Schema(type="string"), required=true, description="被护理人年龄"), + * @OA\Parameter(name="contact", in="query", @OA\Schema(type="string"), required=false, description="联系人"), + * @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=false, description="联系人电话"), * @OA\Parameter(name="from_date", in="query", @OA\Schema(type="string"), required=true, description="开始日期"), * @OA\Parameter(name="to_date", in="query", @OA\Schema(type="string"), required=true, description="结束日期"), * @OA\Parameter(name="price", in="query", @OA\Schema(type="number"), required=true, description="协商价格"), @@ -437,6 +438,7 @@ class OrdersController extends CommonController ]); } + $product = (new Product())->find(request()->product_id); $product_paramedic_level = (new ProductParamedicLevel())->find(request()->product_paramedic_level_id); $product_item = (new ProductItems())->find(request()->product_item_id); $price = $product_item->price + $product_paramedic_level->price; @@ -450,32 +452,35 @@ class OrdersController extends CommonController ]); } + $patient = (new Patient())->firsrOrCreate([ + "customer_id" => $customer->id, + "name" => request()->patient_mobile + ]); + $patient->update([ + "age" => request()->patient_age, + "sex" => request()->patient_sex, + ]); + $order = (new Orders())->create([ "customer_id" => $customer->id, - "project_id" => request()->project_id, + "project_id" => $product->id, "product_id" => request()->product_id, - "patient_id" => request()->patient_id, - "contact" => request()->contact, - "mobile" => request()->mobile, + "patient_id" => $patient->id, + "contact" => request()->contact ?? request()->patient_name, + "mobile" => request()->mobile ?? request()->patient_mobile, "from_date" => request()->from_date, "to_date" => request()->to_date, - "remark" => request()->remark, "product_item_id" => request()->product_item_id, "product_paramedic_level_id" => request()->product_paramedic_level_id, "bed_id" => request()->bed_id, "paramedic_id" => request()->paramedic_id, "price" => request()->price, "factors" => json_encode($factors), - - "status" => Orders::STATUS_UNASSIGNED, + "status" => request()->paramedic_id ? Orders::STATUS_ONGOING : Orders::STATUS_UNASSIGNED, "manager_id" => $this->manager->id ]); $order->getSerial(); - - (new Patient())->find(request()->patient_id)->update([ - "customer_id" => $customer->id - ]); DB::commit(); return $this->getOrder($order->id); } catch (\Exception $exception) { diff --git a/database/migrations/2021_04_04_152542_update_patient_add_mobile.php b/database/migrations/2021_04_04_152542_update_patient_add_mobile.php new file mode 100644 index 0000000..6b61b92 --- /dev/null +++ b/database/migrations/2021_04_04_152542_update_patient_add_mobile.php @@ -0,0 +1,30 @@ +string("mobile")->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}