Files
api_arrahn/app/Jobs/AccountCheckJob.php
2024-10-12 20:18:09 +08:00

54 lines
1.2 KiB
PHP

<?php
namespace App\Jobs;
use Carbon\Carbon;
use App\Services\Reports\AccountService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Cache;
class AccountCheckJob implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
protected $kodcaw;
protected $month;
protected $jobId;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($kodcaw, $month, $jobId)
{
$this->kodcaw = $kodcaw;
$this->month = $month;
$this->jobId = $jobId;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$logger = app('job_log');
try {
$check = app(AccountService::class);
$test =$check->checkAccount( $this->kodcaw,$this->month);
Cache::put("job_result_{$this->jobId}", $test, Carbon::now()->addMinutes(10));
Cache::put("job_status_{$this->jobId}", 'completed', Carbon::now()->addMinutes(10));
} catch (\Exception $e) {
$logger->error($e);
throw $e;
}
}
}