35 lines
909 B
PHP
35 lines
909 B
PHP
<?php
|
|
|
|
namespace Modules\Core\Shipping\Jobs;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Modules\Core\Shipping\Services\CarrierVoucherSync;
|
|
|
|
/**
|
|
* Daily pull of every carrier's reported vouchers for the last $days days
|
|
* into the Carrier Vouchers screen (CarrierVoucherSync). Also run from
|
|
* that screen's "Sync now".
|
|
*/
|
|
class SyncCarrierVouchersJob implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
public int $tries = 2;
|
|
|
|
public int $backoff = 300;
|
|
|
|
public function __construct(public readonly int $days = 14) {}
|
|
|
|
public function handle(CarrierVoucherSync $sync): void
|
|
{
|
|
$sync->syncAll(now()->subDays($this->days)->startOfDay(), now());
|
|
}
|
|
}
|