title) { return $this->title; } return ' 确认发货   '; } /** * @param Model|Authenticatable|HasPermissions|null $user * * @return bool */ protected function authorize($user): bool { return $user->can('dcat.admin.dealer_orders.shipping'); } /** * Handle the action request. * * @param Request $request * * @return Response */ public function handle(Request $request) { $order = DealerOrder::findOrFail($this->getKey()); try { DB::beginTransaction(); (new OrderService())->shippingOrder($order); DB::commit(); } catch (QueryException $e) { DB::rollBack(); if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { $e = new BizException('当前可发货库存不足'); } return $this->response()->error('操作失败,'.$e->getMessage())->refresh(); } catch (Throwable $th) { DB::rollBack(); report($th); return $this->response()->error('操作失败,'.$th->getMessage())->refresh(); } return $this->response()->success('操作成功')->refresh(); } /** * @return string|array|void */ public function confirm() { return ['确认当前订单已发货?', '确认后将无法逆操作']; } }