mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
update
This commit is contained in:
parent
9158697546
commit
f7959dcd93
@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ServerLog extends Model
|
||||
{
|
||||
|
@ -138,12 +138,27 @@ class ServerService
|
||||
|
||||
public function log(int $userId, int $serverId, int $u, int $d, float $rate)
|
||||
{
|
||||
if (($u + $d) <= 10240) return;
|
||||
$timestamp = strtotime(date('Y-m-d H:0'));
|
||||
$serverLog = ServerLog::where('log_at', '>=', $timestamp)
|
||||
->where('log_at', '<', $timestamp + 3600)
|
||||
->where('server_id', $serverId)
|
||||
->where('user_id', $userId)
|
||||
->where('rate', $rate)
|
||||
->first();
|
||||
if ($serverLog) {
|
||||
$serverLog->u = $serverLog->u + $u;
|
||||
$serverLog->d = $serverLog->d + $u;
|
||||
$serverLog->save();
|
||||
} else {
|
||||
$serverLog = new ServerLog();
|
||||
$serverLog->user_id = $userId;
|
||||
$serverLog->server_id = $serverId;
|
||||
$serverLog->u = $u;
|
||||
$serverLog->d = $d;
|
||||
$serverLog->rate = $rate;
|
||||
$serverLog->log_at = $timestamp;
|
||||
$serverLog->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ CREATE TABLE `v2_server_log` (
|
||||
`u` varchar(255) NOT NULL,
|
||||
`d` varchar(255) NOT NULL,
|
||||
`rate` decimal(10,2) NOT NULL,
|
||||
`log_at` int(11) NOT NULL,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`updated_at` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
|
@ -238,3 +238,6 @@ ADD `reset_price` int(11) NULL AFTER `onetime_price`;
|
||||
|
||||
ALTER TABLE `v2_server_log`
|
||||
ADD `id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
|
||||
|
||||
ALTER TABLE `v2_server_log`
|
||||
ADD `log_at` int(11) NOT NULL AFTER `rate`;
|
||||
|
Loading…
Reference in New Issue
Block a user