Files
chatroom/routes/console.php
lkddi 602dcd7cf1 feat: 神秘箱子系统完整实现 + 婚姻状态弹窗 + 工具栏优化
## 新功能
- 神秘箱子系统(MysteryBox)完整实现:
  - 新增 MysteryBox / MysteryBoxClaim 模型及迁移文件
  - DropMysteryBoxJob / ExpireMysteryBoxJob 队列作业
  - MysteryBoxController(/mystery-box/status + /mystery-box/claim)
  - 支持三种类型:普通箱(500~2000金)/ 稀有箱(5000~20000金)/ 黑化箱(陷阱扣200~1000金)
  - 调度器自动投放 + 管理员手动投放
  - CurrencySource 新增 MYSTERY_BOX / MYSTERY_BOX_TRAP 枚举

- 婚姻状态弹窗(工具栏「婚姻」按钮):
  - 工具栏「呼叫」改为「婚姻」,点击打开婚姻状态弹窗
  - 动态渲染三种状态:单身 / 求婚中 / 已婚
  - 被求婚方可直接「答应 / 婉拒」;已婚可申请离婚(含二次确认)

## 优化修复
- frame.blade.php:Alpine.js CDN 补加 defer,修复所有组件初始化报错
- scripts.blade.php:神秘箱子暗号主动拦截(不依赖轮询),领取成功后弹 chatDialog 展示结果,更新金币余额
- MysteryBoxController:claim() 时 change() 补传 room_id 记录来源房间
- 后台游戏管理页(game-configs):投放箱子按钮颜色修复;弹窗替换为 window.adminDialog
- admin/layouts:新增全局 adminDialog 弹窗组件(替代原生 alert/confirm)
- baccarat-panel:FAB 拖动重构为 Alpine.js baccaratFab() 组件,与 slotFab 一致
- GAMES_TODO.md:神秘箱子移入已完成区,补全修复记录
2026-03-03 19:29:43 +08:00

106 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
// 每天凌晨 3 点清理超过 30 天的聊天记录
Schedule::command('messages:purge')->dailyAt('03:00');
// 每 5 分钟为所有在线用户自动存点(经验/金币/等级)
Schedule::command('chatroom:auto-save-exp')->everyFiveMinutes();
// ──────────── 婚姻系统定时任务 ────────────────────────────────────
// 每 5 分钟扫描超时求婚48h后失效 + 戒指消失 + 广播通知)
Schedule::job(new \App\Jobs\ExpireMarriageProposals)->everyFiveMinutes();
// 每 5 分钟:触发到时的定时婚礼(红包分发 + 广播庆典)
Schedule::job(new \App\Jobs\TriggerScheduledWeddings)->everyFiveMinutes();
// 每小时协议离婚超时自动升级为强制72h无响应
Schedule::job(new \App\Jobs\AutoExpireDivorces)->hourly();
// 每小时清理过期婚礼红包expired_at 过后标记 completed
Schedule::job(new \App\Jobs\ExpireWeddingEnvelopes)->hourly();
// 每天 00:05全量处理婚姻亲密度时间奖励每日加分
Schedule::job(new \App\Jobs\ProcessMarriageIntimacy)->dailyAt('00:05');
// ──────────── 节日福利定时任务 ────────────────────────────────────
// 每分钟:扫描并触发到期的节日福利活动
Schedule::call(function () {
\App\Models\HolidayEvent::pendingToTrigger()
->each(fn ($e) => \App\Jobs\TriggerHolidayEventJob::dispatch($e));
})->everyMinute()->name('holiday-events:trigger')->withoutOverlapping();
// ──────────── 百家乐定时任务 ─────────────────────────────────────
// 每分钟:检查是否应开新一局(游戏开启 + 无正在进行的局)
Schedule::call(function () {
if (! \App\Models\GameConfig::isEnabled('baccarat')) {
return;
}
$config = \App\Models\GameConfig::forGame('baccarat')?->params ?? [];
$interval = (int) ($config['interval_minutes'] ?? 2);
// 检查距上一局触发时间是否已达到间隔
$lastRound = \App\Models\BaccaratRound::latest()->first();
if ($lastRound && $lastRound->created_at->diffInMinutes(now()) < $interval) {
return; // 还没到开局时间
}
// 无当前进行中的局才开新局
if (! \App\Models\BaccaratRound::currentRound()) {
\App\Jobs\OpenBaccaratRoundJob::dispatch();
}
})->everyMinute()->name('baccarat:open-round')->withoutOverlapping();
// ──────────── 神秘箱子定时投放 ─────────────────────────────────
// 每分钟:检查是否应自动投放一个新箱子
Schedule::call(function () {
if (! \App\Models\GameConfig::isEnabled('mystery_box')) {
return;
}
$config = \App\Models\GameConfig::forGame('mystery_box')?->params ?? [];
// 自动投放开关
if (! ($config['auto_drop_enabled'] ?? false)) {
return;
}
// 当前已有可领取的箱子时跳过(一次只投放一个)
if (\App\Models\MysteryBox::currentOpenBox()) {
return;
}
$intervalHours = (float) ($config['auto_interval_hours'] ?? 2);
// 检查距上次投放时间
$lastBox = \App\Models\MysteryBox::latest()->first();
if ($lastBox && $lastBox->created_at->diffInHours(now()) < $intervalHours) {
return;
}
// 按配置的陷阱概率决定箱子类型
$trapChance = (int) ($config['trap_chance_percent'] ?? 10);
$rand = random_int(1, 100);
$boxType = match (true) {
$rand <= $trapChance => 'trap',
$rand <= $trapChance + 15 => 'rare',
default => 'normal',
};
\App\Jobs\DropMysteryBoxJob::dispatch($boxType);
})->everyMinute()->name('mystery-box:auto-drop')->withoutOverlapping();