```
feat(shopro_huifu): 新增股份制银行和城商行联行号导入功能 - 添加 joint 预设选项,支持导入招商、浦发、民生等股份制银行及常用城商行 - 更新命令行选项,增加 --preset=joint 参数说明 - 重构联行号导入过滤器,添加股份制银行关键词配置 - 优化 README 文档,更新导入命令使用说明 ```
这个提交包含在:
@@ -95,10 +95,13 @@ php think shopro_huifu:verify
|
|||||||
# 1) 导入内置种子(约 120 条,主要城市 + 贵州/广东,无需下载)
|
# 1) 导入内置种子(约 120 条,主要城市 + 贵州/广东,无需下载)
|
||||||
php think shopro_huifu:import-bank-branch --seed
|
php think shopro_huifu:import-bank-branch --seed
|
||||||
|
|
||||||
# 2) 下载 CSV 并导入(默认 main:主要省市 + 四大行/农商行,约5万条)
|
# 2) 下载 CSV 并导入(默认 main:四大行/农商行,约5万条)
|
||||||
php think shopro_huifu:import-bank-branch --download
|
php think shopro_huifu:import-bank-branch --download
|
||||||
|
|
||||||
# 3) 手动下载后导入(下载失败时用)
|
# 3) 追加导入股份制/常用城商行(招商/浦发/民生等,约3万条,增量不清库)
|
||||||
|
php think shopro_huifu:import-bank-branch --file=addons/shopro_huifu/data/cnaps.csv --preset=joint
|
||||||
|
|
||||||
|
# 4) 手动下载后导入(下载失败时用)
|
||||||
# https://hf-mirror.com/datasets/gweesin/CNAPS/resolve/main/cnaps.csv
|
# https://hf-mirror.com/datasets/gweesin/CNAPS/resolve/main/cnaps.csv
|
||||||
php think shopro_huifu:import-bank-branch --file=addons/shopro_huifu/data/cnaps.csv
|
php think shopro_huifu:import-bank-branch --file=addons/shopro_huifu/data/cnaps.csv
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace addons\shopro_huifu\command;
|
namespace addons\shopro_huifu\command;
|
||||||
|
|
||||||
use addons\shopro_huifu\library\Installer;
|
use addons\shopro_huifu\library\Installer;
|
||||||
|
use addons\shopro_huifu\library\onboard\HuifuOnboardBankBranchImportFilter;
|
||||||
use addons\shopro_huifu\library\onboard\HuifuOnboardBankBranchImporter;
|
use addons\shopro_huifu\library\onboard\HuifuOnboardBankBranchImporter;
|
||||||
use think\console\Command;
|
use think\console\Command;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
@@ -22,7 +23,7 @@ class ImportBankBranch extends Command
|
|||||||
->addOption('truncate', 't', Option::VALUE_NONE, 'Clear table before import (optional, default skip existing)')
|
->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('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('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('preset', 'p', Option::VALUE_OPTIONAL, 'Import scope: main(~50k) / joint(~30k) / full(all)', 'main')
|
||||||
->addOption('limit', 'l', Option::VALUE_OPTIONAL, 'Max rows to import (0=all)', 0)
|
->addOption('limit', 'l', Option::VALUE_OPTIONAL, 'Max rows to import (0=all)', 0)
|
||||||
->addOption('batch', 'b', Option::VALUE_OPTIONAL, 'Batch size', 500)
|
->addOption('batch', 'b', Option::VALUE_OPTIONAL, 'Batch size', 500)
|
||||||
->addOption('format', null, Option::VALUE_OPTIONAL, 'Force format: csv|json|auto', 'auto')
|
->addOption('format', null, Option::VALUE_OPTIONAL, 'Force format: csv|json|auto', 'auto')
|
||||||
@@ -91,6 +92,7 @@ class ImportBankBranch extends Command
|
|||||||
$output->writeln(' php think shopro_huifu:import-bank-branch --seed');
|
$output->writeln(' php think shopro_huifu:import-bank-branch --seed');
|
||||||
$output->writeln(' php think shopro_huifu:import-bank-branch --download');
|
$output->writeln(' php think shopro_huifu:import-bank-branch --download');
|
||||||
$output->writeln(' php think shopro_huifu:import-bank-branch --file=addons/shopro_huifu/data/cnaps.csv');
|
$output->writeln(' php think shopro_huifu:import-bank-branch --file=addons/shopro_huifu/data/cnaps.csv');
|
||||||
|
$output->writeln(' php think shopro_huifu:import-bank-branch --file=addons/shopro_huifu/data/cnaps.csv --preset=joint');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +112,12 @@ class ImportBankBranch extends Command
|
|||||||
];
|
];
|
||||||
|
|
||||||
$output->writeln('导入文件: ' . $file);
|
$output->writeln('导入文件: ' . $file);
|
||||||
$output->writeln('导入范围: ' . ($preset === 'full' ? '全国全量(约15万)' : '主要省市 + 四大行/农商行等(约5万)'));
|
try {
|
||||||
|
$output->writeln('导入范围: ' . HuifuOnboardBankBranchImportFilter::presetLabel($preset));
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$output->error($e->getMessage());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if ($options['dry_run']) {
|
if ($options['dry_run']) {
|
||||||
$output->writeln('[dry-run] 仅解析,不写入数据库');
|
$output->writeln('[dry-run] 仅解析,不写入数据库');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
namespace addons\shopro_huifu\library\onboard;
|
namespace addons\shopro_huifu\library\onboard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联行号导入范围过滤(默认 main ≈ 5 万条:主要省市 + 四大行/农商行等常用银行)
|
* 联行号导入范围过滤
|
||||||
|
* - main ≈5万:主要省市 + 四大行/交邮/农商行
|
||||||
|
* - joint ≈3万:主要省市 + 招商/浦发等股份制及常用城商行
|
||||||
|
* - full :全国全量
|
||||||
*/
|
*/
|
||||||
class HuifuOnboardBankBranchImportFilter
|
class HuifuOnboardBankBranchImportFilter
|
||||||
{
|
{
|
||||||
@@ -13,34 +16,27 @@ class HuifuOnboardBankBranchImportFilter
|
|||||||
if ($preset === '' || $preset === 'main') {
|
if ($preset === '' || $preset === 'main') {
|
||||||
return self::mainPreset();
|
return self::mainPreset();
|
||||||
}
|
}
|
||||||
|
if ($preset === 'joint' || $preset === 'commercial') {
|
||||||
|
return self::jointPreset();
|
||||||
|
}
|
||||||
if ($preset === 'full') {
|
if ($preset === 'full') {
|
||||||
return ['enabled' => false, 'name' => 'full'];
|
return ['enabled' => false, 'name' => 'full'];
|
||||||
}
|
}
|
||||||
throw new \InvalidArgumentException('未知 preset: ' . $preset . ',可选 main / full');
|
throw new \InvalidArgumentException('未知 preset: ' . $preset . ',可选 main / joint / full');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function mainPreset()
|
public static function presetLabel($preset)
|
||||||
|
{
|
||||||
|
$config = self::resolvePreset($preset);
|
||||||
|
if (empty($config['enabled'])) {
|
||||||
|
return '全国全量(约15万)';
|
||||||
|
}
|
||||||
|
return ($config['description'] ?? $config['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function sharedRegion()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'enabled' => true,
|
|
||||||
'name' => 'main',
|
|
||||||
'description' => '主要省市 + 四大行/交邮/农商行等,约5万条',
|
|
||||||
'bank_keywords' => [
|
|
||||||
'工商银行',
|
|
||||||
'农业银行',
|
|
||||||
'中国银行',
|
|
||||||
'建设银行',
|
|
||||||
'交通银行',
|
|
||||||
'邮储银行',
|
|
||||||
'邮政储蓄',
|
|
||||||
'农村商业银行',
|
|
||||||
'农村合作银行',
|
|
||||||
'农村信用',
|
|
||||||
'农商行',
|
|
||||||
'信用社',
|
|
||||||
'村镇银行',
|
|
||||||
'农信',
|
|
||||||
],
|
|
||||||
'major_provinces' => [
|
'major_provinces' => [
|
||||||
'北京', '上海', '天津', '重庆',
|
'北京', '上海', '天津', '重庆',
|
||||||
'河北', '山西', '辽宁', '吉林', '黑龙江',
|
'河北', '山西', '辽宁', '吉林', '黑龙江',
|
||||||
@@ -76,10 +72,77 @@ class HuifuOnboardBankBranchImportFilter
|
|||||||
'拉萨', '西宁',
|
'拉萨', '西宁',
|
||||||
'韶关', '江门', '肇庆', '清远', '茂名', '梅州',
|
'韶关', '江门', '肇庆', '清远', '茂名', '梅州',
|
||||||
],
|
],
|
||||||
'max_matched' => 55000,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function mainPreset()
|
||||||
|
{
|
||||||
|
return array_merge([
|
||||||
|
'enabled' => true,
|
||||||
|
'name' => 'main',
|
||||||
|
'description' => '主要省市 + 四大行/交邮/农商行,约5万条',
|
||||||
|
'bank_keywords' => [
|
||||||
|
'工商银行',
|
||||||
|
'农业银行',
|
||||||
|
'中国银行',
|
||||||
|
'建设银行',
|
||||||
|
'交通银行',
|
||||||
|
'邮储银行',
|
||||||
|
'邮政储蓄',
|
||||||
|
'农村商业银行',
|
||||||
|
'农村合作银行',
|
||||||
|
'农村信用',
|
||||||
|
'农商行',
|
||||||
|
'信用社',
|
||||||
|
'村镇银行',
|
||||||
|
'农信',
|
||||||
|
],
|
||||||
|
'max_matched' => 55000,
|
||||||
|
], self::sharedRegion());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function jointPreset()
|
||||||
|
{
|
||||||
|
return array_merge([
|
||||||
|
'enabled' => true,
|
||||||
|
'name' => 'joint',
|
||||||
|
'description' => '主要省市 + 招商/浦发/民生等股份制及常用城商行,约3万条',
|
||||||
|
'bank_keywords' => [
|
||||||
|
'招商银行',
|
||||||
|
'浦发银行',
|
||||||
|
'浦东发展',
|
||||||
|
'民生银行',
|
||||||
|
'光大银行',
|
||||||
|
'兴业银行',
|
||||||
|
'平安银行',
|
||||||
|
'中信银行',
|
||||||
|
'华夏银行',
|
||||||
|
'广发银行',
|
||||||
|
'恒丰银行',
|
||||||
|
'浙商银行',
|
||||||
|
'渤海银行',
|
||||||
|
'上海银行',
|
||||||
|
'北京银行',
|
||||||
|
'宁波银行',
|
||||||
|
'南京银行',
|
||||||
|
'杭州银行',
|
||||||
|
'江苏银行',
|
||||||
|
'徽商银行',
|
||||||
|
'天津银行',
|
||||||
|
'重庆银行',
|
||||||
|
'成都银行',
|
||||||
|
'长沙银行',
|
||||||
|
'郑州银行',
|
||||||
|
'青岛银行',
|
||||||
|
'厦门银行',
|
||||||
|
'广州银行',
|
||||||
|
'东莞银行',
|
||||||
|
'苏州银行',
|
||||||
|
],
|
||||||
|
'max_matched' => 32000,
|
||||||
|
], self::sharedRegion());
|
||||||
|
}
|
||||||
|
|
||||||
public static function matches(array $row, array $preset)
|
public static function matches(array $row, array $preset)
|
||||||
{
|
{
|
||||||
if (empty($preset['enabled'])) {
|
if (empty($preset['enabled'])) {
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户