营销:自动钓鱼卡用户收竿消息末尾附加购买推广标签

使用自动钓鱼卡时,钓鱼播报消息末尾显示紫色小标签
「🎣 自动钓鱼卡」,其他玩家点击可直接打开商店购买。

* 仅检测到用户当前持有有效自动钓鱼卡时才附加
* 通过 onclick=window.openShopModal() 触发商店弹窗
This commit is contained in:
2026-03-01 16:30:15 +08:00
parent 303c5e2a60
commit 168bc002f9

View File

@@ -172,12 +172,21 @@ class FishingController extends Controller
$user->refresh();
// 5. 广播钓鱼结果到聊天室
// 若使用自动钓鱼卡,在消息末尾附加购买推广小标签(其他人点击可打开商店)
$autoFishingMinutesLeft = $this->shopService->getActiveAutoFishingMinutesLeft($user);
$promoTag = $autoFishingMinutesLeft > 0
? ' <span onclick="window.openShopModal&&window.openShopModal()" '
.'style="display:inline-block;margin-left:6px;padding:1px 7px;background:linear-gradient(90deg,#7c3aed,#a855f7);'
.'color:#fff;border-radius:10px;font-size:10px;cursor:pointer;font-weight:bold;vertical-align:middle;'
.'box-shadow:0 1px 4px rgba(124,58,237,.35);" title="点击购买自动钓鱼卡">🎣 自动钓鱼卡</span>'
: '';
$sysMsg = [
'id' => $this->chatState->nextMessageId($id),
'room_id' => $id,
'from_user' => '钓鱼播报',
'to_user' => '大家',
'content' => "{$result['emoji']}{$user->username}{$result['message']}",
'content' => "{$result['emoji']}{$user->username}{$result['message']}{$promoTag}",
'is_secret' => false,
'font_color' => $result['exp'] >= 0 ? '#16a34a' : '#dc2626',
'action' => '',