功能:VIP 赞助会员系统

- 新建 vip_levels 表(名称、图标、颜色、经验/金币倍率、专属进入/离开模板)
- 默认4个等级种子:白银🥈(×1.5)、黄金🥇(×2.0)、钻石💎(×3.0)、至尊👑(×5.0)
- 后台 VIP 等级 CRUD 管理(新增/编辑/删除,配置模板和倍率)
- 后台用户编辑弹窗支持设置 VIP 等级和到期时间
- ChatController 心跳经验按 VIP 倍率加成
- FishingController 正向奖励按 VIP 倍率加成(负面惩罚不变)
- 在线名单显示 VIP 图标和管理员🛡️标识
- VIP 用户进入/离开使用专属颜色和标题
- 后台侧栏新增「👑 VIP 会员等级」入口
This commit is contained in:
2026-02-26 21:30:07 +08:00
parent ea06328885
commit fd3214eaff
22 changed files with 2293 additions and 19 deletions

View File

@@ -14,6 +14,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@@ -36,6 +37,8 @@ class User extends Authenticatable
'first_ip',
'last_ip',
'usersf',
'vip_level_id',
'hy_time',
];
/**
@@ -85,4 +88,53 @@ class User extends Authenticatable
get: fn () => $this->usersf ?: '1.GIF',
);
}
/**
* 关联:用户所属的 VIP 会员等级
*/
public function vipLevel(): BelongsTo
{
return $this->belongsTo(VipLevel::class, 'vip_level_id');
}
/**
* 判断用户是否为有效 VIP有等级且未过期
*/
public function isVip(): bool
{
if (! $this->vip_level_id) {
return false;
}
// hy_time 为 null 表示永久会员
if (! $this->hy_time) {
return true;
}
return $this->hy_time->isFuture();
}
/**
* 获取 VIP 会员名称(无效则返回空字符串)
*/
public function vipName(): string
{
if (! $this->isVip()) {
return '';
}
return $this->vipLevel?->name ?? '';
}
/**
* 获取 VIP 会员图标(无效则返回空字符串)
*/
public function vipIcon(): string
{
if (! $this->isVip()) {
return '';
}
return $this->vipLevel?->icon ?? '';
}
}