红包领取增加全员通知

This commit is contained in:
pllx
2026-04-30 15:52:16 +08:00
parent 9764961519
commit 92e3dd0cdf
3 changed files with 47 additions and 20 deletions
+25 -4
View File
@@ -1,9 +1,9 @@
<?php
/**
* 文件功能:游戏下注公屏右下角通知广播服务
* 文件功能:游戏下注与奖励公屏右下角通知广播服务
*
* 统一处理百家乐、赛马、双色球等游戏下注成功后的公屏消息、
* 统一处理百家乐、赛马、双色球等游戏下注或奖励领取成功后的公屏消息、
* 右下角 Toast 通知载荷和异步落库,避免各玩法重复拼装广播结构。
*/
@@ -13,7 +13,7 @@ use App\Events\MessageSent;
use App\Jobs\SaveMessageJob;
/**
* 类功能:为游戏下注成功事件生成并广播全员可见通知。
* 类功能:为游戏下注和奖励领取成功事件生成并广播全员可见通知。
*/
class GameBetBroadcastService
{
@@ -77,7 +77,28 @@ class GameBetBroadcastService
}
/**
* 推送带右下角通知载荷的公屏游戏下注消息
* 广播红包领取成功通知
*/
public function redPacketClaimed(int $roomId, string $username, int $amount, string $type): void
{
$typeLabel = $type === 'exp' ? '经验' : '金币';
$typeIcon = $type === 'exp' ? '✨' : '💰';
$toastColor = $type === 'exp' ? '#6d28d9' : '#d97706';
$formattedAmount = number_format($amount);
$this->pushBetMessage(
roomId: $roomId,
content: "🧧 <b>{$username}</b> 抢到了 <b>{$formattedAmount}</b> {$typeLabel}礼包!{$typeIcon}",
fontColor: $toastColor,
toastTitle: '🧧 有人领取红包',
toastMessage: "<b>{$username}</b> 抢到 <b>{$formattedAmount}</b> {$typeLabel}礼包",
toastIcon: '🧧',
toastColor: $toastColor,
);
}
/**
* 推送带右下角通知载荷的公屏游戏消息。
*/
private function pushBetMessage(
int $roomId,