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;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
|
use App\Models\User;
|
||||||
use App\Utils\Helper;
|
use App\Utils\Helper;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
@ -13,4 +13,8 @@ class ServerLog extends Model
|
|||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
'updated_at' => 'timestamp'
|
'updated_at' => 'timestamp'
|
||||||
];
|
];
|
||||||
|
protected $fillable = [
|
||||||
|
'u',
|
||||||
|
'd'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ use App\Models\Server;
|
|||||||
use App\Models\ServerTrojan;
|
use App\Models\ServerTrojan;
|
||||||
use App\Utils\CacheKey;
|
use App\Utils\CacheKey;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class ServerService
|
class ServerService
|
||||||
{
|
{
|
||||||
@ -268,12 +269,18 @@ class ServerService
|
|||||||
->where('user_id', $userId)
|
->where('user_id', $userId)
|
||||||
->where('rate', $rate)
|
->where('rate', $rate)
|
||||||
->where('method', $method)
|
->where('method', $method)
|
||||||
->lockForUpdate()
|
|
||||||
->first();
|
->first();
|
||||||
if ($serverLog) {
|
if ($serverLog) {
|
||||||
$serverLog->u = $serverLog->u + $u;
|
try {
|
||||||
$serverLog->d = $serverLog->d + $d;
|
$serverLog->update([
|
||||||
return $serverLog->save();
|
'u' => DB::raw("u+{$u}"),
|
||||||
|
'd' => DB::raw("d+{$d}")
|
||||||
|
]);
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
info($e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$serverLog = new ServerLog();
|
$serverLog = new ServerLog();
|
||||||
$serverLog->user_id = $userId;
|
$serverLog->user_id = $userId;
|
||||||
|
Loading…
Reference in New Issue
Block a user