setName('traffic_pool:dedupe') ->setDescription('流量池去重:同 company 内手机/微信相同客资合并') ->addOption('companyId', null, Option::VALUE_OPTIONAL, '公司 ID,0=全部', 0) ->addOption('dry-run', null, Option::VALUE_NONE, '仅统计不写入'); } protected function execute(Input $input, Output $output) { $companyId = max(0, (int)$input->getOption('companyId')); $dryRun = (bool)$input->getOption('dry-run'); $stats = TrafficPoolDedupeService::run($companyId, $dryRun); $output->writeln(sprintf( 'traffic_pool:dedupe done companyId=%d dryRun=%s groups=%d slaves=%d skipped=%d failed=%d firstError=%s', $companyId, $dryRun ? 'yes' : 'no', $stats['mergedGroups'], $stats['mergedSlaves'], $stats['skipped'], $stats['failed'] ?? 0, $stats['firstError'] ?? '' )); return 0; } }