<?php


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\admin\Admin;
use App\Http\Controllers\admin\Upload;
use App\Http\Controllers\admin\Wallet;
use App\Http\Controllers\admin\Withdraw;
use App\Http\Controllers\admin\Room;
use App\Http\Controllers\admin\User;
use App\Http\Controllers\admin\Balance;
use App\Http\Controllers\admin\Config;
use App\Http\Controllers\admin\Sync;
use App\Http\Controllers\admin\Menu;
use App\Http\Controllers\admin\Role;
use App\Http\Controllers\admin\Game;
use App\Http\Controllers\admin\GameplayRule;
use App\Http\Controllers\admin\Issue;
use App\Http\Controllers\admin\Keyboard;
use App\Http\Controllers\admin\Lottery;
use App\Http\Controllers\admin\Bet;

use App\Http\Controllers\admin\Rebate;
use App\Http\Controllers\admin\PaymentOrder;

Route::post('/login', [Admin::class, 'login']);
Route::get('/test', [Wallet::class, 'test']);
Route::get('/image', [Lottery::class, 'generate']);

Route::prefix('/sync')->group(function () {
    Route::get('/collect', [Sync::class, 'collect']);
    Route::get('/recharge', [Sync::class, 'recharge']);
    Route::get('/settle', [Sync::class, 'settle']);
    Route::get('/five', [Sync::class, 'five']);
    Route::get('/close', [Sync::class, 'close']);
    Route::get('/cd', [Sync::class, 'cd']);
    Route::get('/exchange', [Sync::class, 'exchange']);
});

Route::get('/fake', [Bet::class, 'fake']);
Route::get('/fakel', [Issue::class, 'fakeLotteryDraw']);


Route::middleware(['admin.jwt'])->group(function () {


    Route::middleware(['check.button.uri'])->group(function () {
        Route::get('/menu/mineMenu', [Menu::class, 'mineMenu']); // 我的菜单
        Route::post('/menu/check', [Menu::class, 'check']); // 接口权限
        Route::get('/menu/tree', [Menu::class, 'tree']); // 菜单按钮树


        Route::prefix("/paymentOrder")->group(function () {
            Route::get('/', [PaymentOrder::class, 'index']);
        });


        Route::prefix('/rebate')->group(function () {
            Route::get('/', [Rebate::class, 'index']);
            Route::post('/submit', [Rebate::class, 'store']);
        });


        Route::post("/setPassword", [Admin::class, 'setPassword']);
        Route::get('/index', [Admin::class, 'index']);
        Route::post('/submit', [Admin::class, 'store']);
        Route::post('/delete', [Admin::class, 'destroy']);

        // 关键字回复路由
        Route::prefix('/keyboard')->group(function () {
            Route::get('/', [Keyboard::class, 'index']);
            Route::post('/submit', [Keyboard::class, 'store']);
            Route::post('/delete', [Keyboard::class, 'destroy']);
        });

        // 期数路由
        Route::prefix('/issue')->group(function () {
            Route::get('/', [Issue::class, 'index']);
            Route::get('/abnormal', [Issue::class, 'abnormal']);
            Route::post('/submit', [Issue::class, 'store']);
            Route::post('/betting', [Issue::class, 'betting']);
            Route::post('/close', [Issue::class, 'close']);
            Route::post('/failure', [Issue::class, 'failure']); 
            Route::post('/lotteryDraw', [Issue::class, 'lotteryDraw']); // 开奖
            Route::post('/delete', [Issue::class, 'destroy']); // 删除
        });
        // 投注记录
        Route::prefix('/bet')->group(function () {
            Route::get('/', [Bet::class, 'index']);
        });

        // 玩法规则路由
        Route::prefix('/gameplayRule')->group(function () {
            Route::get('/', [GameplayRule::class, 'index']);
            Route::post('/submit', [GameplayRule::class, 'store']); // 游戏规则写入
            Route::get('/cache', [GameplayRule::class, 'info']); // 游戏规则缓存读取
            Route::post('/delete', [GameplayRule::class, 'destroy']); // 删除
        });

        Route::prefix('/withdraw')->group(function () {
            Route::get('/', [Withdraw::class, 'index']);
            Route::post('setStatus', [Withdraw::class, 'setStatus']);

        });

        Route::prefix('/game')->group(function () {
            Route::get('/', [Game::class, 'index']);
            Route::post('/update', [Game::class, 'update']);
            Route::post('/delete', [Game::class, 'destroy']);
        });

        Route::prefix('/room')->group(function () {
            Route::get('/', [Room::class, 'index']);
            Route::get('/details', [Room::class, 'details']);
            Route::post('/setScore', [Room::class, 'setScore']);
            Route::post('/completed', [Room::class, 'completed']);
        });

        Route::prefix('/config')->group(function () {
            Route::get('/getAll', [Config::class, 'getAll']);
            Route::get('/get', [Config::class, 'get']);
            Route::post('/set', [Config::class, 'set']);
            Route::post('/sendChannelMessage', [Config::class, 'sendChannelMessage']);
            // Route::post('/sendChannelVideo', [Config::class, 'sendChannelVideo']);
            Route::get('/', [Config::class, 'index']);
            Route::post('/submit', [Config::class, 'store']); // 
            Route::post('/delete', [Config::class, 'destroy']); // 删除
        });

        Route::prefix('/balance')->group(function () {
            Route::get('/log', [Balance::class, 'log']);
        });

        Route::prefix('/wallet')->group(function () {
            Route::get('/', [Wallet::class, 'index']);
            Route::post('/topUp', [Wallet::class, 'topUp']);
            Route::post('/verifyRecharge', [Wallet::class, 'verifyRecharge']);
            Route::get('/getPendingTasks', [Wallet::class, 'getPendingTasks']);


        });

        Route::prefix('/user')->group(function () {
            Route::get('/', [User::class, 'index']);
            Route::get('/address', [User::class, 'address']);
            Route::post('/merge',[User::class, 'merge']);


        });

        Route::prefix('/menu')->group(function () {
            Route::get('/', [Menu::class, 'index']);
            Route::post('/submit', [Menu::class, 'store']);
            Route::post('/delete', [Menu::class, 'destroy']);
            Route::get('/all', [Menu::class, 'all']);

        });

        Route::prefix('/role')->group(function () {
            Route::get('/', [Role::class, 'index']);
            Route::post('/submit', [Role::class, 'store']);
            Route::post('/delete', [Role::class, 'destroy']);
            Route::get('/all', [Role::class, 'all']);

        });

    });


    Route::prefix('/upload')->group(function () {
        Route::post('/uploadFile', [Upload::class, 'store']);
        Route::post('/uploadVideo', [Upload::class, 'video']);
    });


});



