option('company-id'); $effectiveFrom = trim((string) $this->option('effective-from')); try { $parsed = $importer->rows((string) $this->argument('file')); } catch (\Throwable $exception) { $this->error($exception->getMessage()); return self::FAILURE; } $this->table(['指标', '数量'], [ ['店铺公司行数', $parsed['total_rows']], ['已分配客服公司', $parsed['assigned_rows']], ['暂不分配', $parsed['unassigned_rows']], ['无效行', count($parsed['invalid_rows'])], ]); if ($parsed['invalid_rows'] !== []) { $this->error(implode(PHP_EOL, $parsed['invalid_rows'])); return self::FAILURE; } if ((bool) $this->option('dry-run')) { $this->info('校验通过,未写入数据库。'); return self::SUCCESS; } $result = $repository->syncCustomerServiceMappings( $companyId, $parsed['rows'], $effectiveFrom, trim((string) $this->option('actor')) ?: '客服公司映射导入', ); if ($result['errors'] !== []) { $this->error(implode(PHP_EOL, $result['errors'])); return self::FAILURE; } $this->table(['结果', '数量'], [ ['新增', $result['created']], ['更新', $result['updated']], ['无变化', $result['unchanged']], ['停用', $result['inactive']], ]); $this->info("客服公司映射已同步,生效日期:{$effectiveFrom}"); return self::SUCCESS; } }