From c8c1943f8535e126b4ee8e6a8daaab4d41aad545 Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 17:04:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=95=86=E5=BA=97?= =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E5=85=B6=E4=BB=96=E5=95=86=E5=93=81=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=97=B6=E5=B9=BF=E6=92=AD=E5=85=AC=E5=B1=8F=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 周卡 / 改名卡 / 求婚戒指 / 自动钓鱼卡购买后 各自向聊天室公屏(系统传音,紫色)广播欢迎语: 📅 周卡:「登录时将自动触发!」 🎫 一次性道具:「购买了XXX道具!」 💍 戒指:「不知道打算送给谁呢?」 🎣 钓鱼卡:「开启了X小时的自动钓鱼模式!」 单次特效卡仍由原 play_effect 分支广播(橙色) --- app/Http/Controllers/ShopController.php | 39 ++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ShopController.php b/app/Http/Controllers/ShopController.php index a114cf2..061f177 100644 --- a/app/Http/Controllers/ShopController.php +++ b/app/Http/Controllers/ShopController.php @@ -125,7 +125,7 @@ class ShopController extends Controller 'lightning' => '⚡', 'snow' => '❄️', ]; - // 赠礼消息文案(改成“为XX触发了一场特效”) + // 赠礼消息文案(改成"为XX触发了一场特效") $icon = $icons[$result['play_effect']] ?? '✨'; $toStr = $targetUsername ? "【{$targetUsername}】" : '全体聊友'; $remarkPart = $message ? " 「{$message}」" : ''; @@ -148,6 +148,43 @@ class ShopController extends Controller ); 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, + ] + )); + } } // 返回最新金币余额