<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
Route::group([
    #  'prefix' => 'api',
    'namespace' => 'App\Http\Controllers\API',
], static function () {
    // 获取盲盒列表
    Route::get('/BlindBoxList', 'IndexController@getList');
    # 用户能否购买当前盲盒
    Route::get('/CanNotBuy', 'IndexController@useCanNotBuy');
    # 购买盲盒
    Route::post('/BlindBox/buy', 'IndexController@useBuy');
    # 检查交易
    Route::post('/BlindBox/buy/check', 'IndexController@usePayCheck');
    # python检查回调
    Route::post('/BlindBox/buy/CheckCallback', 'IndexController@useCheckCallback');
    # nodejs转账回调
    Route::post('/transfer/callback', 'IndexController@useNodeJsTransfer');
    #  用户订单查询
    Route::get('/order', 'IndexController@useUserOrder');
    # 获取收款地址
    Route::get('/address', 'IndexController@getReceiptAddress');
    // ---------
    # 获取用户信息
    Route::get('/user/info', 'IndexController@getUserInfo');


    # 测试
    #  Route::get('/my/test', 'IndexController@useMyTest');
    # 用户
    Route::group([
        'prefix' => '/user',
        'namespace' => 'User'
    ], function () {
        // 不需要登录
        Route::group([
        ], function () {
            // 用户登录
            Route::post('login', 'AuthController@login');
        });

        // 需要登录
        Route::group([
            'middleware' => 'auth:api',
        ], function () {
            # 测试数据获取
            Route::get('getlist', 'AuthController@getlist');
            // 管理员退出
            Route::post('logout', 'AuthController@logout');
        });
    });
});
