argument('user_id'); $amount = $this->argument('amount'); // find user $user = User::findOrFail($user_id); $balance = new Balance(); $this->info($user->name . ', 当前余额: ' . $user->balance . ' 元'); $this->info('充值后余额: ' . ($user->balance + $amount) . ' 元'); if (!$this->confirm('确认充值 ' . $amount . ' 元?')) { $this->info('已取消。'); return; } $data = [ 'user_id' => $user->id, 'amount' => $amount, 'payment' => 'console', ]; $balance = $balance->create($data); $transaction = new Transaction(); $description = '控制台充值 ' . $amount . ' 元'; try { $transaction->addAmount($user->id, 'console', $amount, $description); $this->info('充值成功。'); $user->refresh(); $this->info($user->name . ', 当前余额: ' . $user->balance); } catch (ChargeException $e) { return $this->error($e->getMessage()); } } }