|
@@ -422,22 +422,48 @@ class AuthController
|
|
|
return app('json')->fail('验证码错误');
|
|
|
|
|
|
$userInfo = User::where('uid', $request->uid())->find();
|
|
|
- $userPhone = $userInfo->phone;
|
|
|
- if (!$userInfo) return app('json')->fail('用户不存在');
|
|
|
+ $new_whchat = WechatUser::where('uid', $userInfo['uid'])->find();
|
|
|
+ $userOld = User::where('phone', $phone)->find();
|
|
|
if ($userInfo->phone) return app('json')->fail('您的账号已经绑定过手机号码!');
|
|
|
- if (User::where('phone', $phone)->where('user_type', '<>', 'h5')->count())
|
|
|
- return app('json')->success('此手机已经绑定,无法多次绑定!');
|
|
|
- if (User::where('account', $phone)->where('phone', $phone)->where('user_type', 'h5')->find()) {
|
|
|
- if (!$step) return app('json')->success('H5已有账号是否绑定此账号上', ['is_bind' => 1]);
|
|
|
- $userInfo->phone = $phone;
|
|
|
- } else {
|
|
|
- $userInfo->account = $phone;
|
|
|
- $userInfo->phone = $phone;
|
|
|
+ if ($userOld and $new_whchat['routine_openid']){
|
|
|
+ $old_whchat = WechatUser::where('uid', $userOld['uid'])->find();
|
|
|
+ $old_whchat['unionid'] = $new_whchat['unionid'];
|
|
|
+ $old_whchat['routine_openid'] = $new_whchat['routine_openid'];
|
|
|
+ $userOld['phone'] = $phone;
|
|
|
+ $old_whchat->save();
|
|
|
+ $userOld->save();
|
|
|
+ $userInfo->delete();
|
|
|
+ $new_whchat->delete();
|
|
|
+ $token = UserToken::createToken($userOld, 'h5');
|
|
|
+ if ($token) {
|
|
|
+ event('UserLogin', [$userOld, $token]);
|
|
|
+ return app('json')->successful('登陆成功!', [
|
|
|
+ 'token' => $token->token,
|
|
|
+ 'userInfo' => $userOld,
|
|
|
+ 'expires_time' => strtotime($token->expires_time),
|
|
|
+ 'cache_key' => ''
|
|
|
+ ]);
|
|
|
+ } else
|
|
|
+ return app('json')->fail('获取用户访问token失败!');
|
|
|
+ }else{
|
|
|
+ $userPhone = $userInfo->phone;
|
|
|
+ if (!$userInfo) return app('json')->fail('用户不存在');
|
|
|
+ if ($userInfo->phone) return app('json')->fail('您的账号已经绑定过手机号码!');
|
|
|
+ if (User::where('phone', $phone)->where('user_type', '<>', 'h5')->count())
|
|
|
+ return app('json')->success('此手机已经绑定,无法多次绑定!');
|
|
|
+ if (User::where('account', $phone)->where('phone', $phone)->where('user_type', 'h5')->find()) {
|
|
|
+ if (!$step) return app('json')->success('H5已有账号是否绑定此账号上', ['is_bind' => 1]);
|
|
|
+ $userInfo->phone = $phone;
|
|
|
+ } else {
|
|
|
+ $userInfo->account = $phone;
|
|
|
+ $userInfo->phone = $phone;
|
|
|
+ }
|
|
|
+ if ($userInfo->save() || $userPhone == $phone)
|
|
|
+ return app('json')->success('绑定成功');
|
|
|
+ else
|
|
|
+ return app('json')->fail('绑定失败');
|
|
|
}
|
|
|
- if ($userInfo->save() || $userPhone == $phone)
|
|
|
- return app('json')->success('绑定成功');
|
|
|
- else
|
|
|
- return app('json')->fail('绑定失败');
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function brc()
|
|
@@ -457,7 +483,7 @@ class AuthController
|
|
|
*/
|
|
|
public function app_auth(Request $request)
|
|
|
{
|
|
|
-// Db::query("DELETE from eb_wechat_user where uid not in (select uid from eb_user)");
|
|
|
+ Db::query("DELETE from eb_wechat_user where uid not in (select uid from eb_user)");
|
|
|
$cache_key = '';
|
|
|
$userInfo = UtilService::postMore([
|
|
|
['openId', ''],
|