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