文件
xionggeshop/addons/shopro_huifu/command/ProbeSplitConfigDeps.php
可乐加冰 420367200c ```
feat(shopro_huifu): 添加分账扩展材料上传功能并优化图片处理

- 新增 UploadSplitExtendedMaterials 命令用于上传 F469/F330 等分账补充材料
- 优化 ProbeSplitConfigDeps 命令中扩展材料配置的检查逻辑
- 支持 PDF 文件上传,增加文件大小限制(PDF 5MB,图片 2MB)
- 修复 MCC 编码可作为 online_busi_type 备选值的问题

```
2026-10-16 09:59:32 +08:00

105 行
4.6 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?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 (H5921L 等常需 F469/F330) ---');
if ($extMat === '') {
$output->writeln('split_config_extended_material_json: (空)');
$output->writeln('[FAIL] 酒类分账常见缺 F469 协议 + F330 食品证 → upload-split-ext-materials');
} else {
$output->writeln('split_config_extended_material_json: 已配置');
$decoded = json_decode($extMat, true);
if (is_array($decoded)) {
$types = array_column($decoded, 'file_type');
foreach (['F469', 'F330'] as $need) {
$ok = in_array($need, $types, true);
$output->writeln(' ' . ($ok ? '[OK]' : '[FAIL]') . ' ' . $need);
}
}
}
$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;
}
}