文件
xionggeshop/addons/shopro_huifu/library/onboard/HuifuOnboardBusiOpen.php
可乐加冰 5110e5bd34 ```
fix(shopro_huifu): 更新商户开户手续费率配置

修复了HuifuOnboardBusiOpen类中手续费率配置的错误,
将fixed_ratio字段的值从固定的'0.00'更改为动态计算的结算费率,
同时移除了不再使用的fee_rate字段配置。
```
2026-09-30 14:24:47 +08:00

242 行
4.9 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace addons\shopro_huifu\library\onboard;
use addons\shopro_huifu\library\HuifuConfig;
use addons\shopro_huifu\library\SdkLoader;
class HuifuOnboardBusiOpen
{
protected $sdk;
protected $config;
public function __construct(HuifuOnboardSdk $sdk = null)
{
$this->sdk = $sdk ?: new HuifuOnboardSdk();
$this->config = HuifuConfig::getInstance();
}
public function submit($huifuId, array $form, array $fileMap)
{
SdkLoader::requireRequest('V2UserBusiOpenRequest.php');
$meta = $this->sdk->newReqMeta();
$request = new \BsPaySdk\request\V2UserBusiOpenRequest();
$request->setHuifuId($huifuId);
$request->setReqSeqId($meta['req_seq_id']);
$request->setReqDate($meta['req_date']);
$request->setUpperHuifuId($this->sdk->getUpperHuifuId());
$settleCycle = $this->config->get('onboard_settle_cycle', 'D1');
$settleBatch = $this->config->get('onboard_settle_batch_no', '300');
// 汇付费率单位为百分比;AMT * 0.0005 对应 fee_rate=0.05。
$settleFeeRate = max(0.05, (float) $this->config->get('onboard_settle_fee_rate', '0.05'));
$cashType = $this->config->get('onboard_cash_type', 'D1');
$cashFix = $this->config->get('onboard_cash_fix_amt', '0.03');
$cashRate = $this->config->get('onboard_cash_fee_rate', '0');
$settleConfigList = [[
'settle_cycle' => $settleCycle,
'settle_batch_no' => $settleBatch,
'min_amt' => '0.01',
'remained_amt' => '0.00',
'settle_abstract' => '分账结算',
'out_settle_flag' => '2',
'fixed_ratio' => number_format($settleFeeRate, 2, '.', ''),
]];
// 系统 bank_account_type:0=对私,1=对公
// 汇付 card_type:0=对公,1=对私法人,2=对私非法人
$bankAccountType = (string) ($form['bank_account_type'] ?? '0');
$cardType = $bankAccountType === '1' ? '0' : '1';
$accountType = $form['account_type'] ?? 'indv';
$cardName = $form['card_name'] ?? '';
if ($accountType === 'indv') {
$cardName = $form['name'] ?? $cardName;
} elseif ($bankAccountType === '0') {
$cardName = $form['legal_name'] ?? $cardName;
}
$cardInfo = [
'card_type' => $cardType,
'card_name' => $cardName,
'card_no' => $form['card_no'],
'prov_id' => $form['prov_id'],
'area_id' => $form['area_id'],
'mp' => $form['mp'],
];
if (!empty($form['branch_code'])) {
$cardInfo['branch_code'] = $form['branch_code'];
}
if (!empty($form['branch_name'])) {
$cardInfo['branch_name'] = $form['branch_name'];
}
if ($cardType === '1') {
$cardInfo['cert_type'] = '00';
$cardInfo['cert_no'] = $form['cert_no'];
$cardInfo['cert_validity_type'] = $form['cert_validity_type'];
$cardInfo['cert_begin_date'] = $form['cert_begin_date'];
if ($form['cert_validity_type'] === '0' && !empty($form['cert_end_date'])) {
$cardInfo['cert_end_date'] = $form['cert_end_date'];
}
}
$cashConfig = [[
'cash_type' => $cashType,
'fix_amt' => $cashFix,
'fee_rate' => $cashRate,
]];
$fileList = [];
if (!empty($fileMap['F13'])) {
$fileList[] = [
'file_type' => 'F13',
'file_id' => $fileMap['F13'],
'file_name' => 'bank_card.jpg',
];
}
if ($cardType === '0' && !empty($fileMap['F08'])) {
$fileList[] = [
'file_type' => 'F08',
'file_id' => $fileMap['F08'],
'file_name' => 'account_permit.jpg',
];
}
$extend = [
'settle_config_list' => json_encode($settleConfigList, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'card_info' => json_encode($cardInfo, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'cash_config' => json_encode($cashConfig, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
'async_return_url' => $this->sdk->getOnboardNotifyUrl(),
];
if ($fileList) {
$extend['file_list'] = json_encode($fileList, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
$request->setExtendInfo($extend);
$result = $this->sdk->getClient()->postRequest($request);
$data = $this->sdk->getClient()->parseResponse($result);
$applyNo = $data['apply_no'] ?? ($data['apply_id'] ?? '');
return [
'req_date' => $meta['req_date'],
'req_seq_id' => $meta['req_seq_id'],
'apply_no' => $applyNo,
'resp' => $data,
];
}
}