```
feat(shopro_huifu): 添加联行号导入范围筛选功能 - 新增 preset 参数支持 main(默认) 和 full 两种模式 - main 模式仅导入主要省市 + 四大行/农商行等约5万条数据 - full 模式导入全国全量约15万条数据 - 添加 HuifuOnboardBankBranchImportFilter 类处理筛选逻辑 - 优化 CSV 流式处理,提升大文件导入性能 - 更新 README 文档说明新的导入命令选项 ```
这个提交包含在:
@@ -22,6 +22,7 @@ class ImportBankBranch extends Command
|
||||
->addOption('truncate', 't', Option::VALUE_NONE, 'Clear table before import (optional, default skip existing)')
|
||||
->addOption('update-existing', 'u', Option::VALUE_NONE, 'Update rows when branch_code already exists')
|
||||
->addOption('check', 'c', Option::VALUE_NONE, 'Check duplicate branch_code / branch_name in DB only')
|
||||
->addOption('preset', 'p', Option::VALUE_OPTIONAL, 'Import scope: main(~50k, default) / full(all)', 'main')
|
||||
->addOption('limit', 'l', Option::VALUE_OPTIONAL, 'Max rows to import (0=all)', 0)
|
||||
->addOption('batch', 'b', Option::VALUE_OPTIONAL, 'Batch size', 500)
|
||||
->addOption('format', null, Option::VALUE_OPTIONAL, 'Force format: csv|json|auto', 'auto')
|
||||
@@ -32,6 +33,8 @@ class ImportBankBranch extends Command
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
@ini_set('memory_limit', '256M');
|
||||
|
||||
$exportJson = trim((string) $input->getOption('export-json'));
|
||||
if ($exportJson !== '') {
|
||||
return $this->exportJson($output, $exportJson, (int) $input->getOption('export-limit'));
|
||||
@@ -59,8 +62,14 @@ class ImportBankBranch extends Command
|
||||
$download = (bool) $input->getOption('download');
|
||||
$seed = (bool) $input->getOption('seed');
|
||||
|
||||
$preset = trim((string) $input->getOption('preset'));
|
||||
if ($preset === '') {
|
||||
$preset = 'main';
|
||||
}
|
||||
|
||||
if ($seed) {
|
||||
$file = ADDON_PATH . 'shopro_huifu/data/bank_branches.json';
|
||||
$preset = 'full';
|
||||
} elseif ($download) {
|
||||
$output->writeln('正在下载全国联行号 CSV(约 20MB,来源 gweesin/CNAPS)...');
|
||||
try {
|
||||
@@ -86,9 +95,14 @@ class ImportBankBranch extends Command
|
||||
}
|
||||
}
|
||||
|
||||
if ($seed || strtolower(pathinfo($file, PATHINFO_EXTENSION)) === 'json') {
|
||||
$preset = 'full';
|
||||
}
|
||||
|
||||
$options = [
|
||||
'truncate' => (bool) $input->getOption('truncate'),
|
||||
'update_existing' => (bool) $input->getOption('update-existing'),
|
||||
'preset' => $preset,
|
||||
'limit' => (int) $input->getOption('limit'),
|
||||
'batch' => (int) $input->getOption('batch'),
|
||||
'format' => (string) $input->getOption('format'),
|
||||
@@ -96,6 +110,7 @@ class ImportBankBranch extends Command
|
||||
];
|
||||
|
||||
$output->writeln('导入文件: ' . $file);
|
||||
$output->writeln('导入范围: ' . ($preset === 'full' ? '全国全量(约15万)' : '主要省市 + 四大行/农商行等(约5万)'));
|
||||
if ($options['dry_run']) {
|
||||
$output->writeln('[dry-run] 仅解析,不写入数据库');
|
||||
}
|
||||
@@ -113,11 +128,13 @@ class ImportBankBranch extends Command
|
||||
}
|
||||
|
||||
$output->writeln(sprintf(
|
||||
'完成: 解析 %d 行,新增 %d,更新 %d,跳过已存在 %d,文件内重复 %d,无效 %d',
|
||||
'完成: 解析 %d 行,命中 %d 行,新增 %d,更新 %d,跳过已存在 %d,范围外 %d,文件内重复 %d,无效 %d',
|
||||
$stats['parsed'] ?? 0,
|
||||
$stats['matched'] ?? 0,
|
||||
$stats['inserted'],
|
||||
$stats['updated'],
|
||||
$stats['skipped_existing'] ?? 0,
|
||||
$stats['skipped_filtered'] ?? 0,
|
||||
$stats['duplicate_in_file'] ?? 0,
|
||||
$stats['skipped_invalid'] ?? 0
|
||||
));
|
||||
|
||||
在新工单中引用
屏蔽一个用户