Compare commits

..
7 Commits
Author SHA1 Message Date
OG Backup 911ef2ce2c Merge branch 'main' of https://git.20031227.de5.net/og/Socket 2026-06-14 14:21:35 +08:00
OG Backup 2cd31285f0 backup: 线上最终版本全量备份
包含所有线上运行的改动:
- 荷官端倒计时卡顿修复(CountdownService TTL+10/前端watchdog)
- 停止下注debounce防重复(8个handle.js)
- 洗码量规则重写(单边/双边/开和不计/百家乐+龙虎)
- 龙虎和局不杀庄闲(全额退回)
- 日志系统(Logger工具类/日志查看/清理脚本)
- 好路提醒异常处理(WaybillRemindService try-catch)
- 扫牌器连接改进(ScanConnectService)
- 牛牛/三卡开牌修复
- .gitignore更新/.DS_Store清理
2026-06-14 14:20:43 +08:00
fengshao1227 73a8847ceb docs: 洗码量计算规则文档(客户2026-05-28确认的完整规则) 2026-05-29 06:14:20 +08:00
fengshao1227 e44d645547 fix: 洗码量按客户完整规则重写
百家乐+龙虎:
- 单边洗码(type_xima=2):输口计洗码,开和不计
- 双边洗码(type_xima=1):所有投注都计洗码,开和不计(庄闲退回部分除外)
- 龙虎和局不杀龙虎,全额退回
2026-05-29 05:37:40 +08:00
fengshao1227 c3621121ca fix: 龙虎洗码量改为所有输口之和,和局通杀龙虎计入洗码 2026-05-28 18:04:53 +08:00
fengshao1227 477ca7f6c9 fix: 百家乐洗码量改为所有输口投注额之和
原逻辑只算庄/闲的投注额,对子、和、幸运6、大小的输口不计入。
改为:所有输的位置的投注额都计入洗码量(庄、闲、和、庄对、闲对、幸运6、大小)。
2026-05-28 18:03:35 +08:00
testadmin 8edc071997 fix: 倒计时卡住根因修复 — Redis TTL缓冲+前端watchdog兜底
根因:CountdownService用while(sleep(1))阻塞循环推送倒计时,
Redis key TTL=wait_time,3台同时运行时worker争用导致循环慢于
Redis过期时间,key先过期→循环中断→倒计时冻结在当前秒数。

修复:
1. Redis TTL加10秒缓冲(waitTime+10),防止key提前过期
2. 前端加watchdog兜底:服务端2秒没推送就本地继续倒计时
2026-05-19 14:25:48 +08:00
15 changed files with 201 additions and 37 deletions
Executable
+1
View File
@@ -0,0 +1 @@
APP_DEBUG=true␍␍[APP]␍DEFAULT_TIMEZONE=Asia/Shanghai␍␍[DATABASE]␍TYPE=mysql␍HOSTNAME=127.0.0.1␍DATABASE=tnt_game␍USERNAME=root␍PASSWORD=shuijizai720␍HOSTPORT=3306␍CHARSET=utf8␍DEBUG=true␍␍[LANG]␍default_lang=zh-cn␍␍[SYSTEM]␍WEBSOCKET=ws.poker4u.club␍PROTOCOL=https␍LOGO_PATH=/static/logo/fop_180_180.png␍PLAYER=https://i.55player.com/zb.html␍dt_half = 1␍SB_SERVER=http://192.168.6.32:8080␍␍[SWOOLE]␍HOST=127.0.0.1␍PORT=8082␍DAEMONIZE=false␍␍[DOMAIN]␍CONSOLE=cz.poker4u.club␍BET=bet.poker4u.club
+24 -19
View File
@@ -188,11 +188,7 @@ class OpeningBaccaratService
}
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'] + $v['banker_pair_amount'] + $v['player_pair_amount'] + $v['luck_six_amount'] + $v['big_amount'] + $v['small_amount'];
$winMoney = 0;
// 双边洗码
$ximaliang = 0;
if($userInfo['type_xima'] == 1){
$ximaliang = abs($v['banker_amount'] - $v['player_amount']);
}
if($numberTabInfo['result'] == 1){
// 庄赢
if ($v['banker_amount'] > 0){
@@ -206,26 +202,26 @@ class OpeningBaccaratService
$winMoney = round($v['banker_amount'] * (1 + $userInfo['price_banker']),2) + $winMoney;
}
}
// 单边洗码
if($userInfo['type_xima'] == 2){
$ximaliang = $v['player_amount'];
if($userInfo['type_xima'] == 1){
$ximaliang = $amount;
}else{
$ximaliang += $v['player_amount'] + $v['tie_amount'];
}
}elseif($numberTabInfo['result'] == 2){
// 闲赢
if($v['player_amount'] > 0){
$winMoney = $v['player_amount'] * (1 + $userInfo['price_player']) + $winMoney;
}
// 单边洗码
if($userInfo['type_xima'] == 2){
$ximaliang = $v['banker_amount'];
if($userInfo['type_xima'] == 1){
$ximaliang = $amount;
}else{
$ximaliang += $v['banker_amount'] + $v['tie_amount'];
}
}elseif($numberTabInfo['result'] == 3) {
$ximaliang = 0;
// 和赢
// 和赢:庄闲退回,开和不计洗码
if($v['tie_amount'] > 0){
$winMoney = $v['tie_amount'] * (1 + $userInfo['price_tie_baccarat']) + $winMoney;
}
// 开 和,下注庄和闲不扣钱
if($v['banker_amount'] > 0 && $v['player_amount'] > 0){
$winMoney = $v['player_amount'] + $v['banker_amount'] + $winMoney;
}elseif($v['banker_amount'] > 0){
@@ -234,12 +230,11 @@ class OpeningBaccaratService
$winMoney = $v['player_amount'] + $winMoney;
}
}
// 对子
if($numberTabInfo['pair'] == 3){
// 计算庄对下注的赢钱金额
if ($v['banker_pair_amount'] > 0) {
$winMoney = $v['banker_pair_amount'] * (1 + $userInfo['price_pair']) + $winMoney;
}
//计算闲对下注的赢钱金额
if ($v['player_pair_amount'] > 0) {
$winMoney = $v['player_pair_amount'] * (1 + $userInfo['price_pair']) + $winMoney;
}
@@ -247,22 +242,32 @@ class OpeningBaccaratService
if ($v['banker_pair_amount'] > 0) {
$winMoney = $v['banker_pair_amount'] * (1 + $userInfo['price_pair']) + $winMoney;
}
if($userInfo['type_xima'] != 1) $ximaliang += $v['player_pair_amount'];
}elseif($numberTabInfo['pair'] == 2){
if ($v['player_pair_amount'] > 0) {
$winMoney = $v['player_pair_amount'] * (1 + $userInfo['price_pair']) + $winMoney;
}
if($userInfo['type_xima'] != 1) $ximaliang += $v['banker_pair_amount'];
}else{
if($userInfo['type_xima'] != 1) $ximaliang += $v['banker_pair_amount'] + $v['player_pair_amount'];
}
// 幸运6
if ($numberTabInfo['luck_six'] == 2 && $v['luck_six_amount'] > 0){
$winMoney = $v['luck_six_amount'] * (1 + $userInfo['price_luck_six_2']) + $winMoney;
}
if ($numberTabInfo['luck_six'] == 3 && $v['luck_six_amount'] > 0){
}elseif ($numberTabInfo['luck_six'] == 3 && $v['luck_six_amount'] > 0){
$winMoney = $v['luck_six_amount'] * (1 + $userInfo['price_luck_six_3']) + $winMoney;
}else{
if($userInfo['type_xima'] != 1) $ximaliang += $v['luck_six_amount'];
}
// 大小
if ($numberTabInfo['big_small'] == 1){
$winMoney = $v['big_amount'] * (1 + $userInfo['price_big']) + $winMoney;
}
if ($numberTabInfo['big_small'] == 2){
if($userInfo['type_xima'] != 1) $ximaliang += $v['small_amount'];
}elseif ($numberTabInfo['big_small'] == 2){
$winMoney = $v['small_amount'] * (1 + $userInfo['price_small']) + $winMoney;
if($userInfo['type_xima'] != 1) $ximaliang += $v['big_amount'];
}else{
if($userInfo['type_xima'] != 1) $ximaliang += $v['big_amount'] + $v['small_amount'];
}
// 计算最终赢钱金额
$winTotal = $winMoney - $amount;
+10 -16
View File
@@ -131,19 +131,16 @@ class OpeningDtService
}
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'];
$winMoney = 0;
// 双边洗码
$ximaliang = 0;
if($userInfo['type_xima'] == 1){
$ximaliang = abs($v['banker_amount'] - $v['player_amount']);
}
// 龙赢
if ($numberTabInfo['result'] == 1) {
if($v['banker_amount'] > 0){
$winMoney = round($v['banker_amount'] * (1 + $userInfo['price_dragon']),2) + $winMoney;
}
// 单边洗码
if($userInfo['type_xima'] == 2){
$ximaliang = $v['player_amount'];
if($userInfo['type_xima'] == 1){
$ximaliang = $amount;
}else{
$ximaliang = $v['player_amount'] + $v['tie_amount'];
}
}
// 虎赢
@@ -151,18 +148,15 @@ class OpeningDtService
if($v['player_amount'] > 0){
$winMoney = round($v['player_amount'] * (1 + $userInfo['price_tiger']),2) + $winMoney;
}
// 单边洗码
if($userInfo['type_xima'] == 2){
$ximaliang = $v['banker_amount'];
if($userInfo['type_xima'] == 1){
$ximaliang = $amount;
}else{
$ximaliang = $v['banker_amount'] + $v['tie_amount'];
}
}
// 和
// 和:不杀龙虎,全额退回
if ($numberTabInfo['result'] == 3) {
if (Env::get('system.dt_half') == 1) {
$winMoney = round(($v['banker_amount'] + $v['player_amount']) / 2, 2) + $winMoney;
} else {
$winMoney = $v['banker_amount'] + $v['player_amount'] + $winMoney;
}
$winMoney = $v['banker_amount'] + $v['player_amount'] + $winMoney;
$ximaliang = 0;
if ($v['tie_amount'] > 0) {
$winMoney = $v['tie_amount'] * (1 + $userInfo['price_tie_dt']) + $winMoney;
+1 -1
View File
@@ -27,7 +27,7 @@ class CountdownService
//处理倒计时
$waitTime = intval($tableInfo['wait_time']);
//将倒计时用作是redis的过期时间
RedisUtil::save('countdown_'.$numberTabInfo['id'],$waitTime,$waitTime);
RedisUtil::save('countdown_'.$numberTabInfo['id'],$waitTime,$waitTime + 10);
while($waitTime >= 0){
$countdown = Cache::store('redis')->get('countdown_'.$numberTabInfo['id']);
if ($countdown){
+61
View File
@@ -0,0 +1,61 @@
# 洗码量(码量)计算规则
> 客户在 2026-05-28 明确的完整规则,由此重写了开奖结算逻辑。
> 实现位置:`app/services/opening/OpeningBaccaratService.php`、`OpeningDtService.php`
## 核心定义
**洗码量 = 投注额(按原投注额度计,不乘赔率)**
系统有两种洗码模式,存于 `cg_user.type_xima`
| type_xima | 模式 | 规则 |
|-----------|------|------|
| 1 | 双边洗码 | **所有投注**都计洗码,开和不计 |
| 2 | 单边洗码 | 只有**输口**计洗码,开和不计 |
> 注意:历史代码里 type_xima 的语义曾被误用为 `1=双边/2=单边`,已确认数据库中
> 单边洗码会员是 `type_xima=2`。
## 百家乐(game_id=1
下注位置:庄、闲、和、庄对、闲对、幸运6、大、小
**单边洗码(type_xima=2)— 输口计洗码:**
- 庄赢:洗码 = 闲 + 和 + 没中的对子 + 没中的幸运6 + 没中的大小
- 闲赢:洗码 = 庄 + 和 + 没中的对子 + 没中的幸运6 + 没中的大小
- 和局:庄闲退回不计,洗码 = 没中的对子 + 没中的幸运6 + 没中的大小
**双边洗码(type_xima=1)— 所有投注都计洗码:**
- 庄赢/闲赢:洗码 = 全部投注额(`$amount`
- 和局:庄闲退回部分不计,其余照常(开和不计核心投注)
## 龙虎(game_id=2
下注位置:龙、虎、和
- **和局不杀龙虎**,龙虎全额退回(dt_half 旧逻辑"和局杀一半"已废除)
- 单边洗码:龙赢→洗码=虎+和;虎赢→洗码=龙+和
- 双边洗码:龙赢/虎赢→洗码=全部投注额;和局→0
- 赔率:龙/虎 1:0.97,和 1:40
## 百家乐赔率补充
- 庄 1:0.95,闲 1:1,和 1:8
- 免佣模式(baccarat_type=1):庄赢且非幸运6 时 1:1,幸运6 时 1:0.5
## 关键代码模式
```php
// 输口判断:开出的结果 != 投注位置 → 该位置投注额计入 ximaliang
if($userInfo['type_xima'] == 1){
$ximaliang = $amount; // 双边:全部投注
}else{
$ximaliang += <各输口投注额>; // 单边:仅输口
}
// 开和:庄闲退回,ximaliang 不累加这部分
```
## 数据落地
- 洗码记录写入 `cg_xima` 表,字段 `ximaliang`(原投注额)、`maliang`=ximaliang×码率)、`net_maliang`
- 开奖时(OpeningXxxService→Bet::openingBet)实时按各级代理当前码率计算并落库
- **码率/占成在开奖时实时读 DB**,改了码率只影响之后开的局,已开未结的局不变
Regular → Executable
+1 -1
View File
@@ -1 +1 @@
open_basedir=/www/wwwroot/tnt-game-socket/:/tmp/
open_basedir=/www/wwwroot/Socket/:/tmp/
+7
View File
@@ -0,0 +1,7 @@
<?php
//花式
$pattern = intval(substr(113,0,1));
//点数
$number = intval(substr(413,1,2));
var_dump($pattern);
var_dump($number);
+12
View File
@@ -532,9 +532,21 @@ websocket.on('resetBoot',function(data){
}
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){
+12
View File
@@ -259,9 +259,21 @@ websocket.on('resetBoot',function(data){
layer.msg(lang[data.msg]);
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){
+12
View File
@@ -504,9 +504,21 @@ websocket.on('resetBoot',function(data){
}
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){
@@ -520,9 +520,21 @@ websocket.on('resetBoot',function(data){
}
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){
+12
View File
@@ -197,9 +197,21 @@ websocket.on('resetBoot',function(data){
}
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){
+12
View File
@@ -495,9 +495,21 @@ websocket.on('resetBoot',function(data){
}
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){
+12
View File
@@ -565,9 +565,21 @@ websocket.on('resetBoot',function(data){
}
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){
@@ -177,9 +177,21 @@ websocket.on('resetBoot',function(data){
}
}
});
var _cdTimer = null;
var _cdVal = 0;
websocket.on('startBetCountDown',function(data){
if(data.status == true && data.table_id == table_id){
_cdVal = data.count_down;
countDown(data.count_down);
if(_cdTimer) clearTimeout(_cdTimer);
if(_cdVal > 0){
_cdTimer = setTimeout(function _tick(){
_cdVal--;
if(_cdVal >= 0) countDown(_cdVal);
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
else _cdTimer = null;
}, 2000);
}
}
});
websocket.on('endBet',function(data){