mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: server log fetch
This commit is contained in:
parent
91418caf04
commit
0c14652ff7
@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use App\Utils\Helper;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
|
@ -13,4 +13,8 @@ class ServerLog extends Model
|
||||
'created_at' => 'timestamp',
|
||||
'updated_at' => 'timestamp'
|
||||
];
|
||||
protected $fillable = [
|
||||
'u',
|
||||
'd'
|
||||
];
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use App\Models\Server;
|
||||
use App\Models\ServerTrojan;
|
||||
use App\Utils\CacheKey;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ServerService
|
||||
{
|
||||
@ -268,12 +269,18 @@ class ServerService
|
||||
->where('user_id', $userId)
|
||||
->where('rate', $rate)
|
||||
->where('method', $method)
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if ($serverLog) {
|
||||
$serverLog->u = $serverLog->u + $u;
|
||||
$serverLog->d = $serverLog->d + $d;
|
||||
return $serverLog->save();
|
||||
try {
|
||||
$serverLog->update([
|
||||
'u' => DB::raw("u+{$u}"),
|
||||
'd' => DB::raw("d+{$d}")
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
info($e);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$serverLog = new ServerLog();
|
||||
$serverLog->user_id = $userId;
|
||||
|
Loading…
Reference in New Issue
Block a user