[exam] schedule

This commit is contained in:
xiaomlove
2021-04-29 19:18:13 +08:00
parent a1972ea288
commit 164bc80c4e
14 changed files with 315 additions and 92 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands;
use App\Repositories\ExamRepository;
use Illuminate\Console\Command;
class ExamAssign extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'exam:assign {--uid=} {--exam_id=} {--begin=} {--end=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Assign exam to user, options: --uid, --exam_id, --begin, --end';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$examRep = new ExamRepository();
$uid = $this->option('uid');
$examId = $this->option('exam_id');
$begin = $this->option('begin');
$end = $this->option('end');
$this->info(sprintf('uid: %s, examId: %s, begin: %s, end: %s', $uid, $examId, $begin, $end));
$result = $examRep->assignToUser($uid, $examId, $begin, $end);
$this->info(sprintf('%s, [assignToUser], result: %s, request_id: %s', __METHOD__, var_export($result, true), REQUEST_ID));
return 0;
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Console\Commands;
use App\Repositories\ExamRepository;
use Illuminate\Console\Command;
class ExamAssignCronjob extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'exam:assign_cronjob';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Assign exam cronjob';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$examRep = new ExamRepository();
$result = $examRep->cronjonAssign();
$this->info(sprintf('%s, [cronjonAssign], result: %s, request_id: %s', __METHOD__, var_export($result, true), REQUEST_ID));
return 0;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands;
use App\Repositories\ExamRepository;
use Illuminate\Console\Command;
class ExamCheckoutCronjob extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'exam:checkout_cronjob {--ignore-time-range}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Checkout exam cronjob, options: --ignore-time-range';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$examRep = new ExamRepository();
$ignoreTimeRange = $this->option('ignore-time-range');
$this->info('ignore-time-range: ' . var_export($ignoreTimeRange, true));
$result = $examRep->cronjobCheckout($ignoreTimeRange);
$this->info(sprintf('%s, [cronjobCheckout], result: %s, request_id: %s', __METHOD__, var_export($result, true), REQUEST_ID));
return 0;
}
}

View File

@@ -44,12 +44,19 @@ class Test extends Command
*/
public function handle()
{
$user = User::query()->findOrFail(1);
dd(nexus_trans('exam.checkout_pass_message_content', ['exam_name' => '年中考核', 'begin' => 1, 'end' => 2]));
$rep = new ExamRepository();
// $r = $rep->assignToUser(1, 1);
// $r = $rep->addProgress(27, 4, 1025, 1);
// dd($r);
$r = $rep->addProgress(3, 1, [
1 => 25*1024*1024*1024,
2 => 55*3600,
3 => 100*1024*1024*1024,
4 => 1252
]);
dd($r);
// $rep->assignCronjob();
$rep->cronjobCheckout();
// $rep->cronjobCheckout();
}
}