1.优化websocket接口,新增赔率参数

This commit is contained in:
2026-05-15 16:24:19 +08:00
parent 575aa279bd
commit 91229f4477
13 changed files with 434 additions and 40 deletions

View File

@@ -14,6 +14,7 @@ use app\common\service\GameHotDataCoordinator;
use app\common\service\GameHotDataRedis;
use app\common\service\GameRecordService;
use app\common\service\GameWebSocketEventBus;
use app\common\service\GameWebSocketPayloadHelper;
use support\think\Db;
use Webman\Http\Request;
use support\Response;
@@ -49,6 +50,9 @@ class Game extends MobileBase
}
$user = $this->auth->getUser();
$currentStreakRaw = $user->current_streak ?? 0;
$currentStreakParsed = filter_var($currentStreakRaw, FILTER_VALIDATE_INT);
$currentStreak = $currentStreakParsed === false ? 0 : $currentStreakParsed;
return $this->mobileSuccess([
'server_time' => $now,
'runtime_enabled' => GameRecordService::getConfigBool(GameRecordService::KEY_AUTO_CREATE),
@@ -68,11 +72,12 @@ class Game extends MobileBase
BetChips::lobbyChipsPayload()
),
'dictionary' => $items,
'streak_win_reward' => StreakWinReward::lobbyPayload(),
'user_snapshot' => [
'coin' => $user->coin,
'current_streak' => $user->current_streak ?? 0,
],
'user_snapshot' => array_merge(
[
'coin' => $user->coin,
],
StreakWinReward::playerBetOddsForCurrentStreak($currentStreak)
),
]);
}
@@ -280,7 +285,7 @@ class Game extends MobileBase
}
GameHotDataCoordinator::afterUserCommitted($userId);
GameWebSocketEventBus::publish('bet.accepted', [
GameWebSocketEventBus::publish('bet.accepted', GameWebSocketPayloadHelper::mergeUserStreakInto([
'user_id' => $userId,
'period_no' => $period->period_no,
'numbers' => $numbers,
@@ -290,13 +295,13 @@ class Game extends MobileBase
'total_amount' => $totalAmount,
'balance_after' => $after,
'accepted_at' => time(),
]);
GameWebSocketEventBus::publish('wallet.changed', [
], $userId, $streakAtBet));
GameWebSocketEventBus::publish('wallet.changed', GameWebSocketPayloadHelper::mergeUserStreakInto([
'user_id' => $userId,
'balance_after' => $after,
'biz_type' => 'bet',
'changed_at' => time(),
]);
], $userId, $streakAtBet));
return $this->mobileSuccess([
'order_no' => $orderNo,
'period_no' => $period->period_no,