功能:商店购买其他商品类型时广播公屏通知
周卡 / 改名卡 / 求婚戒指 / 自动钓鱼卡购买后 各自向聊天室公屏(系统传音,紫色)广播欢迎语: 📅 周卡:「登录时将自动触发!」 🎫 一次性道具:「购买了XXX道具!」 💍 戒指:「不知道打算送给谁呢?」 🎣 钓鱼卡:「开启了X小时的自动钓鱼模式!」 单次特效卡仍由原 play_effect 分支广播(橙色)
This commit is contained in:
@@ -125,7 +125,7 @@ class ShopController extends Controller
|
|||||||
'lightning' => '⚡',
|
'lightning' => '⚡',
|
||||||
'snow' => '❄️',
|
'snow' => '❄️',
|
||||||
];
|
];
|
||||||
// 赠礼消息文案(改成“为XX触发了一场特效”)
|
// 赠礼消息文案(改成"为XX触发了一场特效")
|
||||||
$icon = $icons[$result['play_effect']] ?? '✨';
|
$icon = $icons[$result['play_effect']] ?? '✨';
|
||||||
$toStr = $targetUsername ? "【{$targetUsername}】" : '全体聊友';
|
$toStr = $targetUsername ? "【{$targetUsername}】" : '全体聊友';
|
||||||
$remarkPart = $message ? " 「{$message}」" : '';
|
$remarkPart = $message ? " 「{$message}」" : '';
|
||||||
@@ -148,6 +148,43 @@ class ShopController extends Controller
|
|||||||
);
|
);
|
||||||
broadcast($sysMsgEvent);
|
broadcast($sysMsgEvent);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// ── 其他类型:广播购买通知到公屏 ────────────────────────────
|
||||||
|
$user = Auth::user();
|
||||||
|
$roomId = (int) $request->room_id;
|
||||||
|
|
||||||
|
if ($roomId > 0) {
|
||||||
|
// auto_fishing 有效期文案(提前算好,避免在 match 内写复杂三元表达式)
|
||||||
|
$fishDuration = '';
|
||||||
|
if ($item->type === 'auto_fishing') {
|
||||||
|
$mins = (int) ($item->duration_minutes ?? 0);
|
||||||
|
$fishDuration = $mins >= 60 ? floor($mins / 60).'小时' : $mins.'分钟';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据商品类型生成不同通知文案
|
||||||
|
$sysContent = match ($item->type) {
|
||||||
|
'duration' => "📅 【{$user->username}】购买了全屏特效周卡「{$item->name}」,登录时将自动触发!",
|
||||||
|
'one_time' => "🎫 【{$user->username}】购买了「{$item->name}」道具!",
|
||||||
|
'ring' => "💍 【{$user->username}】在商店购买了一枚「{$item->name}」,不知道打算送给谁呢?",
|
||||||
|
'auto_fishing' => "🎣 【{$user->username}】购买了「{$item->name}」,开启了 {$fishDuration} 的自动钓鱼模式!",
|
||||||
|
default => "🛒 【{$user->username}】购买了「{$item->name}」。",
|
||||||
|
};
|
||||||
|
|
||||||
|
broadcast(new MessageSent(
|
||||||
|
roomId: $roomId,
|
||||||
|
message: [
|
||||||
|
'id' => 0,
|
||||||
|
'room_id' => $roomId,
|
||||||
|
'from_user' => '系统传音',
|
||||||
|
'to_user' => '大家',
|
||||||
|
'content' => $sysContent,
|
||||||
|
'font_color' => '#7c3aed',
|
||||||
|
'sent_at' => now()->format('H:i:s'),
|
||||||
|
'is_secret' => false,
|
||||||
|
'action' => null,
|
||||||
|
]
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回最新金币余额
|
// 返回最新金币余额
|
||||||
|
|||||||
Reference in New Issue
Block a user