mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update: rollback traffic fetch
This commit is contained in:
parent
8a58a1ad88
commit
3600c9a166
@ -82,17 +82,15 @@ class UserService
|
|||||||
|
|
||||||
public function trafficFetch(int $u, int $d, int $userId, object $server, string $protocol):bool
|
public function trafficFetch(int $u, int $d, int $userId, object $server, string $protocol):bool
|
||||||
{
|
{
|
||||||
$user = User::find($userId);
|
$user = User::lockForUpdate()
|
||||||
|
->find($userId);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
$user->t = time();
|
||||||
$user->update([
|
$user->u = $user->u + $u;
|
||||||
't' => time(),
|
$user->d = $user->d + $d;
|
||||||
'u' => DB::raw("u + {$u}"),
|
if (!$user->save()) {
|
||||||
'd' => DB::raw("d + {$d}")
|
|
||||||
]);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$mailService = new MailService();
|
$mailService = new MailService();
|
||||||
|
Loading…
Reference in New Issue
Block a user