This commit is contained in:
Tokumeikoi 2020-04-26 19:15:13 +08:00
parent 42ad99065e
commit 99117cca58

View File

@ -138,16 +138,6 @@ class ServerService
public function log(int $userId, int $serverId, int $u, int $d, float $rate) public function log(int $userId, int $serverId, int $u, int $d, float $rate)
{ {
$serverLog = ServerLog::where('user_id', $userId)
->where('server_id', $serverId)
->where('created_at', '>=', strtotime(date('Y-m-d h:00:00')))
->orderBy('created_at', 'DESC')
->first();
if ($serverLog) {
$serverLog->u = $serverLog->u + $u;
$serverLog->d = $serverLog->d + $d;
$serverLog->save();
} else {
$serverLog = new ServerLog(); $serverLog = new ServerLog();
$serverLog->user_id = $userId; $serverLog->user_id = $userId;
$serverLog->server_id = $serverId; $serverLog->server_id = $serverId;
@ -156,5 +146,4 @@ class ServerService
$serverLog->rate = $rate; $serverLog->rate = $rate;
$serverLog->save(); $serverLog->save();
} }
}
} }