优化vip
This commit is contained in:
@@ -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'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user