<?php

use Illuminate\Support\Facades\Route;
use Modules\Channel\Http\Controllers\AdvertiserController;
use Modules\Channel\Http\Controllers\CompanyUserController;
use Modules\Channel\Http\Controllers\PayTemplateController;
use Modules\Channel\Http\Controllers\UserMiniprogramController;
use Modules\Channel\Http\Controllers\WechatOpenPlatformController;

Route::prefix('channel')->group(function () {
    Route::post('advertiser/add', [AdvertiserController::class, 'addAdvertiser']);
    Route::post('advertiser/updateAdvertiser', [AdvertiserController::class, 'updateAdvertiser']);

    Route::get('advertiser/listAdvertiser', [AdvertiserController::class, 'listAdvertiser']);
    Route::get('advertiser/getAdvertiser', [AdvertiserController::class, 'getAdvertiser']);

    Route::get('miniprogram/list', [UserMiniprogramController::class, 'index']);


    //支付模板
    Route::prefix('paytemplate')->group(function(){
        Route::get('optionTypeList',[PayTemplateController::class,'optionTypeListOutPut'])->withoutMiddleware(config('catch.route.middlewares'));
        Route::get('optionSequence',[PayTemplateController::class,'optionSequence'])->withoutMiddleware(config('catch.route.middlewares'));
        Route::get('list',[PayTemplateController::class,'index'])->middleware(['roleCheck:administrator,optimizer']);
        Route::get('show/{id}',[PayTemplateController::class,'show'])->middleware(['roleCheck:administrator,optimizer']);
        Route::post('store',[PayTemplateController::class,'store'])->middleware(['roleCheck:administrator,optimizer']);
        Route::post('update/{id}',[PayTemplateController::class,'update'])->middleware(['roleCheck:administrator,optimizer']);
        /**
         * @deprecated
         */
        Route::post('updateStatus/{id}',[PayTemplateController::class,'updateStatus']);//->withoutMiddleware(config('catch.route.middlewares'));;
        Route::post('updatePayTemplateItem/{id}',[PayTemplateController::class,'updatePayTemplateItem'])->middleware(['roleCheck:administrator,optimizer']);
        Route::get('deleteOneItem/{id}',[PayTemplateController::class,'deleteOneItem'])->middleware(['roleCheck:administrator,optimizer']);
    });
    Route::prefix('wechat_min_user')->group(function (){
        // 微信小程用户信息
        Route::get('detail/{uid}',[\Modules\Channel\Http\Controllers\WechatMinprogramUserController::class,'userInfoDetail']);
        // 微信小程序充值记录
        Route::get('order_list',[\Modules\Channel\Http\Controllers\WechatMinprogramUserController::class,'orderList']);
        //观看记录
        Route::get('watch_record',[\Modules\Channel\Http\Controllers\WechatMinprogramUserController::class,'watchRecord']);
        // 消费记录
        Route::get('consume_record',[\Modules\Channel\Http\Controllers\WechatMinprogramUserController::class,'consumeRecord']);
    });

    Route::any("order_list",[\Modules\Channel\Http\Controllers\OrdersController::class,'orderList']);
    Route::any("order_types",[\Modules\Channel\Http\Controllers\OrdersController::class,'orderTypes']);
    Route::any("order_status",[\Modules\Channel\Http\Controllers\OrdersController::class,'orderStatus']);
    Route::any('promotions/options', [\Modules\Channel\Http\Controllers\OrdersController::class, 'promotionsOptions']);
    Route::any('miniprogram/use_list', [\Modules\Channel\Http\Controllers\OrdersController::class, 'userUseList']);
    Route::any('promotions/users', [\Modules\Channel\Http\Controllers\OrdersController::class, 'promotionsUsers']);

    Route::prefix('companyUser')->group(function(){
        Route::get('list', [CompanyUserController::class, 'list']);
    });


    /**
     * 第三方开放平台
     */
    Route::prefix('openPlatform')->group(function(){
        Route::get('auth/{component_appid}/{user_id}', [WechatOpenPlatformController::class, 'auth'])->withoutMiddleware(config('catch.route.middlewares'));
        Route::get('preauth', [WechatOpenPlatformController::class, 'preauth'])->middleware(['roleCheck:company']);
    });
});

/**
 * 微信专用
 */
Route::prefix('wechat')->group(function(){
    /**
     * 三方平台
     */
    Route::prefix('openPlatform')->group(function(){
        Route::post('authorCommand/{component_appid}', [WechatOpenPlatformController::class, 'authorCommand'])->withoutMiddleware(config('catch.route.middlewares'));
        Route::post('infoCommand/{authorizer_appid}/{component_appid}', [WechatOpenPlatformController::class, 'infoCommand'])->withoutMiddleware(config('catch.route.middlewares'));
    });
});

