```
feat(shopro_huifu): 添加分账媒体文件上传命令并优化分账配置流程 - 新增 UploadSplitMedia 命令用于上传小程序运营媒介截图到汇付 - 在 SyncSplitReceivers 中添加异常处理和更清晰的日志输出 - 优化 HuifuMerchantSplitService 中的分账配置逻辑 - 当分账比例>20%时自动验证并上传运营媒介材料 - 添加相关配置项到数据库升级脚本 - 注册新命令到应用命令列表 ```
这个提交包含在:
@@ -150,6 +150,17 @@ class HuifuMerchantSplitService
|
||||
$extend['split_ext_info'] = $splitExtInfo;
|
||||
}
|
||||
|
||||
$ratioFloat = floatval($applyRatio);
|
||||
$mediaList = $this->buildOnlineMediaInfoListJson($options, $ratioFloat);
|
||||
if ($mediaList !== null && $mediaList !== '') {
|
||||
$extend['online_media_info_list'] = $mediaList;
|
||||
} elseif ($this->needsOnlineMediaInfo($ratioFloat) && empty($options['skip_media_check'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
'分账比例>20%须提交运营媒介 online_media_info_list(首页/商品/下单/支付截图的汇付 file_id)。'
|
||||
. '请执行 php think shopro_huifu:upload-split-media 或配置 split_config_online_media_json,见 docs/汇付延时分账测试指南.md'
|
||||
);
|
||||
}
|
||||
|
||||
$asyncUrl = trim((string) ($options['async_return_url'] ?? $this->config->get('split_config_async_url', '')));
|
||||
if ($asyncUrl !== '') {
|
||||
$extend['async_return_url'] = $asyncUrl;
|
||||
@@ -381,6 +392,105 @@ class HuifuMerchantSplitService
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业商户分账比例 >20% 时汇付要求运营媒介材料(与业务开通一致)
|
||||
*/
|
||||
public function needsOnlineMediaInfo($applyRatio)
|
||||
{
|
||||
return floatval($applyRatio) > 20.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null JSON 字符串(数组),供 extend.online_media_info_list
|
||||
*/
|
||||
public function buildOnlineMediaInfoListJson(array $options = [], $applyRatio = 0.0)
|
||||
{
|
||||
if (isset($options['online_media_info_list'])) {
|
||||
$raw = $options['online_media_info_list'];
|
||||
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_online_media_json', ''));
|
||||
if ($cfgJson !== '') {
|
||||
$decoded = json_decode($cfgJson, true);
|
||||
if (!is_array($decoded)) {
|
||||
throw new \InvalidArgumentException('split_config_online_media_json 不是合法 JSON 数组');
|
||||
}
|
||||
return json_encode($decoded, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
$item = $this->buildOnlineMediaItemFromConfig();
|
||||
if ($item !== null) {
|
||||
return json_encode([$item], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
if ($this->needsOnlineMediaInfo($applyRatio)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>|null
|
||||
*/
|
||||
public function buildOnlineMediaItemFromConfig()
|
||||
{
|
||||
$front = trim((string) $this->config->get('split_config_media_front_page', ''));
|
||||
$service = trim((string) $this->config->get('split_config_media_service_page', ''));
|
||||
$order = trim((string) $this->config->get('split_config_media_order_page', ''));
|
||||
$pay = trim((string) $this->config->get('split_config_media_pay_page', ''));
|
||||
if ($front === '' || $service === '' || $order === '' || $pay === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mediaType = trim((string) $this->config->get('split_config_media_type', 'S3'));
|
||||
if ($mediaType === '') {
|
||||
$mediaType = 'S3';
|
||||
}
|
||||
$mediaName = trim((string) $this->config->get('split_config_media_name', ''));
|
||||
if ($mediaName === '') {
|
||||
$mediaName = '雄戈小酒';
|
||||
}
|
||||
$common = trim((string) $this->config->get('split_config_media_mer_common_flag', 'Y'));
|
||||
if ($common === '') {
|
||||
$common = 'Y';
|
||||
}
|
||||
|
||||
$item = [
|
||||
'media_type' => $mediaType,
|
||||
'media_name' => $mediaName,
|
||||
'media_mer_common_flag' => $common,
|
||||
'media_front_page' => $front,
|
||||
'media_service_page' => $service,
|
||||
'media_order_page' => $order,
|
||||
'media_pay_page' => $pay,
|
||||
];
|
||||
|
||||
$appId = trim((string) $this->config->get('split_config_media_app_id', ''));
|
||||
if ($appId === '' && class_exists(Bridge::class)) {
|
||||
$appId = trim((string) Bridge::getMiniProgramAppId());
|
||||
}
|
||||
if ($appId !== '' && in_array($mediaType, ['S2', 'S3', 'S4'], true)) {
|
||||
$item['app_id'] = $appId;
|
||||
}
|
||||
|
||||
if ($common === 'N') {
|
||||
$auth = trim((string) $this->config->get('split_config_media_authorize_materials', ''));
|
||||
if ($auth !== '') {
|
||||
$item['authorize_materials'] = $auth;
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $huifuIds
|
||||
*/
|
||||
|
||||
在新工单中引用
屏蔽一个用户