CaiWuXiTong/app/Console/Commands/SyncStoreReportMirror.php
WuYongJie 78857a51d9 feat: 店铺维度报表按主体期间拆分并支持期初数据维护
- 改为按期初数据+系统主体+爬虫新主体生成主体期间,一行一期间,修复流程历史重复行
- 变更日当天归新主体、老主体失效显示变更日前一天;关店和其他非正常状态两列显示 -
- 期初数据首次打开固化为系统库设置,可在「规则信息 → 店铺维度报表逻辑配置」在线增删改
- 爬虫店铺主体按税号归一,首次抓到的新主体写入期间变更表并自动生成新期间
- 新增期间变更表迁移与 crawl_shop_company 镜像数据集
2026-10-06 18:42:12 +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;
}
}