|
@@ -76,7 +76,8 @@ class WechatService
|
|
|
$user = $this->socialite->userFromCode($code);
|
|
|
|
|
|
// 验证openid
|
|
|
- abort_if(empty($user->getId()), 400, '获取微信openid失败');
|
|
|
+ $openid = $user->getId();
|
|
|
+ abort_if(empty($openid), 400, '获取微信openid失败');
|
|
|
|
|
|
// 整理用户信息
|
|
|
$userInfo = $this->formatUserInfo($user);
|
|
@@ -87,7 +88,7 @@ class WechatService
|
|
|
}
|
|
|
|
|
|
// 执行登录
|
|
|
- return $this->accountService->wxLogin($user->getId(), $userInfo);
|
|
|
+ return $this->accountService->wxLogin($openid, $userInfo);
|
|
|
} catch (BusinessException $e) {
|
|
|
throw $e;
|
|
|
} catch (\Exception $e) {
|
|
@@ -96,6 +97,7 @@ class WechatService
|
|
|
'state' => $state,
|
|
|
'invite_code' => $inviteCode,
|
|
|
'user_info' => $user ?? null,
|
|
|
+ 'openid' => $openid ?? null,
|
|
|
]);
|
|
|
throw new BusinessException('微信授权失败,请稍后重试');
|
|
|
}
|
|
@@ -183,7 +185,7 @@ class WechatService
|
|
|
/**
|
|
|
* 格式化性别信息
|
|
|
*
|
|
|
- * @param int|null $gender 微信返回��性别值:1为男性,2为女性,0为未知
|
|
|
+ * @param int|null $gender 微信返回的性别值:1为男性,2为女性,0为未知
|
|
|
* @return string|null male/female/null
|
|
|
*/
|
|
|
protected function formatGender(?int $gender): ?string
|