新增:双色球彩票系统后端基础(阶段一)
📦 数据库 - lottery_issues(期次表) - lottery_tickets(购票记录表) - lottery_pool_logs(奖池流水表,透明展示) 🔩 核心组件 - LotteryIssue / LotteryTicket / LotteryPoolLog 完整 Model - LotteryService:购票/机选/开奖/奖池派发/滚存/超级期预热/公屏广播 - LotteryController:current/buy/quickPick/history/my 五个接口 - DrawLotteryJob(每日定时开奖)/ OpenLotteryIssueJob(初始化首期) 💰 货币日志 - CurrencySource 新增 LOTTERY_BUY / LOTTERY_WIN - 所有金币变动均通过 UserCurrencyService::change() 记录流水 🗓️ 调度器 - 每分钟检查停售/开奖时机 - 每日 18:00 超级期预热广播 🔧 配置 - GameConfigSeeder 追加 lottery 默认配置(默认关闭) - /games/enabled 接口追加 lottery 开关状态 - 新增 /lottery/* 路由组(auth 保护)
This commit is contained in:
@@ -127,3 +127,44 @@ Schedule::call(function () {
|
||||
|
||||
\App\Jobs\OpenHorseRaceJob::dispatch()->delay(now()->addSeconds(30));
|
||||
})->everyMinute()->name('horse-race:open-race')->withoutOverlapping();
|
||||
|
||||
// ──────────── 双色球彩票定时任务 ─────────────────────────────────
|
||||
|
||||
// 每分钟:检查是否到开奖时间,到期触发开奖;同时确保有进行中的期次
|
||||
Schedule::call(function () {
|
||||
if (! \App\Models\GameConfig::isEnabled('lottery')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$issue = \App\Models\LotteryIssue::query()->whereIn('status', ['open', 'closed'])->latest()->first();
|
||||
|
||||
// 无进行中期次则自动创建一期
|
||||
if (! $issue) {
|
||||
\App\Jobs\OpenLotteryIssueJob::dispatch();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// open 状态:检查是否已到停售时间
|
||||
if ($issue->status === 'open' && $issue->sell_closes_at && now()->gte($issue->sell_closes_at)) {
|
||||
$issue->update(['status' => 'closed']);
|
||||
$issue->refresh();
|
||||
}
|
||||
|
||||
// closed 状态:检查是否已到开奖时间
|
||||
if ($issue->status === 'closed' && $issue->draw_at && now()->gte($issue->draw_at)) {
|
||||
\App\Jobs\DrawLotteryJob::dispatch($issue);
|
||||
}
|
||||
})->everyMinute()->name('lottery:check')->withoutOverlapping();
|
||||
|
||||
// 每日 18:00:超级期预热广播(若当前期次为超级期,提醒用户购票)
|
||||
Schedule::call(function () {
|
||||
if (! \App\Models\GameConfig::isEnabled('lottery')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$issue = \App\Models\LotteryIssue::currentIssue();
|
||||
if ($issue && $issue->is_super_issue) {
|
||||
\App\Jobs\OpenLotteryIssueJob::dispatch(); // 触发广播
|
||||
}
|
||||
})->dailyAt('18:00')->name('lottery:super-reminder');
|
||||
|
||||
Reference in New Issue
Block a user