CaiWuXiTong/app/Console/Commands/SyncStoreReportMirror.php
WuYongJie 561c42d830 feat: 店铺主体期间与爬虫数据逻辑
- 店铺维度报表按期初数据+系统主体+爬虫新主体生成主体期间,一行一期间,修复流程历史重复行
- 变更日当天归新主体、老主体失效显示变更日前一天;关店和其他非正常状态两列显示 -
- 新增店铺维度报表逻辑配置页(R1-R8)、主体商标数据逻辑配置页和预警页面
- 爬虫店铺主体按税号归一,首次抓到的新主体写入期间变更表并自动生成新期间
- 店铺基础信息、商标展示按爬虫优先;新增爬虫数据质量检查与预警处理
2026-10-03 13:28:08 +08:00

56 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Modules\EcommerceFinance\Services\StoreReportMirrorSynchronizer;
use Throwable;
class SyncStoreReportMirror extends Command
{
protected $signature = 'business-mirror:sync-store-report
{--batch= : 每批最多读取账单行数}
{--max-batches= : 本轮最多处理账单批次数}
{--daily-batch= : 每批最多汇总原始账单行数}
{--daily-max-batches= : 本轮最多处理日汇总批次数}';
protected $description = '自动初始化并增量同步店铺维度报表共享镜像';
public function handle(StoreReportMirrorSynchronizer $synchronizer): int
{
if (! (bool) config('upstream_mirrors.refresh_enabled', false)
|| ! (bool) config('upstream_mirrors.store_report.enabled', true)) {
return self::SUCCESS;
}
try {
$result = $synchronizer->sync(
$this->option('batch') === null ? null : (int) $this->option('batch'),
$this->option('max-batches') === null ? null : (int) $this->option('max-batches'),
$this->option('daily-batch') === null ? null : (int) $this->option('daily-batch'),
$this->option('daily-max-batches') === null ? null : (int) $this->option('daily-max-batches'),
);
} catch (Throwable $exception) {
Log::error('店铺维度报表共享镜像同步失败。', ['exception' => $exception::class]);
$this->error('店铺维度报表共享镜像同步失败,页面继续读取上一版数据。');
return self::FAILURE;
}
$this->info(sprintf(
'店铺报表镜像:流程期间 %s/%d 行,主体变更 %s(检查 %d 店,新增 %d 条),账单 %s/%d 行,日汇总 %s/%d 行。',
$result['lifecycles']['status'],
$result['lifecycles']['source_rows'],
$result['period_changes']['status'],
$result['period_changes']['checked'],
$result['period_changes']['created'],
$result['bills']['status'],
$result['bills']['source_rows'],
$result['daily']['status'],
$result['daily']['source_rows'],
));
return self::SUCCESS;
}
}