|
|
|
|
@ -10,6 +10,7 @@ use App\Libs\WxMicroPay;
|
|
|
|
|
use App\Models\Area;
|
|
|
|
|
use App\Models\Balance;
|
|
|
|
|
use App\Models\Bed;
|
|
|
|
|
use App\Models\OrderItems;
|
|
|
|
|
use App\Models\Orders;
|
|
|
|
|
use App\Models\ParamedicLevel;
|
|
|
|
|
use App\Models\Patient;
|
|
|
|
|
@ -549,6 +550,60 @@ class OrdersController extends CommonController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\POST(
|
|
|
|
|
* path="/manager/update-order-items",
|
|
|
|
|
* summary="V2-子订单修改(覆盖单条修改)",
|
|
|
|
|
* description="子订单修改",
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Parameter(name="ids", in="query", @OA\Schema(type="integer"), required=true, description="子订单id,可传单个id或数组"),
|
|
|
|
|
* @OA\Parameter(name="bed_id", in="query", @OA\Schema(type="integer"), required=false, description="床位id"),
|
|
|
|
|
* @OA\Parameter(name="paramedic_id", in="query", @OA\Schema(type="integer"), required=false, description="护工id"),
|
|
|
|
|
* @OA\Parameter(name="price", in="query", @OA\Schema(type="integer"), required=false, description="价格"),
|
|
|
|
|
* @OA\Parameter(name="skip_warnings", in="query", @OA\Schema(type="integer"), required=false, description="跳过警示项目"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="子订单修改"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function updateOrderItems(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$order_items = (new OrderItems())->whereHas("order")->whereIn("id", (array)$request->ids)->get();
|
|
|
|
|
if ($request->has("price")) {
|
|
|
|
|
$warnings = [];
|
|
|
|
|
$errors = [];
|
|
|
|
|
}
|
|
|
|
|
if (count($errors)) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => "105",
|
|
|
|
|
"errormsg" => implode(",", $errors)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
if (count($errors) && !$request->skip_warnings) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"has_warnings" => true,
|
|
|
|
|
"errormsg" => implode(",", $warnings)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
foreach ($order_items as $order_item) {
|
|
|
|
|
//todo
|
|
|
|
|
}
|
|
|
|
|
DB::commit();
|
|
|
|
|
return response()->json(["errormsg" => "OK"]);
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => $exception->getCode(),
|
|
|
|
|
"errormsg" => $exception->getMessage()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\POST(
|
|
|
|
|
* path="/manager/scan-pay/{order_id}",
|
|
|
|
|
@ -604,30 +659,23 @@ class OrdersController extends CommonController
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\POST(
|
|
|
|
|
* path="/manager/confirm-order/{id}",
|
|
|
|
|
* summary="确认订单",
|
|
|
|
|
* description="确认订单",
|
|
|
|
|
* path="/manager/assign-order/{id}",
|
|
|
|
|
* summary="V2-派单",
|
|
|
|
|
* description="派单",
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Parameter(name="id", in="path", @OA\Schema(type="integer"), required=true, description="订单id"),
|
|
|
|
|
* @OA\Parameter(name="bed_id", in="query", @OA\Schema(type="integer"), required=true, description="床位id"),
|
|
|
|
|
* @OA\Parameter(name="price", in="query", @OA\Schema(type="number"), required=true, description="价格"),
|
|
|
|
|
* @OA\Parameter(name="from_date", in="query", @OA\Schema(type="date"), required=true, description="开始日期"),
|
|
|
|
|
* @OA\Parameter(name="to_date", in="query", @OA\Schema(type="date"), required=true, description="预计结束日期"),
|
|
|
|
|
* @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="patient_quantity", in="query", @OA\Schema(type="integer"), required=true, description="护理人数"),
|
|
|
|
|
* @OA\Parameter(name="auto_checkout", in="query", @OA\Schema(type="integer"), required=false, description="是否自动结算"),
|
|
|
|
|
* @OA\Parameter(name="paramedic_id", in="query", @OA\Schema(type="integer"), required=true, description="护工id"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="确认订单"
|
|
|
|
|
* description="派单"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function confirmOrder($id)
|
|
|
|
|
public function assignOrder($id)
|
|
|
|
|
{
|
|
|
|
|
$order = (new Orders())->with("firstItem")->find($id);
|
|
|
|
|
if ($order->status !== Orders::STATUS_UNCONFIRMED) {
|
|
|
|
|
$order = (new Orders())->find($id);
|
|
|
|
|
if ($order->status !== Orders::STATUS_UNCONFIRMED || $order->status !== Orders::STATUS_UNASSIGNED) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => 50001,
|
|
|
|
|
"errormsg" => "订单状态不适配"
|
|
|
|
|
@ -636,25 +684,11 @@ class OrdersController extends CommonController
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
$dirty = [];
|
|
|
|
|
|
|
|
|
|
foreach (request()->all() as $k => $v) {
|
|
|
|
|
if ($k == "factors") continue;
|
|
|
|
|
if ($order->{$k} && $order->{$k} != $v) {
|
|
|
|
|
$dirty[$k] = $v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//单独处理factors
|
|
|
|
|
if ($order->determineOrderFactorsIsDirty()) {
|
|
|
|
|
$factors = (new Orders())->requestFactorsToOrderFactors();
|
|
|
|
|
$dirty["factors"] = json_encode($factors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dirty["status"] = Orders::STATUS_UNASSIGNED;
|
|
|
|
|
$dirty["manager_id"] = $this->manager->id;
|
|
|
|
|
|
|
|
|
|
$order->update($dirty);
|
|
|
|
|
$order->update([
|
|
|
|
|
"paramedic_id" => request()->paramedic_id,
|
|
|
|
|
"status" => Orders::STATUS_ONGOING
|
|
|
|
|
]);
|
|
|
|
|
event(new OrderAssigned($order));
|
|
|
|
|
DB::commit();
|
|
|
|
|
return response()->json($order);
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
|