Files
2026-09-15 10:35:56 +08:00

36 lines
1014 B
PHP

<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Cron;
use Esun\LingxingErp\Model\Config;
use Esun\LingxingErp\Model\Inventory\InventorySynchronizer;
use Psr\Log\LoggerInterface;
class SyncInventory
{
public function __construct(
private readonly Config $config,
private readonly InventorySynchronizer $synchronizer,
private readonly LoggerInterface $logger
) {
}
public function execute(): void
{
if (!$this->config->isEnabled()) {
return;
}
try {
$summary = $this->synchronizer->synchronizeAll();
if ($summary['errors'] !== []) {
$this->logger->error('Lingxing inventory synchronization completed with warehouse errors.', [
'errors' => $summary['errors'],
]);
}
} catch (\Throwable $exception) {
$this->logger->error('Lingxing inventory synchronization failed.', ['exception' => $exception]);
}
}
}