|
|
|
@ -225,7 +225,7 @@ class UserService
|
|
|
|
|
$userToken = $this->generateToken($user['id'], $user['account'], $password) . uniqid() . rand(1000, 9999);
|
|
|
|
|
$record = M('user_token','tab_')->where(['user_id' => $user['id'], 'game_id' => $game['id']])->find();
|
|
|
|
|
if (!$record) {
|
|
|
|
|
M('user_token', 'tab_')->add([
|
|
|
|
|
$status = M('user_token', 'tab_')->add([
|
|
|
|
|
'user_id' => $user['id'],
|
|
|
|
|
'game_id' => $game['id'],
|
|
|
|
|
'relation_game_id' => $game['relation_game_id'],
|
|
|
|
@ -234,6 +234,10 @@ class UserService
|
|
|
|
|
'create_time' => time(),
|
|
|
|
|
'update_time' => time()
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (!$status) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
M('user_token', 'tab_')->where([
|
|
|
|
|
'user_id' => $user['id'],
|
|
|
|
@ -244,14 +248,17 @@ class UserService
|
|
|
|
|
'update_time' => time()
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
M('user_token', 'tab_')->where([
|
|
|
|
|
$status = M('user_token', 'tab_')->where([
|
|
|
|
|
'user_id' => $uid,
|
|
|
|
|
'game_id|relation_game_id' => $game['relation_game_id']
|
|
|
|
|
])->save([
|
|
|
|
|
'user_token' => $userToken,
|
|
|
|
|
'login_cnt' => $record['login_cnt'] + 1,
|
|
|
|
|
'update_time' => time()
|
|
|
|
|
]);
|
|
|
|
|
]);
|
|
|
|
|
if ($status === false) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return [$token, $userToken];
|
|
|
|
|
}
|
|
|
|
|