42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\command;
|
|
|
|
use app\common\service\pharmacy\EjMedicineCatalogSyncService;
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\input\Option;
|
|
use think\console\Output;
|
|
|
|
class EjPharmacySyncCatalog extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this->setName('ej-pharmacy:sync-catalog')
|
|
->setDescription('增量同步洛阳药房 ERP 药材目录')
|
|
->addOption('limit', 'l', Option::VALUE_OPTIONAL, '每页数量', 200);
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
try {
|
|
$stats = EjMedicineCatalogSyncService::sync(max((int) $input->getOption('limit'), 1));
|
|
$output->writeln(sprintf(
|
|
'同步完成 pages=%d pulled=%d created=%d updated=%d deactivated=%d cursor=%d',
|
|
$stats['pages'],
|
|
$stats['pulled'],
|
|
$stats['created'],
|
|
$stats['updated'],
|
|
$stats['deactivated'],
|
|
$stats['cursor']
|
|
));
|
|
return 0;
|
|
} catch (\Throwable $exception) {
|
|
$output->error($exception->getMessage());
|
|
return 1;
|
|
}
|
|
}
|
|
}
|