mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
73 lines
1.6 KiB
PHP
73 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Setting;
|
|
use App\Models\User;
|
|
use App\Repositories\CleanupRepository;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Nexus\Database\NexusDB;
|
|
|
|
class CalculateUserSeedBonus implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
private int $beginUid;
|
|
|
|
private int $endUid;
|
|
|
|
private string $requestId;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(int $beginUid, int $endUid, string $requestId = '')
|
|
{
|
|
$this->beginUid = $beginUid;
|
|
$this->endUid = $endUid;
|
|
$this->requestId = $requestId;
|
|
}
|
|
|
|
/**
|
|
* Determine the time at which the job should timeout.
|
|
*
|
|
* @return \DateTime
|
|
*/
|
|
public function retryUntil()
|
|
{
|
|
return now()->addSeconds(Setting::get('main.autoclean_interval_one'));
|
|
}
|
|
|
|
public $tries = 1;
|
|
|
|
public $timeout = 3600;
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
CleanupRepository::runBatchJob(CleanupRepository::USER_SEED_BONUS_BATCH_KEY, $this->requestId);
|
|
}
|
|
|
|
/**
|
|
* Handle a job failure.
|
|
*
|
|
* @param \Throwable $exception
|
|
* @return void
|
|
*/
|
|
public function failed(\Throwable $exception)
|
|
{
|
|
do_log("failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error');
|
|
}
|
|
}
|