init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user