Files
Socket/app/services/process/StartBetService.php
T
testadmin d77c6beac7 feat: add logging module for backend + frontend error reporting
Backend:
- New Logger utility (app/utils/Logger.php) with category-based log files
  (connect/game/bet/error/frontend under runtime/log/)
- Log WebSocket connect/close events (WsConnect, WsClose)
- Log dealer auth success/failure (SpaceConnectService)
- Log all game events: startBet, endBet, changeBoot, opening for all 7 game types
- Log unhandled exceptions (ExceptionHandle)
- Separate SQL/error logs via apart_level, enable realtime_write for Swoole
- Add /log/report POST endpoint for frontend error ingestion

Frontend:
- New error-report.js with window.onerror + unhandledrejection auto-reporting
- Added to all 12 dealer HTML templates
- Bump VERSION_V to v10.1.0
2026-05-14 11:28:33 +08:00

54 lines
2.0 KiB
PHP

<?php
namespace app\services\process;
use app\models\process\NumberTab;
use app\services\connect\InitTableService;
use app\utils\Logger;
use freedom\utils\SocketSession;
/**
* TODO 开始倒计时
* Class StartBetService
* @package app\services\process
*/
class StartBetService
{
/**
* TODO 处理开始倒计时
* @param int $numberTabId
* @param array $tableInfo
* @return void
*/
public static function startBet(int $numberTabId, array $tableInfo){
$ws = app('\think\swoole\WebSocket');
$modelRes = NumberTab::startBet($numberTabId);
if ($modelRes['status'] == true){
$numberTabInfo = $modelRes['data'];
$responseData = [
'status' => true,
'table_id' => $tableInfo['id'],
'round' => [
'boot_id' => $numberTabInfo['boot_id'],
'boot_num' => $numberTabInfo['boot_num'],
'number_tab_id' => $numberTabInfo['id'],
'number_tab_number' => $numberTabInfo['number'],
'in_checkout' => $tableInfo['in_checkout'],
'number_tab_status' => InitTableService::numberTabStatus($numberTabInfo)
]
];
// 广播到 house 房间
$ws->to(SocketSession::HOUSE_NAME)->emit('startBet', $responseData);
// 同时发送给请求者
$ws->emit('startBet', $responseData);
//启动倒计时(该处以后会废弃掉)
CountdownService::countdown($numberTabId,$tableInfo,$modelRes['data']);
Logger::info(Logger::CAT_GAME, 'start_bet', ['table_id' => $tableInfo['id'], 'table_name' => $tableInfo['table_name'], 'nt_id' => $numberTabId]);
}else{
Logger::warn(Logger::CAT_GAME, 'start_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $modelRes['msg']]);
$ws->emit('startBet', ['status' => false, 'msg' => $modelRes['msg']]);
}
}
}