优化vip

This commit is contained in:
2026-04-12 23:25:38 +08:00
parent 353aaaf6ce
commit dca43a2d0d
9 changed files with 346 additions and 100 deletions
+33
View File
@@ -13,6 +13,10 @@ namespace App\Services;
use App\Models\User;
/**
* 聊天室入场、离场与会员喜报播报服务
* 负责统一生成进退场文本,以及会员主题横幅和购买成功喜报的前端载荷。
*/
class RoomBroadcastService
{
/**
@@ -183,4 +187,33 @@ class RoomBroadcastService
'presence_icon' => (string) ($theme['icon'] ?? ''),
];
}
/**
* 构建会员购买成功喜报的前端载荷。
*
* @return array<string, string|null>
*/
public function buildVipPurchasePayload(User $user): array
{
$theme = $this->vipPresenceService->buildPurchaseTheme($user);
if (empty($theme['enabled'])) {
return [];
}
$text = trim((string) ($theme['text'] ?? ''));
if ($text === '') {
return [];
}
return [
'presence_type' => 'purchase',
'presence_text' => $text,
'presence_color' => (string) ($theme['color'] ?? ''),
'presence_effect' => $theme['effect'] ? (string) $theme['effect'] : null,
'presence_banner_style' => (string) ($theme['banner_style'] ?? ''),
'presence_level_name' => (string) ($theme['level_name'] ?? ''),
'presence_icon' => (string) ($theme['icon'] ?? ''),
];
}
}