包含所有线上运行的改动: - 荷官端倒计时卡顿修复(CountdownService TTL+10/前端watchdog) - 停止下注debounce防重复(8个handle.js) - 洗码量规则重写(单边/双边/开和不计/百家乐+龙虎) - 龙虎和局不杀庄闲(全额退回) - 日志系统(Logger工具类/日志查看/清理脚本) - 好路提醒异常处理(WaybillRemindService try-catch) - 扫牌器连接改进(ScanConnectService) - 牛牛/三卡开牌修复 - .gitignore更新/.DS_Store清理
75 lines
3.1 KiB
PHP
75 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace app\services\bet;
|
|
|
|
use app\models\bet\Bet;
|
|
use app\utils\Logger;
|
|
use freedom\utils\RouletteUtil;
|
|
use freedom\utils\SocketSession;
|
|
|
|
/**
|
|
* TODO ToBetRouletteService
|
|
* Class ToBetRouletteService
|
|
* @package app\services\bet
|
|
*/
|
|
|
|
class ToBetRouletteService{
|
|
|
|
/**
|
|
* TODO 处理轮盘下注
|
|
* @param array $event
|
|
* @param array $tableInfo
|
|
* @return void
|
|
*/
|
|
public static function toBetRoulette(array $event, array $tableInfo){
|
|
$ws = app('\think\swoole\WebSocket');
|
|
$fd = $ws->getSender();
|
|
$data = array();
|
|
$event_amount = $event['amount'];
|
|
$fieldName = 'roulette_'.$event['roulette_type'].'_amount';
|
|
foreach ($event_amount as $k => $v){
|
|
if (intval($v) > 0){
|
|
$data[$k] = intval($v);
|
|
}
|
|
}
|
|
$seat_num = isset($event['seat_num']) && intval($event['seat_num']) > 0 ? intval($event['seat_num']) : 0;
|
|
|
|
$time = time();
|
|
$toBetCheck = ToBetCommonService::toBetCheck($tableInfo,$event,$data);
|
|
if ($toBetCheck['status'] == false){
|
|
Logger::warn(Logger::CAT_BET, 'roulette_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
|
|
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
|
|
SocketSession::resetRepeat($fd,'user','isToBet');
|
|
return;
|
|
}
|
|
$numberTabInfo = $toBetCheck['numberTabInfo'];
|
|
$userInfo = $toBetCheck['userInfo'];
|
|
$amount = array_sum($data);
|
|
$prevBetInfo = Bet::getPrevBetInfo($userInfo['id'],$numberTabInfo['id']);
|
|
|
|
if($prevBetInfo){
|
|
$beforeAmount = string_to_array($prevBetInfo[$fieldName]);
|
|
$betTotalAmount = RouletteUtil::amountInc($beforeAmount, $data);
|
|
}else{
|
|
$betTotalAmount = $data;
|
|
}
|
|
$res = Bet::toBet($tableInfo,$userInfo,$numberTabInfo,$prevBetInfo,$data,$seat_num,$betTotalAmount,$time,0,$fieldName);
|
|
$numberTabAmount = string_to_array($numberTabInfo[$fieldName]);
|
|
if($res){
|
|
Logger::info(Logger::CAT_BET, 'roulette_bet_success', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
|
|
$ws->emit('toBet',['status' => true, 'table_id' => $tableInfo['id'], 'bet_amount_msg' => [$fieldName => $betTotalAmount], 'money' => ($userInfo['money'] - $amount),'seat_num' => $seat_num, 'msg' => 'to_bet_success']);
|
|
$totalAmountArray = RouletteUtil::amountInc($numberTabAmount, $data);
|
|
$round = [
|
|
'amount_total' => $totalAmountArray,
|
|
'amount_item' => $data
|
|
];
|
|
$ws->to(SocketSession::HOUSE_NAME)->emit('allBetAmount',['status' => true, 'table_id' => $tableInfo['id'], 'round' => $round]);
|
|
}else{
|
|
Logger::warn(Logger::CAT_BET, 'roulette_bet_db_fail', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
|
|
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => 'to_bet_fail']);
|
|
}
|
|
SocketSession::resetRepeat($fd,'user','isToBet');
|
|
}
|
|
|
|
}
|