Files
test_ea/laravel/app/Console/Commands/SyncSalesCommand.php
2026-02-15 01:34:17 +07:00

46 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Contracts\WbSyncManagerInterface;
use App\Enums\WbEndpoint;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
final class SyncSalesCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync:sales {--dateFrom=} {--dateTo=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Sync sales from WB API';
/**
* Execute the console command.
*/
public function handle(WbSyncManagerInterface $manager): int
{
$dateFrom = $this->option('dateFrom');
$dateTo = $this->option('dateTo');
$dateFrom = $dateFrom ?: Carbon::now()->subYear()->toDateString();
$dateTo = $dateTo ?: Carbon::yesterday()->toDateString();
$manager->start(WbEndpoint::SALES, $dateFrom, $dateTo);
$this->info('Sales sync started');
return self::SUCCESS;
}
}