2025-11-07 09:56:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\command;
|
|
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
use support\think\Db;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Otop extends Command
|
|
|
|
|
{
|
|
|
|
|
protected static $defaultName = 'Otop';
|
|
|
|
|
protected static $defaultDescription = '结算';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function configure()
|
|
|
|
|
{
|
2025-11-22 15:31:01 +08:00
|
|
|
$this->addOption('user_id','u', InputArgument::OPTIONAL, 'user_id');
|
2025-11-07 09:56:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param InputInterface $input
|
|
|
|
|
* @param OutputInterface $output
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
|
|
{
|
|
|
|
|
$user_id = $input->getOption('user_id');
|
|
|
|
|
if(!$user_id){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @var \plugin\admin\app\model\Admin $admin
|
|
|
|
|
*/
|
|
|
|
|
$admin = \plugin\admin\app\model\Admin::where('id',$user_id)->find();
|
|
|
|
|
if(!$admin){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$totp = \OTPHP\TOTP::create($admin->totp_secret);
|
|
|
|
|
cp($totp->now());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|