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; } }