diff --git a/app/Http/Controllers/Admin/GameConfigController.php b/app/Http/Controllers/Admin/GameConfigController.php index 70813d8..43d92ff 100644 --- a/app/Http/Controllers/Admin/GameConfigController.php +++ b/app/Http/Controllers/Admin/GameConfigController.php @@ -15,6 +15,8 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\GameConfig; +use App\Models\LotteryIssue; +use App\Services\LotteryService; use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; @@ -97,8 +99,51 @@ class GameConfigController extends Controller $typeNames = ['normal' => '普通箱', 'rare' => '稀有箱', 'trap' => '黑化箱']; return response()->json([ - 'ok' => true, + 'ok' => true, 'message' => "✅ 已投放「{$typeNames[$boxType]}」到 #1 房间,暗号将实时发送到公屏!", ]); } + + /** + * 手动开启新一期双色球彩票。 + * + * 仅在当前无进行中期次时生效,防止重复开期。 + */ + public function openLotteryIssue(): JsonResponse + { + if (! GameConfig::isEnabled('lottery')) { + return response()->json(['ok' => false, 'message' => '双色球彩票未开启,请先开启游戏。']); + } + + if (LotteryIssue::currentIssue()) { + return response()->json(['ok' => false, 'message' => '当前已有进行中的期次,无需重复开期。']); + } + + \App\Jobs\OpenLotteryIssueJob::dispatch(); + + return response()->json(['ok' => true, 'message' => '✅ 已排队开期任务,新期次将就绪建立!']); + } + + /** + * 管理员强制立即开奖(测试专用)。 + * + * 将当前 open 或 closed 期次直接投入开奖队列。 + */ + public function forceLotteryDraw(LotteryService $lottery): JsonResponse + { + $issue = LotteryIssue::query() + ->whereIn('status', ['open', 'closed']) + ->latest() + ->first(); + + if (! $issue) { + return response()->json(['ok' => false, 'message' => '当前无可开奖的期次。']); + } + + // 强制将状态改为 closed + $issue->update(['status' => 'closed']); + \App\Jobs\DrawLotteryJob::dispatch($issue->fresh()); + + return response()->json(['ok' => true, 'message' => "✅ 开奖任务已入队,第 {$issue->issue_no} 期将就绪开奖!"]); + } } diff --git a/resources/views/admin/game-configs/index.blade.php b/resources/views/admin/game-configs/index.blade.php index c9f140a..db28d28 100644 --- a/resources/views/admin/game-configs/index.blade.php +++ b/resources/views/admin/game-configs/index.blade.php @@ -158,6 +158,36 @@ @endif + + {{-- 双色球彩票:手动操作区域 --}} + @if ($game->game_key === 'lottery') +