```
feat(shopro_huifu): 增加联行号表自动创建和结算费率配置功能 - 新增 install_bank_branch_table.sql 脚本用于独立创建联行号表 - 修改 ImportBankBranch 命令,当联行号表不存在时自动创建,无需手动执行 repair-menu - 添加 upgradeSchema 方法支持独立运行数据库升级脚本 - 在配置界面新增 onboard_settle_fee_rate 字段,支持设置D1结算费率 - 更新 HuifuOnboardBusiOpen 类使用配置的结算费率参数 ```
这个提交包含在:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace addons\shopro_huifu\command;
|
||||
|
||||
use addons\shopro_huifu\library\Installer;
|
||||
use addons\shopro_huifu\library\onboard\HuifuOnboardBankBranchImporter;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
@@ -37,9 +38,16 @@ class ImportBankBranch extends Command
|
||||
try {
|
||||
Db::execute('SELECT 1 FROM `' . config('database.prefix') . 'shopro_huifu_bank_branch` LIMIT 1');
|
||||
} catch (\Throwable $e) {
|
||||
$output->error('表 shopro_huifu_bank_branch 不存在,请先执行 php think shopro_huifu:repair-menu');
|
||||
$output->writeln('表 shopro_huifu_bank_branch 不存在,正在自动创建 ...');
|
||||
try {
|
||||
Installer::ensureBankBranchTable($output);
|
||||
Db::execute('SELECT 1 FROM `' . config('database.prefix') . 'shopro_huifu_bank_branch` LIMIT 1');
|
||||
} catch (\Throwable $inner) {
|
||||
$output->error('创建 shopro_huifu_bank_branch 失败: ' . $inner->getMessage());
|
||||
$output->writeln('也可手动执行: php think shopro_huifu:repair-menu');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
$file = trim((string) $input->getOption('file'));
|
||||
$download = (bool) $input->getOption('download');
|
||||
|
||||
@@ -23,9 +23,9 @@ class RepairMenu extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
Installer::upgradeSchema($output);
|
||||
Installer::installMenu($output);
|
||||
Installer::installSplitMenu($output);
|
||||
Installer::upgradePayTypeColumn($output);
|
||||
\app\common\library\Menu::enable('shopro_huifu/config');
|
||||
\app\common\library\Menu::enable('shopro/split');
|
||||
Installer::grantRulesToShoproGroups($output);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
-- 仅创建联行号表(可单独执行,不依赖 repair-menu)
|
||||
-- 用法: mysql -u用户 -p 数据库名 < addons/shopro_huifu/data/install_bank_branch_table.sql
|
||||
-- 表前缀默认 fa_,若不同请全局替换 fa_
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `fa_shopro_huifu_bank_branch` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`branch_code` varchar(20) NOT NULL COMMENT '联行号',
|
||||
`branch_name` varchar(255) NOT NULL COMMENT '支行全称',
|
||||
`bank_name` varchar(64) DEFAULT NULL COMMENT '银行简称',
|
||||
`prov_id` char(6) DEFAULT NULL,
|
||||
`area_id` char(6) DEFAULT NULL,
|
||||
`status` tinyint(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uniq_branch_code` (`branch_code`),
|
||||
KEY `branch_name` (`branch_name`(64)),
|
||||
KEY `area_id` (`area_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='汇付银行支行联行号';
|
||||
@@ -149,12 +149,35 @@ class Installer
|
||||
*/
|
||||
protected static function recreateMenu(array $menu, $parent, $rootName, array $legacyNames = [])
|
||||
{
|
||||
foreach (array_merge($legacyNames, [$rootName]) as $name) {
|
||||
$toDelete = array_unique(array_filter(array_merge(
|
||||
$legacyNames,
|
||||
[$rootName],
|
||||
array_column($menu, 'name')
|
||||
)));
|
||||
foreach ($toDelete as $name) {
|
||||
\app\common\library\Menu::delete($name);
|
||||
}
|
||||
\app\common\library\Menu::create($menu, $parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补跑升级 SQL(repair-menu / 导入联行号前可单独调用,忽略已存在字段/表)
|
||||
*/
|
||||
public static function upgradeSchema($output = null)
|
||||
{
|
||||
$addonDir = ADDON_PATH . 'shopro_huifu' . DS;
|
||||
self::log($output, '检查/升级汇付数据表 ...');
|
||||
self::importSqlFile($addonDir . 'upgrade_huifu_split.sql', $output, true);
|
||||
self::importSqlFile($addonDir . 'upgrade_huifu_onboard.sql', $output, true);
|
||||
self::importSqlFile($addonDir . 'upgrade_huifu_onboard_account.sql', $output, true);
|
||||
self::upgradePayTypeColumn($output);
|
||||
}
|
||||
|
||||
public static function ensureBankBranchTable($output = null)
|
||||
{
|
||||
self::upgradeSchema($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇付/分账菜单统一挂到「商城配置」
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,9 @@ class HuifuOnboardBusiOpen
|
||||
|
||||
$settleBatch = $this->config->get('onboard_settle_batch_no', '300');
|
||||
|
||||
// 汇付费率单位为百分比;AMT * 0.0005 对应 fee_rate=0.05。
|
||||
$settleFeeRate = max(0.05, (float) $this->config->get('onboard_settle_fee_rate', '0.05'));
|
||||
|
||||
$cashType = $this->config->get('onboard_cash_type', 'D1');
|
||||
|
||||
$cashFix = $this->config->get('onboard_cash_fix_amt', '0.03');
|
||||
@@ -82,6 +85,8 @@ class HuifuOnboardBusiOpen
|
||||
|
||||
'fixed_ratio' => '0.00',
|
||||
|
||||
'fee_rate' => number_format($settleFeeRate, 2, '.', ''),
|
||||
|
||||
]];
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backe
|
||||
onboard_required: '1',
|
||||
onboard_settle_cycle: 'D1',
|
||||
onboard_settle_batch_no: '300',
|
||||
onboard_settle_fee_rate: '0.05',
|
||||
onboard_notify_url: ''
|
||||
}
|
||||
},
|
||||
|
||||
@@ -31,6 +31,7 @@ INSERT IGNORE INTO `__PREFIX__shopro_huifu_config` (`name`, `value`, `group`, `d
|
||||
('onboard_required', '1', 'onboard', '汇付分账模式下强制个人进件'),
|
||||
('onboard_settle_cycle', 'D1', 'onboard', '个人入驻默认结算周期'),
|
||||
('onboard_settle_batch_no', '300', 'onboard', '结算批次号'),
|
||||
('onboard_settle_fee_rate', '0.05', 'onboard', 'D1结算手续费率(百分比,AMT*0.0005对应0.05)'),
|
||||
('onboard_cash_type', 'D1', 'onboard', '取现类型'),
|
||||
('onboard_cash_fix_amt', '0.03', 'onboard', '取现固定手续费'),
|
||||
('onboard_cash_fee_rate', '0', 'onboard', '取现费率'),
|
||||
|
||||
@@ -45,6 +45,12 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="结算周期"><el-input v-model="form.onboard_settle_cycle" placeholder="D1"></el-input></el-form-item>
|
||||
<el-form-item label="结算批次号"><el-input v-model="form.onboard_settle_batch_no"></el-input></el-form-item>
|
||||
<el-form-item label="D1结算费率(%)">
|
||||
<el-input v-model="form.onboard_settle_fee_rate" placeholder="0.05"></el-input>
|
||||
<div style="color:#909399;font-size:12px;line-height:1.6;margin-top:4px;">
|
||||
汇付按百分比传值;0.05 表示 AMT × 0.0005,不能低于渠道商/上级商户底价。
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="进件通知URL"><el-input v-model="form.onboard_notify_url" readonly></el-input></el-form-item>
|
||||
|
||||
<el-divider content-position="left">只读</el-divider>
|
||||
|
||||
在新工单中引用
屏蔽一个用户