|
@@ -141,12 +141,9 @@ class WechatOfficialController extends HttpBaseController
|
|
$productTitle = $productInfo -> title;
|
|
$productTitle = $productInfo -> title;
|
|
}
|
|
}
|
|
if ($isExistUser) {
|
|
if ($isExistUser) {
|
|
- $isSuccess = true;
|
|
|
|
$userId = $isExistUser->id; // 用户id
|
|
$userId = $isExistUser->id; // 用户id
|
|
$nickname = $isExistUser->mid; //用户的mid
|
|
$nickname = $isExistUser->mid; //用户的mid
|
|
- Log::info('2222222222222222222222222 === ' . 'userid' . $isExistUser->id );
|
|
|
|
} else {
|
|
} else {
|
|
- Log::info('33333333333333333333333333333333333 === ' . 'nickname' . $nickname);
|
|
|
|
// 插入数据
|
|
// 插入数据
|
|
$isSuccess = DB::transaction(function () use ($openid, $nickname, $avatar, $unionid, $wxInfo) {
|
|
$isSuccess = DB::transaction(function () use ($openid, $nickname, $avatar, $unionid, $wxInfo) {
|
|
$mid = Str::random(12);
|
|
$mid = Str::random(12);
|
|
@@ -180,40 +177,35 @@ class WechatOfficialController extends HttpBaseController
|
|
'userId' => $userId,
|
|
'userId' => $userId,
|
|
'nickname' => $nickname
|
|
'nickname' => $nickname
|
|
];
|
|
];
|
|
- Log::info('666666666666666666666666666666 === ' . 'id' . $returnInfo['nickname']);
|
|
|
|
return $returnInfo;
|
|
return $returnInfo;
|
|
//return $userId;
|
|
//return $userId;
|
|
});
|
|
});
|
|
- Log::info('555555555555555555555555555 === ' . 'id' . $isSuccess -> userId);
|
|
|
|
- $userId = $isSuccess -> userId; // 用户id
|
|
|
|
-
|
|
|
|
|
|
+ $userId = $isSuccess['userId']; // 用户id
|
|
|
|
+ $nickname = $isSuccess['nickname']; //用户名
|
|
}
|
|
}
|
|
|
|
|
|
- if ($isSuccess) {
|
|
|
|
- $oauthUrl = 'https://www.xingyousoft.com';
|
|
|
|
- if ($sceneStr) {
|
|
|
|
- $oauthUrl = $this->app->oauth->withState(base64_encode($sceneStr))->redirect();
|
|
|
|
- }
|
|
|
|
- Log::info('4444444444444444444444444444444 === ' . 'nickname' . $nickname);
|
|
|
|
- // 发送登录成功消息
|
|
|
|
- $this->app->template_message->send([
|
|
|
|
- 'touser' => $openid,
|
|
|
|
- 'template_id' => 'demGYbEZInVgvwO1ClJNuz2Hc-0FYWZp_duv7HSgdmw',
|
|
|
|
- 'url' => $oauthUrl,
|
|
|
|
- 'data' => [
|
|
|
|
- 'thing2' => $nickname,
|
|
|
|
- 'thing3' => $productTitle,
|
|
|
|
- 'time6' => date('Y-m-d H:i:s')
|
|
|
|
- ]
|
|
|
|
- ]);
|
|
|
|
- // 保存生成token需要的信息
|
|
|
|
- $loginToken = new LoginTokenService($this->siteInfo['token_table']);
|
|
|
|
- $token = $loginToken->createOnlyOneToken($userId, $productMid);
|
|
|
|
- Cache::put('TOKEN_' . $sceneStr, $token, 5 * 60); // 有效期5分钟
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- abort(500, '登录授权失败,请稍后再试!');
|
|
|
|
|
|
+ $oauthUrl = 'https://www.xingyousoft.com';
|
|
|
|
+ if ($sceneStr) {
|
|
|
|
+ $oauthUrl = $this->app->oauth->withState(base64_encode($sceneStr))->redirect();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 发送登录成功消息
|
|
|
|
+ $this->app->template_message->send([
|
|
|
|
+ 'touser' => $openid,
|
|
|
|
+ 'template_id' => 'demGYbEZInVgvwO1ClJNuz2Hc-0FYWZp_duv7HSgdmw',
|
|
|
|
+ 'url' => $oauthUrl,
|
|
|
|
+ 'data' => [
|
|
|
|
+ 'thing2' => $nickname,
|
|
|
|
+ 'thing3' => $productTitle,
|
|
|
|
+ 'time6' => date('Y-m-d H:i:s')
|
|
|
|
+ ]
|
|
|
|
+ ]);
|
|
|
|
+ // 保存生成token需要的信息
|
|
|
|
+ $loginToken = new LoginTokenService($this->siteInfo['token_table']);
|
|
|
|
+ $token = $loginToken->createOnlyOneToken($userId, $productMid);
|
|
|
|
+ Cache::put('TOKEN_' . $sceneStr, $token, 5 * 60); // 有效期5分钟
|
|
|
|
+ return true;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private function msgEvent($event, $message)
|
|
private function msgEvent($event, $message)
|