import( (string) $this->argument('path'), $this->option('balance-date') === null ? null : (string) $this->option('balance-date'), (string) $this->option('scope'), (bool) $this->option('dry-run'), ); } catch (Throwable $exception) { report($exception); $this->error($exception->getMessage()); return self::FAILURE; } $this->info(sprintf( '%s:%s 共 %d 条,替换原有 %d 条。', $result['dry_run'] ? '校验完成' : '导入完成', $result['balance_date'], $result['total'], $result['replaced'], )); if (! $result['dry_run']) { $companyIds = StoreReceivingAccount::withoutGlobalScopes() ->whereNull('deleted_at') ->distinct() ->pluck('company_id') ->filter() ->map(static fn (mixed $id): int => (int) $id) ->unique() ->values(); foreach ($companyIds as $companyId) { try { $alerts = $alertSynchronizer->syncLatest($companyId); if ($alerts['created'] > 0 || $alerts['updated'] > 0) { $this->info(sprintf( '余额预警待办:公司 %d 新增 %d 条、更新 %d 条。', $companyId, $alerts['created'], $alerts['updated'], )); } } catch (Throwable $exception) { report($exception); $this->warn("余额预警待办生成失败(公司 {$companyId}),余额快照已保留。"); } } } return self::SUCCESS; } }