```
feat(shopro_huifu): 增强分账配置查询命令的诊断能力 - 改进 QuerySplitConfig 命令的错误提示信息,提供更详细的分账配置状态说明 - 新增商户详细信息查询功能,可获取 delay_flag 等业务开通字段 - 添加嵌套键值扫描工具方法,用于解析汇付应答中的嵌套JSON数据 - 扩展分账配置查询接口,支持传递 product_id 获取更完整的商户信息 - 优化命令行输出,提供分账配置问题的解决方案指导 ```
这个提交包含在:
@@ -579,12 +579,85 @@ class HuifuClient
|
||||
$request->setHuifuId($huifuId);
|
||||
$request->setReqDate(date('Ymd'));
|
||||
$request->setReqSeqId('SPLQ' . date('YmdHis') . mt_rand(1000, 9999));
|
||||
$productId = trim((string) $this->config->get('product_id'));
|
||||
if ($productId !== '') {
|
||||
$request->setExtendInfo(['product_id' => $productId]);
|
||||
}
|
||||
|
||||
return $this->safeApiResult($this->postRequest($request));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商户详细信息查询(传 product_id 时可含 delay_flag 等业务开通字段)
|
||||
*/
|
||||
public function queryMerchantBasicdata($huifuId = '', $withProductId = true)
|
||||
{
|
||||
$huifuId = trim((string) $huifuId);
|
||||
if ($huifuId === '') {
|
||||
$huifuId = trim((string) $this->config->get('huifu_id'));
|
||||
}
|
||||
if ($huifuId === '') {
|
||||
return ['ok' => false, 'message' => '缺少 huifu_id', 'data' => null];
|
||||
}
|
||||
|
||||
SdkLoader::requireRequest('V2MerchantBasicdataQueryRequest.php');
|
||||
$request = new \BsPaySdk\request\V2MerchantBasicdataQueryRequest();
|
||||
$request->setHuifuId($huifuId);
|
||||
$request->setReqDate(date('Ymd'));
|
||||
$request->setReqSeqId('MBDQ' . date('YmdHis') . mt_rand(1000, 9999));
|
||||
if ($withProductId) {
|
||||
$productId = trim((string) $this->config->get('product_id'));
|
||||
if ($productId !== '') {
|
||||
$request->setExtendInfo(['product_id' => $productId]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->safeApiResult($this->postRequest($request));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 在汇付应答中递归查找指定键(用于 split 配置可能在嵌套 JSON 字符串中)
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function collectNestedKeys($payload, array $keys)
|
||||
{
|
||||
$found = [];
|
||||
self::walkNestedPayload($payload, $keys, $found);
|
||||
return $found;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected static function walkNestedPayload($node, array $keys, array &$found)
|
||||
{
|
||||
if (is_string($node)) {
|
||||
$trim = trim($node);
|
||||
if ($trim !== '' && ($trim[0] === '{' || $trim[0] === '[')) {
|
||||
$decoded = json_decode($trim, true);
|
||||
if (is_array($decoded)) {
|
||||
self::walkNestedPayload($decoded, $keys, $found);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!is_array($node)) {
|
||||
return;
|
||||
}
|
||||
foreach ($node as $k => $v) {
|
||||
if (in_array($k, $keys, true) && $v !== '' && $v !== null && !isset($found[$k])) {
|
||||
$found[$k] = $v;
|
||||
}
|
||||
self::walkNestedPayload($v, $keys, $found);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 解析 split_bill_result(可能是 array 或 JSON 字符串)
|
||||
*
|
||||
|
||||
在新工单中引用
屏蔽一个用户