2022-09-28 05:13:24 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
|
use App\Models\Balance;
|
2022-09-28 05:13:24 +00:00
|
|
|
|
use App\Models\Host;
|
|
|
|
|
use App\Models\Transaction;
|
2022-11-06 11:28:22 +00:00
|
|
|
|
use App\Models\User;
|
2022-09-28 05:13:24 +00:00
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
class GetUser extends Command
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name and signature of the console command.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2022-10-02 13:26:59 +00:00
|
|
|
|
protected $signature = 'user {email_or_id}';
|
2022-09-28 05:13:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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()
|
|
|
|
|
{
|
|
|
|
|
//
|
2022-10-02 13:26:59 +00:00
|
|
|
|
$email_or_id = $this->argument('email_or_id');
|
|
|
|
|
|
|
|
|
|
$user = User::where('email', $email_or_id)->orWhere('id', $email_or_id)->first();
|
2022-09-28 05:13:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$transaction = new Transaction();
|
|
|
|
|
|
2022-10-02 13:26:59 +00:00
|
|
|
|
$drops = $transaction->getDrops($user->id);
|
2022-09-28 05:13:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->warn('用户基本信息');
|
|
|
|
|
|
2022-10-02 13:26:59 +00:00
|
|
|
|
$this->info('用户 ID: ' . $user->id);
|
2022-09-28 05:13:24 +00:00
|
|
|
|
$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']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|