| 1234567891011121314151617181920212223 |
- <?php
- namespace App\Console\Commands;
- use App\Services\Reporting\ReportSync;
- use App\Support\SyncCommandLock;
- use Illuminate\Console\Command;
- class SyncReporting extends Command
- {
- protected $signature = 'reporting:sync {--full : 分批重新核对全部历史来源,不修改业务订单或钱包}';
- protected $description = '同步后台统一报表事实(默认增量,幂等,可重试)';
- public function handle(ReportSync $service, SyncCommandLock $lock): int
- {
- $exit = $lock->run('reporting:sync', function () use ($service) {
- $result = $service->sync((bool) $this->option('full'));
- $this->line(json_encode($result, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
- return $result['errors'] > 0 ? self::FAILURE : self::SUCCESS;
- });
- if ($exit === null) $this->info('报表同步已在运行,跳过本次执行');
- return $exit ?? self::SUCCESS;
- }
- }
|