Tree 14 часов назад
Родитель
Сommit
b179a9d6e5
3 измененных файлов с 92 добавлено и 0 удалено
  1. 82 0
      app/Console/Commands/CheckStockModeNegative.php
  2. 4 0
      app/Console/Kernel.php
  3. 6 0
      routes/api.php

+ 82 - 0
app/Console/Commands/CheckStockModeNegative.php

@@ -0,0 +1,82 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Notification\TelegramBot;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+
+class CheckStockModeNegative extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'stock_mode:check_negative';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Check stock-mode rooms (low/mid/high) and send Telegram alert when Stock is negative';
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        // 低/中/高三个房间:SortID 1,2,3
+        $rooms = DB::connection('write')
+            ->table('QPPlatformDB.dbo.RoomStockStatic2')
+            ->where('GameID', 0)
+            ->whereIn('SortID', [1, 2, 3])
+            ->get();
+
+        if ($rooms->isEmpty()) {
+            return 0;
+        }
+
+        $negativeRooms = [];
+        foreach ($rooms as $room) {
+            if ($room->Stock < 0) {
+                // 数据库存储的是 *100 后的值,这里除以 100 便于阅读
+                $negativeRooms[] = [
+                    'sort_id' => $room->SortID,
+                    'stock_raw' => $room->Stock,
+                    'stock' => round($room->Stock / 100, 2),
+                    'level_base' => isset($room->LevelBase) ? round($room->LevelBase / 100, 2) : null,
+                ];
+            }
+        }
+
+        if (empty($negativeRooms)) {
+            return 0;
+        }
+
+        $lines = [];
+        $lines[] = '【库存模式报警】RoomStockStatic2 库存为负';
+        $lines[] = '时间: ' . date('Y-m-d H:i:s');
+        foreach ($negativeRooms as $info) {
+            $lines[] = sprintf(
+                '房间 SortID=%d, Stock=%s (原始=%d), LevelBase=%s',
+                $info['sort_id'],
+                $info['stock'],
+                $info['stock_raw'],
+                $info['level_base'] === null ? '-' : $info['level_base']
+            );
+        }
+
+        try {
+            TelegramBot::getDefault()->sendMsgWithEnv(implode("\n", $lines));
+        } catch (\Throwable $e) {
+            $this->error('Failed to send Telegram alert: ' . $e->getMessage());
+        }
+
+        return 0;
+    }
+}
+

+ 4 - 0
app/Console/Kernel.php

@@ -3,6 +3,7 @@
 namespace App\Console;
 
 use App\Console\Commands\CheckIosAppStore;
+use App\Console\Commands\CheckStockModeNegative;
 use App\Console\Commands\DbQueue;
 use App\Console\Commands\OnlineReport;
 use App\Console\Commands\DecStock;
@@ -29,6 +30,7 @@ class Kernel extends ConsoleKernel
         ExemptReview::class,
         PayOrder::class,
         Extension::class,
+        CheckStockModeNegative::class,
         RecordPlatformData::class,
         RecordServerGameCount::class,
         RecordServerGameCountYesterday::class,
@@ -39,6 +41,7 @@ class Kernel extends ConsoleKernel
         DbQueue::class,
         RecordThreeGameYesterday::class,
         SuperballUpdatePoolAndStats::class,
+
     ];
 
     /**
@@ -52,6 +55,7 @@ class Kernel extends ConsoleKernel
 //        $schedule->command('db_queue')->everyMinute()->description('批量处理redis队列任务');
         $schedule->command('exempt_review')->everyMinute()->description('免审提现');
         $schedule->command('record_server_game_count')->cron('*/15 * * * * ')->description('按天统计游戏人数');
+        $schedule->command('stock_mode:check_negative')->cron('*/5 * * * *')->description('检测库存模式房间库存是否为负并通过 Telegram 报警');
         $schedule->command('online_max')->cron('*/8 * * * * ')->description('最高在线人数统计');
         $schedule->command('record_server_game_count_yesterday')->cron('05 0 * * * ')->description('按天统计游戏人数--今日执行昨日');
         $schedule->command('RecordPlatformData')->cron('10 0 * * * ')->description('数据统计');

+ 6 - 0
routes/api.php

@@ -25,6 +25,12 @@ Route::any('/apk/test', 'Api\ApkController@test');
 Route::any('/apk/checkpay2', 'Api\ApkController@check_user_pay2');
 Route::post('/user/message', 'Api\ApiController@userMessageAdd');
 Route::any('/log', 'Api\ApiController@log');
+Route::any('/weblog', 'Api\ApiController@weblog');
+Route::any('/init-h5-client', 'Api\ApiController@inith5client');
+Route::any('/sendfbevent', 'Api\ApiController@sendfbevent');
+Route::any('/sendggevent', 'Api\ApiController@sendggevent');
+Route::any('/push_subscribe', 'Api\ApiController@pushSubscribe');
+Route::any('/upload_subscribe_state', 'Api\ApiController@uploadSubscribeState');
 Route::any('/callback_start', 'Api\AccCallbackController@send');
 Route::any('/error_report', 'Api\ApiController@errorReport');
 Route::any('/adjust_test', 'Api\ApiController@adjust');