增加 Get User
This commit is contained in:
parent
02adec44bf
commit
e2202c3e17
82
app/Console/Commands/GetUser.php
Normal file
82
app/Console/Commands/GetUser.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Host;
|
||||
use App\Models\User;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\User\Balance;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class GetUser extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user {id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '获取一个用户的信息,交易记录,余额,主机,服务器,工单。';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
$id = $this->argument('id');
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
$transaction = new Transaction();
|
||||
|
||||
$drops = $transaction->getDrops($id);
|
||||
|
||||
|
||||
$this->warn('用户基本信息');
|
||||
|
||||
$this->info('用户 ID: ' . $id);
|
||||
$this->info('名称: ' . $user->name);
|
||||
$this->info('邮箱: ' . $user->email);
|
||||
$this->info('余额:' . $user->balance . ' 元');
|
||||
|
||||
$this->info('Drops:' . $drops);
|
||||
|
||||
|
||||
$this->warn('前 10 条充值记录');
|
||||
|
||||
$balances = Balance::where('user_id', $user->id)->whereNotNull('paid_at')->latest()->limit(10)->get();
|
||||
|
||||
// 倒序输出
|
||||
foreach (array_reverse($balances->toArray()) as $balance) {
|
||||
$this->info('[' . $balance['paid_at'] . '] 支付方式: ' . $balance['payment'] . ' 金额:' . $balance['amount'] . ' 元');
|
||||
}
|
||||
|
||||
$this->warn('前 10 个主机');
|
||||
|
||||
$hosts = Host::where('user_id', $user->id)->with('module')->latest()->limit(10)->get();
|
||||
|
||||
// 倒序
|
||||
foreach (array_reverse($hosts->toArray()) as $host) {
|
||||
$this->info('[' . $host['module']['name'] . '](' . $host['price'] . ' Drops) ' . $host['name']);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Console\Commands\BanUser;
|
||||
use App\Console\Commands\CalcModule;
|
||||
use App\Console\Commands\GetUser;
|
||||
use App\Console\Commands\SuspendUserAllHosts;
|
||||
use App\Console\Commands\UnbanUser;
|
||||
use App\Console\Commands\UserAddBalance;
|
||||
@ -30,6 +31,7 @@ class Kernel extends ConsoleKernel
|
||||
SuspendUserAllHosts::class,
|
||||
CalcModule::class,
|
||||
UserAddBalance::class,
|
||||
GetUser::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use App\Models\Host;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Module\Module;
|
||||
// use App\Models\Module\Module;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user