|
|
|
|
@ -401,7 +401,7 @@ class OrdersController extends CommonController
|
|
|
|
|
$has_orders = Orders::where("customer_id", $customer->id)->whereIn("status", [Orders::STATUS_UNCONFIRMED, Orders::STATUS_UNASSIGNED, Orders::STATUS_ONGOING])->count();
|
|
|
|
|
if ($has_orders) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => "0",
|
|
|
|
|
"errorcode" => "101",
|
|
|
|
|
"errormsg" => "客户名下有即将开始或正在进行中的订单,暂不可以再次下单"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
@ -415,7 +415,7 @@ class OrdersController extends CommonController
|
|
|
|
|
$price += collect($factors)->sum("price");
|
|
|
|
|
if (request()->price < $price) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => "0",
|
|
|
|
|
"errorcode" => "102",
|
|
|
|
|
"errormsg" => "协商价格不能低于系统指导价"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
@ -464,6 +464,91 @@ class OrdersController extends CommonController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\POST(
|
|
|
|
|
* path="/manager/update-order/{id}",
|
|
|
|
|
* summary="V2-订单修改(静态修改不影响当前所有子订单)",
|
|
|
|
|
* description="订单修改",
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @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="paramedic_id", in="query", @OA\Schema(type="integer"), required=false, description="护工id"),
|
|
|
|
|
* @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="协商价格"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="订单修改"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function updateOrder($id)
|
|
|
|
|
{
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
$order = Orders::with(["customer", "patient", "product", "productItem", "productParamedicLevel"])->find($id);
|
|
|
|
|
if (request()->has("paramedic_id")) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => "103",
|
|
|
|
|
"errormsg" => "修改订单不包含护工更改,更换护工请移步"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$product_paramedic_level = request()->has("product_paramedic_level_id") ? (new ProductParamedicLevel())->find(request()->product_paramedic_level_id) : $order->productParamedicLevel;
|
|
|
|
|
$product_item = request()->has("product_item_id") ? (new ProductItems())->find(request()->product_item_id) : $order->productItem;
|
|
|
|
|
$price = $product_item->price + $product_paramedic_level->price;
|
|
|
|
|
$factors = request()->has("factors") ? (new Orders())->requestFactorsToOrderFactors() : json_decode($order->factors);
|
|
|
|
|
$price += collect($factors)->sum("price");
|
|
|
|
|
|
|
|
|
|
if (request()->has("price") && request()->price < $price) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => "102",
|
|
|
|
|
"errormsg" => "协商价格不能低于系统指导价"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新被陪护人
|
|
|
|
|
if (request()->has("patient_name", "patient_mobile", "patient_sex", "patient_age")) {
|
|
|
|
|
$order->patient->update([
|
|
|
|
|
"name" => request()->patient_name,
|
|
|
|
|
"age" => request()->patient_age,
|
|
|
|
|
"sex" => request()->patient_sex,
|
|
|
|
|
"mobile" => request()->patient_mobile,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新订单
|
|
|
|
|
$update = (new Orders())->filterRequestColumns(request(), ["id"]);
|
|
|
|
|
if (request()->has("contact", "patient_name") && !request()->contact) {
|
|
|
|
|
$update["contact"] = request()->patient_name;
|
|
|
|
|
}
|
|
|
|
|
if (request()->has("mobile", "patient_mobile") && !request()->mobile) {
|
|
|
|
|
$update["mobile"] = request()->patient_mobile;
|
|
|
|
|
}
|
|
|
|
|
if (request()->has("factors")) {
|
|
|
|
|
$update["factors"] = $factors;
|
|
|
|
|
}
|
|
|
|
|
$order->update($update);
|
|
|
|
|
DB::commit();
|
|
|
|
|
return response()->json($order->toArray());
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => $exception->getCode(),
|
|
|
|
|
"errormsg" => $exception->getMessage()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\POST(
|
|
|
|
|
* path="/manager/scan-pay/{order_id}",
|
|
|
|
|
|