Socket/app/services/process/EndBetService.php
2026-01-28 23:48:20 +08:00

48 lines
1.5 KiB
PHP

<?php
namespace app\services\process;
use app\models\process\NumberTab;
use app\services\connect\InitTableService;
use freedom\utils\RedisUtil;
use freedom\utils\SocketSession;
/**
* TODO 结束倒计时
* Class EndBetService
* @package app\services\process
*/
class EndBetService
{
/**
* TODO 处理结束倒计时
* @param int $numberTabId
* @param array $tableInfo
* @return void
*/
public static function endBet(int $numberTabId, array $tableInfo){
$ws = app('\think\swoole\WebSocket');
$modelRes = NumberTab::endBet($numberTabId);
if ($modelRes['status'] == true){
$numberTabInfo = $modelRes['data'];
//清除Redis
RedisUtil::delete('countdown_'.$numberTabInfo['id']);
$ws->to(SocketSession::HOUSE_NAME)->emit('endBet',[
'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)
]
]);
}else{
$ws->emit('endBet', ['status' => false, 'msg' => $modelRes['msg']]);
}
}
}