```
feat(split): 添加分账模式scene参数支持及扩展信息配置 - 在SyncSplitReceivers命令中新增--scene选项,用于指定分账模式 - 支持通过插件配置split_config_scene设置默认分账场景 - 实现buildSplitExtInfoJson方法,根据分账比例和场景自动生成扩展信息 - 当分账比例超过30%或场景为'00'时自动添加业务说明信息 - 在数据库升级脚本中新增分账场景相关配置项 - 完善分账配置的参数验证和错误处理机制 ```
这个提交包含在:
@@ -124,6 +124,11 @@ class HuifuMerchantSplitService
|
||||
|
||||
$receiverHuifuIds = $this->normalizeReceiverIds($receiverHuifuIds, $mainHuifuId);
|
||||
|
||||
$scene = trim((string) ($options['scene'] ?? $this->resolveSplitConfigScene()));
|
||||
if ($scene === '') {
|
||||
throw new \InvalidArgumentException('分账模式 scene 不能为空,请在插件配置 split_config_scene 或传 --scene');
|
||||
}
|
||||
|
||||
$extend = [
|
||||
'product_id' => trim((string) $this->config->get('product_id')),
|
||||
'rule_origin' => $ruleOrigin,
|
||||
@@ -132,8 +137,14 @@ class HuifuMerchantSplitService
|
||||
'div_flag' => (string) ($options['div_flag'] ?? 'Y'),
|
||||
'apply_ratio' => $applyRatio,
|
||||
'start_type' => (string) ($options['start_type'] ?? '0'),
|
||||
'scene' => $scene,
|
||||
];
|
||||
|
||||
$splitExtInfo = $this->buildSplitExtInfoJson($options, floatval($applyRatio), $scene);
|
||||
if ($splitExtInfo !== null && $splitExtInfo !== '') {
|
||||
$extend['split_ext_info'] = $splitExtInfo;
|
||||
}
|
||||
|
||||
$asyncUrl = trim((string) ($options['async_return_url'] ?? $this->config->get('split_config_async_url', '')));
|
||||
if ($asyncUrl !== '') {
|
||||
$extend['async_return_url'] = $asyncUrl;
|
||||
@@ -264,6 +275,69 @@ class HuifuMerchantSplitService
|
||||
return (string) $v !== '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇付 split/config 必填「分账模式」:A5=线上推广方佣金/抽成,02=线上其他,00=其他(>30% 常需 split_ext_info)
|
||||
*/
|
||||
public function resolveSplitConfigScene()
|
||||
{
|
||||
$scene = trim((string) $this->config->get('split_config_scene', 'A5'));
|
||||
return $scene !== '' ? $scene : 'A5';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null JSON 字符串,供 extend.split_ext_info
|
||||
*/
|
||||
protected function buildSplitExtInfoJson(array $options, $applyRatio, $scene)
|
||||
{
|
||||
if (isset($options['split_ext_info'])) {
|
||||
$raw = $options['split_ext_info'];
|
||||
if (is_array($raw)) {
|
||||
return json_encode($raw, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
$raw = trim((string) $raw);
|
||||
if ($raw !== '') {
|
||||
return $raw;
|
||||
}
|
||||
}
|
||||
|
||||
$cfgJson = trim((string) $this->config->get('split_config_ext_info', ''));
|
||||
if ($cfgJson !== '') {
|
||||
return $cfgJson;
|
||||
}
|
||||
|
||||
$busi = trim((string) $this->config->get('split_config_busi_instruction', ''));
|
||||
$capital = trim((string) $this->config->get('split_config_capital_instruction', ''));
|
||||
$function = trim((string) $this->config->get('split_config_function_instruction', ''));
|
||||
if ($busi !== '' || $capital !== '' || $function !== '') {
|
||||
return json_encode([
|
||||
'busi_instruction' => $busi,
|
||||
'capital_instruction' => $capital,
|
||||
'function_instruction' => $function,
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
$needExt = $applyRatio > 30.0 || $scene === '00';
|
||||
if (!$needExt) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return json_encode($this->defaultSplitExtInfoPayload(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 最大分账比例>30% 时的兜底说明(与 docs/汇付分账40%申请说明 一致,可在后台配置覆盖)
|
||||
*
|
||||
* @return array<string,string>
|
||||
*/
|
||||
protected function defaultSplitExtInfoPayload()
|
||||
{
|
||||
return [
|
||||
'busi_instruction' => '平台运营微信小程序酒类零售,采用自营零售与推广分销、区域代理模式;收款商户负责货源、发货与售后,推广员与区域代理按平台制度获得服务费,单笔订单分账总额不超过实付金额40%,确认收货后延时分账。',
|
||||
'capital_instruction' => '消费者微信支付进入平台汇付主商户,开启延时分账暂存;确认收货后由系统接口向各分账接收方子商户划转推广/区域服务费,余额留主商户;退款按汇付与微信规则原路退回,资金均在汇付体系内可追溯。',
|
||||
'function_instruction' => '开通延时分账并将最大比例设为40%,用于向已进件推广员、区域代理自动结算服务费,避免人工转账;实际单笔平均分账约15%-25%,基于真实交易及合作协议,不用于违规资金归集。',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $huifuIds
|
||||
*/
|
||||
|
||||
在新工单中引用
屏蔽一个用户