```
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配置支持 - 在数据库升级脚本中增加新的配置项 ```
这个提交包含在:
@@ -161,6 +161,22 @@ class HuifuMerchantSplitService
|
||||
);
|
||||
}
|
||||
|
||||
$onlineBusiType = $this->resolveOnlineBusiType($options, $mainHuifuId);
|
||||
if ($onlineBusiType !== '') {
|
||||
$extend['online_busi_type'] = $onlineBusiType;
|
||||
} elseif ($this->needsOnlineBusiType($ratioFloat) && empty($options['skip_online_busi_check'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
'分账比例>30%须填写 online_busi_type(线上业务类型编码,8位如 H7999AL)。'
|
||||
. '请配置 split_config_online_busi_type、传 --online-busi-type=,或确认主商户进件资料已含该字段;'
|
||||
. '编码表见汇付《线上业务类型编码及补充材料说明》或问渠道/实施(酒类小程序须选与营业执照一致项)'
|
||||
);
|
||||
}
|
||||
|
||||
$extendedMaterial = $this->buildExtendedMaterialListJson($options);
|
||||
if ($extendedMaterial !== null && $extendedMaterial !== '') {
|
||||
$extend['extended_material_list'] = $extendedMaterial;
|
||||
}
|
||||
|
||||
$asyncUrl = trim((string) ($options['async_return_url'] ?? $this->config->get('split_config_async_url', '')));
|
||||
if ($asyncUrl !== '') {
|
||||
$extend['async_return_url'] = $asyncUrl;
|
||||
@@ -400,6 +416,76 @@ class HuifuMerchantSplitService
|
||||
return floatval($applyRatio) > 20.0;
|
||||
}
|
||||
|
||||
public function needsOnlineBusiType($applyRatio)
|
||||
{
|
||||
return floatval($applyRatio) > 30.0;
|
||||
}
|
||||
|
||||
public function hasOnlineMediaForSplit($applyRatio, array $options = [])
|
||||
{
|
||||
try {
|
||||
$json = $this->buildOnlineMediaInfoListJson($options, floatval($applyRatio));
|
||||
return $json !== null && $json !== '';
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function resolveOnlineBusiType(array $options = [], $mainHuifuId = null)
|
||||
{
|
||||
$fromOpt = trim((string) ($options['online_busi_type'] ?? ''));
|
||||
if ($fromOpt !== '') {
|
||||
return $fromOpt;
|
||||
}
|
||||
$fromCfg = trim((string) $this->config->get('split_config_online_busi_type', ''));
|
||||
if ($fromCfg !== '') {
|
||||
return $fromCfg;
|
||||
}
|
||||
if (!empty($options['skip_merchant_online_busi_lookup'])) {
|
||||
return '';
|
||||
}
|
||||
$mainHuifuId = $mainHuifuId ?: $this->resolveMainHuifuId();
|
||||
try {
|
||||
$basic = $this->client->queryMerchantBasicdata($mainHuifuId);
|
||||
if (!empty($basic['ok']) && is_array($basic['data'] ?? null)) {
|
||||
$found = HuifuClient::collectNestedKeys($basic['data'], ['online_busi_type']);
|
||||
$v = trim((string) ($found['online_busi_type'] ?? ''));
|
||||
if ($v !== '') {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::write('[shopro_huifu] split/config online_busi_type lookup fail: ' . $e->getMessage(), 'info');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null JSON 数组字符串
|
||||
*/
|
||||
protected function buildExtendedMaterialListJson(array $options = [])
|
||||
{
|
||||
if (isset($options['extended_material_list'])) {
|
||||
$raw = $options['extended_material_list'];
|
||||
if (is_array($raw)) {
|
||||
return json_encode($raw, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
$raw = trim((string) $raw);
|
||||
if ($raw !== '') {
|
||||
return $raw;
|
||||
}
|
||||
}
|
||||
$cfg = trim((string) $this->config->get('split_config_extended_material_json', ''));
|
||||
if ($cfg === '') {
|
||||
return null;
|
||||
}
|
||||
$decoded = json_decode($cfg, true);
|
||||
if (!is_array($decoded)) {
|
||||
throw new \InvalidArgumentException('split_config_extended_material_json 不是合法 JSON 数组');
|
||||
}
|
||||
return json_encode($decoded, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null JSON 字符串(数组),供 extend.online_media_info_list
|
||||
*/
|
||||
|
||||
在新工单中引用
屏蔽一个用户