mirror of
https://gitee.com/liuxioabin/fengketrade.git
synced 2026-04-20 05:33:18 +08:00
生成支付串
This commit is contained in:
parent
037ada5e61
commit
ca82c79c78
@ -140,55 +140,7 @@ class Ccblife extends Common
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 建行用户自动登录(JSBridge方式)
|
|
||||||
* H5在建行App内打开时,通过JSBridge获取用户信息后调用
|
|
||||||
*
|
|
||||||
* POST /addons/shopro/ccblife/autoLogin
|
|
||||||
*/
|
|
||||||
public function autoLogin()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
// 获取请求参数
|
|
||||||
$ccbUserId = $this->request->post('ccb_user_id', '');
|
|
||||||
$mobile = $this->request->post('mobile', '');
|
|
||||||
$nickname = $this->request->post('nickname', '');
|
|
||||||
$avatar = $this->request->post('avatar', '');
|
|
||||||
|
|
||||||
// 验证必需参数
|
|
||||||
if (empty($ccbUserId)) {
|
|
||||||
$this->error('建行用户ID不能为空');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理用户登录/注册
|
|
||||||
$userInfo = $this->processUserLogin($ccbUserId, $mobile, [
|
|
||||||
'nickname' => $nickname,
|
|
||||||
'avatar' => $avatar
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 使用Auth系统登录并生成Token
|
|
||||||
$this->auth->direct($userInfo['user_id']);
|
|
||||||
$token = $this->auth->getToken();
|
|
||||||
|
|
||||||
// 返回结果
|
|
||||||
$this->success('登录成功', [
|
|
||||||
'token' => $token,
|
|
||||||
'user_id' => $userInfo['user_id'],
|
|
||||||
'is_new_user' => $userInfo['is_new'],
|
|
||||||
'userInfo' => $userInfo
|
|
||||||
]);
|
|
||||||
|
|
||||||
} catch (\think\exception\HttpResponseException $e) {
|
|
||||||
// HttpResponseException 是框架正常的响应机制,直接向上抛出
|
|
||||||
throw $e;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Log::error('建行自动登录失败: ' . $e->getMessage());
|
|
||||||
Log::error('错误堆栈: ' . $e->getTraceAsString());
|
|
||||||
$this->error('登录失败: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理用户登录/注册
|
* 处理用户登录/注册
|
||||||
*
|
*
|
||||||
|
|||||||
@ -36,11 +36,6 @@ class CcbEncryption
|
|||||||
*/
|
*/
|
||||||
private $publicKey;
|
private $publicKey;
|
||||||
|
|
||||||
/**
|
|
||||||
* 建行平台公钥
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $platformPublicKey;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造函数
|
* 构造函数
|
||||||
@ -75,8 +70,8 @@ class CcbEncryption
|
|||||||
throw new Exception('服务方私钥未配置');
|
throw new Exception('服务方私钥未配置');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->platformPublicKey)) {
|
if (empty($this->publicKey)) {
|
||||||
throw new Exception('建行平台公钥未配置');
|
throw new Exception('服务方公钥未配置');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +85,7 @@ class CcbEncryption
|
|||||||
public function rsaEncrypt($data)
|
public function rsaEncrypt($data)
|
||||||
{
|
{
|
||||||
// 格式化公钥
|
// 格式化公钥
|
||||||
$publicKey = $this->formatKey($this->platformPublicKey, 'PUBLIC');
|
$publicKey = $this->formatKey($this->publicKey);
|
||||||
|
|
||||||
// 获取公钥资源
|
// 获取公钥资源
|
||||||
$pubKeyId = openssl_pkey_get_public($publicKey);
|
$pubKeyId = openssl_pkey_get_public($publicKey);
|
||||||
@ -382,7 +377,7 @@ class CcbEncryption
|
|||||||
$signString = http_build_query($params);
|
$signString = http_build_query($params);
|
||||||
|
|
||||||
// 3. 追加平台公钥
|
// 3. 追加平台公钥
|
||||||
$signString .= '&PLATFORMPUB=' . $this->platformPublicKey;
|
$signString .= '&PLATFORMPUB=' . $this->publicKey;
|
||||||
|
|
||||||
// 4. 生成MD5签名 (转为大写,与Java一致)
|
// 4. 生成MD5签名 (转为大写,与Java一致)
|
||||||
return strtoupper(md5($signString . $this->privateKey));
|
return strtoupper(md5($signString . $this->privateKey));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user