feat(shopro_huifu): 新增分账配置依赖检查命令并完善online_busi_type支持 - 新增ProbeSplitConfigDeps命令用于检查split/config提交前的依赖项 (online_busi_type、运营媒介等) - 在SyncSplitReceivers命令中添加--online-busi-type选项 - 更新QuerySplitConfig显示online_busi_type信息并调整后续步骤提示 - 完善HuifuMerchantSplitService中的online_busi_type解析逻辑 - 添加extended_material_list配置支持 - 在数据库升级脚本中增加新的配置项 ```
92 行
4.1 KiB
PHP
92 行
4.1 KiB
PHP
<?php
|
||
|
||
namespace addons\shopro_huifu\command;
|
||
|
||
use addons\shopro_huifu\library\Bridge;
|
||
use addons\shopro_huifu\library\HuifuClient;
|
||
use addons\shopro_huifu\library\HuifuConfig;
|
||
use addons\shopro_huifu\library\split\HuifuMerchantSplitService;
|
||
use think\console\Command;
|
||
use think\console\Input;
|
||
use think\console\input\Option;
|
||
use think\console\Output;
|
||
|
||
/**
|
||
* 分账 split/config 提交前依赖项检查(online_busi_type、运营媒介等)
|
||
*/
|
||
class ProbeSplitConfigDeps extends Command
|
||
{
|
||
protected function configure()
|
||
{
|
||
$this->setName('shopro_huifu:probe-split-config-deps')
|
||
->addOption('huifu-id', null, Option::VALUE_OPTIONAL, '主商户号')
|
||
->setDescription('Check split/config prerequisites before sync-split-receivers');
|
||
}
|
||
|
||
protected function execute(Input $input, Output $output)
|
||
{
|
||
if (!Bridge::isEnabled()) {
|
||
$output->writeln('[FAIL] 汇付插件未启用');
|
||
return 1;
|
||
}
|
||
|
||
$service = new HuifuMerchantSplitService();
|
||
$main = trim((string) $input->getOption('huifu-id'));
|
||
if ($main === '') {
|
||
$main = $service->resolveMainHuifuId();
|
||
}
|
||
$ratio = floatval($service->resolveApplyRatio());
|
||
$cfg = HuifuConfig::getInstance();
|
||
|
||
$output->writeln('主商户 huifu_id: ' . $main);
|
||
$output->writeln('apply_ratio: ' . $ratio . '%');
|
||
$output->writeln('scene(配置): ' . $service->resolveSplitConfigScene());
|
||
$output->writeln('rule_origin(配置): ' . $service->resolveRuleOrigin([]));
|
||
$output->writeln('');
|
||
|
||
$onlineBusi = $service->resolveOnlineBusiType(['main_huifu_id' => $main], $main);
|
||
$cfgBusi = trim((string) $cfg->get('split_config_online_busi_type', ''));
|
||
$output->writeln('--- online_busi_type (>30% 必填) ---');
|
||
$output->writeln('插件配置 split_config_online_busi_type: ' . ($cfgBusi !== '' ? $cfgBusi : '(空)'));
|
||
$output->writeln('汇付商户详情/合并结果: ' . ($onlineBusi !== '' ? $onlineBusi : '(未查到)'));
|
||
if ($ratio > 30 && $onlineBusi === '') {
|
||
$output->writeln('[FAIL] 缺少 online_busi_type,请向渠道/实施索取编码或查 KYC 编码表后写入配置');
|
||
} else {
|
||
$output->writeln('[OK] online_busi_type');
|
||
}
|
||
$output->writeln('');
|
||
|
||
$mediaJson = trim((string) $cfg->get('split_config_online_media_json', ''));
|
||
$output->writeln('--- online_media_info_list (>20% 必填) ---');
|
||
$output->writeln('split_config_online_media_json: ' . ($mediaJson !== '' ? '已配置(' . strlen($mediaJson) . ' 字符)' : '(空)'));
|
||
if ($service->hasOnlineMediaForSplit($ratio)) {
|
||
$output->writeln('[OK] 运营媒介可组装');
|
||
} elseif ($service->needsOnlineMediaInfo($ratio)) {
|
||
$output->writeln('[FAIL] 缺少运营媒介,请 php think shopro_huifu:upload-split-media ... --save-config');
|
||
}
|
||
$output->writeln('');
|
||
|
||
$extMat = trim((string) $cfg->get('split_config_extended_material_json', ''));
|
||
$output->writeln('--- extended_material_list (按编码表可选/必填) ---');
|
||
$output->writeln('split_config_extended_material_json: ' . ($extMat !== '' ? '已配置' : '(空,若下一报错要求补充材料再填)'));
|
||
|
||
$client = new HuifuClient();
|
||
$basic = $client->queryMerchantBasicdata($main, true);
|
||
if ($basic['ok']) {
|
||
$scan = HuifuClient::collectNestedKeys($basic['data'] ?? [], [
|
||
'online_busi_type', 'delay_flag', 'mcc', 'wx_mcc', 'ali_mcc', 'scene_type',
|
||
]);
|
||
if ($scan !== []) {
|
||
$output->writeln('');
|
||
$output->writeln('商户详情相关字段: ' . json_encode($scan, JSON_UNESCAPED_UNICODE));
|
||
}
|
||
}
|
||
|
||
$output->writeln('');
|
||
$output->writeln('预览 split/config 请求体: php think shopro_huifu:sync-split-receivers --dry-run');
|
||
$output->writeln('正式提交: php think shopro_huifu:sync-split-receivers --online-busi-type=你的编码');
|
||
|
||
return ($ratio > 30 && $onlineBusi === '') ? 1 : 0;
|
||
}
|
||
}
|