CaiWuXiTong/app/Console/Commands/WarmOrderDataShopCandidates.php

31 lines
1.0 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Modules\EcommerceFinance\Repositories\OrderDataMirrorRepository;
use Throwable;
class WarmOrderDataShopCandidates extends Command
{
protected $signature = 'order-data:warm-shop-candidates {--full : 全量核对店铺候选(夜间维护)}';
protected $description = '增量预热订单售后费用明细的店铺候选,夜间使用 --full 全量核对';
public function handle(OrderDataMirrorRepository $orders): int
{
try {
$names = $orders->refreshShopNamesCache((bool) $this->option('full'));
$this->info(sprintf('店铺候选已预热,共 %d 个店铺。', count($names)));
return self::SUCCESS;
} catch (Throwable $exception) {
Log::error('店铺候选预热失败。', ['exception' => $exception::class]);
$this->error('店铺候选预热失败:' . $exception->getMessage());
return self::FAILURE;
}
}
}