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, + ] + )); + } } // 返回最新金币余额