修复新人进房欢迎消息显示
This commit is contained in:
@@ -127,14 +127,9 @@ class ChatController extends Controller
|
||||
// 必须在推送新消息之前执行,否则可能误删刚刚创建的欢迎播报
|
||||
$this->chatState->removeOldWelcomeMessages($id, $user->username);
|
||||
|
||||
// 新人首次进入:赠送 6666 金币、播放满场烟花、发送全场欢迎通告
|
||||
// 双重校验:优先以 has_received_new_gift 标记为准,若标记异常则用 created_at 时间兜底
|
||||
// 新人首次进入:赠送 6666 金币、播放满场烟花、发送全场欢迎通告。
|
||||
$user->refresh();
|
||||
$isNewbie = ! $user->has_received_new_gift;
|
||||
// 兜底:如果用户创建时间在 2 分钟内,即使标记异常也按新人处理
|
||||
if (! $isNewbie && $user->created_at && $user->created_at->diffInSeconds(now()) < 120) {
|
||||
$isNewbie = true;
|
||||
}
|
||||
if ($isNewbie) {
|
||||
// 通过统一积分服务发放新人礼包 6666 金币并记录流水
|
||||
$this->currencyService->change(
|
||||
@@ -153,6 +148,7 @@ class ChatController extends Controller
|
||||
'font_color' => '#b91c1c',
|
||||
'action' => '',
|
||||
'welcome_user' => $user->username,
|
||||
'welcome_kind' => 'newbie_bonus',
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
];
|
||||
$this->chatState->pushMessage($id, $newbieMsg);
|
||||
@@ -178,11 +174,13 @@ class ChatController extends Controller
|
||||
'id' => $this->chatState->nextMessageId($id),
|
||||
'room_id' => $id,
|
||||
'from_user' => 'AI小班长',
|
||||
'to_user' => $user->username,
|
||||
'to_user' => '大家',
|
||||
'content' => $aiWelcomeContent,
|
||||
'is_secret' => false,
|
||||
'font_color' => '#16a34a',
|
||||
'action' => '大声宣告',
|
||||
'welcome_user' => $user->username,
|
||||
'welcome_kind' => 'ai_newbie_welcome',
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
];
|
||||
$this->chatState->pushMessage($id, $aiWelcomeMsg);
|
||||
@@ -204,6 +202,7 @@ class ChatController extends Controller
|
||||
'font_color' => $color,
|
||||
'action' => empty($vipPresencePayload) ? 'system_welcome' : 'vip_presence',
|
||||
'welcome_user' => $user->username,
|
||||
'welcome_kind' => 'entry_broadcast',
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user