diff --git a/app/Jobs/WorkOrder/WorkOrder.php b/app/Jobs/WorkOrder/WorkOrder.php index 3f58e16..722b513 100644 --- a/app/Jobs/WorkOrder/WorkOrder.php +++ b/app/Jobs/WorkOrder/WorkOrder.php @@ -47,17 +47,17 @@ public function handle(): void if ($this->type == 'post') { $response = $this->workOrder->module->http()->post('work-orders', $this->workOrder->toArray()); - } elseif ($this->type == 'put') { - $response = $this->workOrder->module->http()->put('work-orders/'.$this->workOrder->id, $this->workOrder->toArray()); + } else if ($this->type == 'put') { + $response = $this->workOrder->module->http()->put('work-orders/' . $this->workOrder->id, $this->workOrder->toArray()); } else { - $response = $this->workOrder->module->http()->delete('work-orders/'.$this->workOrder->id); + $response = $this->workOrder->module->http()->delete('work-orders/' . $this->workOrder->id); if ($response->successful()) { $this->workOrder->delete(); } } - if (! $response->successful()) { + if (!$response->successful()) { Log::debug('WorkOrder push failed', [ 'type' => $this->type, 'response' => $response->json(), diff --git a/app/Models/WorkOrder/WorkOrder.php b/app/Models/WorkOrder/WorkOrder.php index 275e2eb..c2f9600 100644 --- a/app/Models/WorkOrder/WorkOrder.php +++ b/app/Models/WorkOrder/WorkOrder.php @@ -150,8 +150,11 @@ public function safeDelete(): bool throw new CommonException('工单状态是 pending,无法删除'); } - dispatch(new WorkOrderJob($this, 'delete')); - + if ($this->isPlatform()) { + $this->delete(); + } else { + dispatch(new WorkOrderJob($this, 'delete')); + } return true; }