payload['id'] ?? null; DB::beginTransaction(); $order = DealerOrder::lockForUpdate()->findOrFail($id); if (! $order->isPay()) { throw new BizException('无法收款:订单状态异常,请刷新后再试'); } $order->update([ 'status' => DealerOrderStatus::Paying, 'pay_time' => null, ]); $order->refuseLogs()->create([ 'reason' => $input['reason'], ]); DB::commit(); } catch (Throwable $e) { DB::rollBack(); report($e); return $this->response()->error('操作失败,'.$e->getMessage())->refresh(); } return $this ->response() ->success('操作成功') ->refresh(); } /** * Build a form here. */ public function form() { $this->textarea('reason', '原因')->rules('required|max:255'); } /** * The data of the form. * * @return array */ public function default() { return [ 'reason' => '', ]; } }