weizong song 5 years ago
parent a9f9da95dc
commit 0609f9a07b

@ -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) {

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdatePatientAddMobile extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table("patient", function (Blueprint $table) {
$table->string("mobile")->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
Loading…
Cancel
Save