- 用户端及后台管理端新增更换结算卡接口与页面交互 - 服务层实现换卡核心逻辑、参数校验及汇付接口调用 - 增加换卡异步通知处理与定时轮询补偿以同步审核状态 - 完善进件状态网关,补充换卡审核状态及驳回原因等字段
115 行
4.0 KiB
PHP
115 行
4.0 KiB
PHP
<?php
|
||
|
||
namespace addons\shopro_huifu\library\onboard;
|
||
|
||
use addons\shopro_huifu\library\SdkLoader;
|
||
|
||
/**
|
||
* 用户业务入驻修改:仅更换结算卡(不改结算/取现费率)
|
||
*/
|
||
class HuifuOnboardBusiModify
|
||
{
|
||
protected $sdk;
|
||
|
||
public function __construct(HuifuOnboardSdk $sdk = null)
|
||
{
|
||
$this->sdk = $sdk ?: new HuifuOnboardSdk();
|
||
}
|
||
|
||
public function modifyCard($huifuId, array $form, array $fileMap)
|
||
{
|
||
SdkLoader::requireRequest('V2UserBusiModifyRequest.php');
|
||
|
||
$meta = $this->sdk->newReqMeta();
|
||
$request = new \BsPaySdk\request\V2UserBusiModifyRequest();
|
||
$request->setHuifuId($huifuId);
|
||
$request->setReqSeqId($meta['req_seq_id']);
|
||
$request->setReqDate($meta['req_date']);
|
||
|
||
$cardInfo = self::buildCardInfo($form);
|
||
$fileList = self::buildFileList($form, $fileMap);
|
||
|
||
$extend = [
|
||
'card_info' => json_encode($cardInfo, 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 = (string) ($data['apply_no'] ?? ($data['apply_id'] ?? ''));
|
||
|
||
return [
|
||
'req_date' => $meta['req_date'],
|
||
'req_seq_id' => $meta['req_seq_id'],
|
||
'apply_no' => $applyNo,
|
||
'resp' => $data,
|
||
];
|
||
}
|
||
|
||
public static function buildCardInfo(array $form)
|
||
{
|
||
// 系统 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' => HuifuOnboardAreaHelper::toHuifuCityCode($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'];
|
||
}
|
||
}
|
||
return $cardInfo;
|
||
}
|
||
|
||
public static function buildFileList(array $form, array $fileMap)
|
||
{
|
||
$bankAccountType = (string) ($form['bank_account_type'] ?? '0');
|
||
$cardType = $bankAccountType === '1' ? '0' : '1';
|
||
$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',
|
||
];
|
||
}
|
||
return $fileList;
|
||
}
|
||
}
|