weizong song 5 years ago
parent 023f54f282
commit 547431dc08

@ -550,7 +550,7 @@ class OrdersController extends CommonController
DB::beginTransaction();
try {
$order = Orders::with(["customer", "patient", "product", "productItem", "productParamedicLevel"])->find($id);
if (request()->paramedic_id && $order->paramedic_id && (request()->paramedic_id != $order->paramedic_id)) {
if ($order->isOngoing() && $order->paramedic_id != request()->paramedic_id) {
return response()->json([
"errorcode" => "103",
"errormsg" => "修改订单不包含护工更改,更换护工请移步"
@ -600,7 +600,7 @@ class OrdersController extends CommonController
$order->update($update);
//如果原本的护工id为空且新提交了护工id视同为派单
if (!$order->paramedic_id && request()->paramedic_id) {
if ($order->isPending && request()->paramedic_id) {
$order->update([
"paramedic_id" => request()->paramedic_id,
"status" => Orders::STATUS_ONGOING

@ -47,6 +47,16 @@ class Orders extends SoftDeletesModel
}
}
public function isPending()
{
return in_array($this->status, [self::STATUS_UNCONFIRMED, self::STATUS_UNASSIGNED]);
}
public function isOngoing()
{
return $this->status == self::STATUS_ONGOING;
}
public function getStatusNameAttribute()
{
return $this->getStatusLabelAttribute();

Loading…
Cancel
Save