<?php

Route::group(['domain' => env('QUICKAPP_DOMAIN'), 'namespace' => 'App\Http\Controllers\QuickApp'], function () {

    //支付回调
    Route::any('pay/wcback', 'Order\OrdersController@wxback');
    Route::any('pay/aliback', 'Order\OrdersController@aliback');
    Route::any('pay/wxapp/wait', 'Order\OrdersController@wait');

    //刷新token
    Route::get('api/refreshToken', 'Oauth\UsersController@refreshToken');

    // vivo推送回调
    Route::any('push/vivoback', 'Push\PushController@vivoCallback');

    Route::group(['prefix' => 'api', 'middleware' =>['checkSign','getPackage']], function () {
        //登录
        Route::post('login', 'Oauth\UsersController@index');
    });

    // 无需登录的接口
    Route::group(['prefix' => 'api', 'middleware' => 'getPackage'], function () {

        Route::middleware(['userrefresh'])->group(function (){
            // 首页
            Route::get('books/{sex}/index', 'Book\BookController@getBookLists');
        });

        // 书库
        Route::get('books/library', 'Book\BookController@library');

        //热词
        Route::get('books/hotwords', 'Book\BookController@hotWords');

        // 分类列表
        Route::get('books/getCategory', 'Book\BookCategoryController@getCategory');

        // 相似推荐
        Route::get('books/similar', 'Book\BookController@similarRecom');

        //排行榜
        Route::get('books/rank', 'Book\BookController@rank');
    });

    Route::group(['prefix' => 'api', 'middleware' => ['jwttoken','getPackage']], function () {

        Route::middleware(['userstatus'])->group(function (){
            //章节订购列表
            Route::get('order/chapterOrderList', 'Order\OrdersController@chapterOrderList');

            //单本订购列表
            Route::get('order/bookOrderList', 'Order\OrdersController@bookOrderList');

            //充值记录
            Route::get('order/chargeRecordLists', 'Order\OrdersController@chargeRecordLists');

            Route::get('user/sign_record', 'User\UserController@signRecord');

            //书架
            Route::get('userShelfBooks', 'User\UserShelfBooksController@index');

            //阅读记录
            Route::get('readrecord', 'User\ReadRecordController@index');
            // 最后阅读
            Route::get('lastreadrecord', 'User\ReadRecordController@lastReadRecord');
        });

        //限免
        Route::get('books/free/{sex}', 'Book\BookController@free')->where('sex', '\d+');
        // 全局配置
        Route::get('options', 'WelcomeController@getOptions');
        // 客服相关
        Route::get('customer_img', 'WelcomeController@getCustomerServiceImg');
        //书库
        Route::get('books/recommen', 'Book\BookController@recommen');
        // 阅爱小说任务页面书籍位置
        Route::get('books/recommen_yueai', 'Book\BookController@recommenYueAi');
        // 书籍推荐书籍
        Route::get('books/shelf_recom', 'Book\BookController@shelfRecom');

        //新书籍推荐
        Route::get('books/recommend_books', 'Book\BookController@recommendBooks');
        Route::get('books/clickRecommendBooks', 'Book\BookController@clickRecommendBooks');
        Route::get('books/checkAdvertisement', 'Book\BookController@getCheckAdvertisement');
        Route::get('books/recommendBanners', 'Book\BookController@getRecommendBanners');
        Route::get('books/advertOrders', 'Book\BookController@getAdvertOrders');

        //阅爱小说返回推荐书单
        Route::get('books/back_recom_yueai', 'Book\BookController@yueaiBackRecom');

        //阅读完后的推荐
        Route::get('books/readOverRecommend', 'Book\BookController@readOverRecommend');
        //图书详情
        Route::get('book/{bid}', 'Book\BookController@index');
        //目录不分页
        Route::get('books/{bid}/allcatalog', 'Book\ChapterController@getCatalog');
        //目录分页
        Route::get('books/{bid}/catalog', 'Book\ChapterController@getCatalogPerPage');
        //章节详情
        Route::get('books/{bid}/chapters/{cid}', 'Book\ChapterController@index')->where('cid', '\d+');
        //余额订购
        Route::get('books/{bid}/balance/chapterOrders/{cid}', 'Book\ChapterController@pay');
        //充值列表
        Route::get('order/chargeList', 'Order\OrdersController@chargeList');

        Route::get('order/issuccess', 'Order\OrdersController@isSuccess');
        //个人中心
        Route::get('userinfo', 'User\UserController@index');
        Route::post('user/sendCode', 'User\UserController@sendCode');
        Route::post('user/bindPhone', 'User\UserController@bindPhone');
        Route::any('user/task/get/{id}', 'User\UserController@getUserTaskReward')->where('id', '\d+');
        Route::any('user/task', 'User\UserController@taskList');

        //用户注销
        Route::get('user/logOff', 'User\UserController@logOff');

        //催更
        Route::post('user/urgeUpdate', 'User\UserController@urgeUpdate');
        //设置派单ID
        Route::post('user/setSendOrder', 'User\UserController@setSendOrder');
        //签到
        Route::get('sign', 'User\UserController@sign');
        Route::get('sign/new', 'User\UserController@newSign');
        Route::get('sign/info', 'User\UserController@findSignInfo');

        Route::get('user/addDesktop', 'User\UserController@addDesktop');

        //添加书架
        Route::post('userShelfBooks', 'User\UserShelfBooksController@addShelf');
        //删除书架
        Route::get('userShelfBooks/delete', 'User\UserShelfBooksController@delShelf');

        Route::get('userShelfBooks/isonshelf', 'User\UserShelfBooksController@isOnshelf');

        //添加阅读记录
        Route::post('readrecord', 'User\ReadRecordController@addReadRecord');
        //删除阅读记录
        Route::get('readrecord/delete', 'User\ReadRecordController@delReadRecord');
        //支付
        Route::get('goToPay', 'Order\OrdersController@wxIndex');
        Route::get('goToH5Pay', 'Order\OrdersController@wxH5Index');
        Route::get('goToAliPay', 'Order\OrdersController@aliIndex');

        Route::get('checkOrder', 'Order\OrdersController@checkOrder');
        //添加快捷方式
        Route::get('shortcut/add', 'User\ShortcutController@add');
        //删除快捷方式
        Route::get('shortcut/delete', 'User\ShortcutController@delete');

        //自定义活动
        Route::get('activity/detail', 'Activity\ActivityController@channelCustomActivityV3');

        // 腾讯广告新版,非点击广告访问链接的用户将看到配置的非广告书籍
        Route::get('txAdqNew/noAdvBookInfo', 'SendOrder\TxAdqNewNoAdvBookController@getNoAdvBookInfo');

        //推荐活动
        Route::get('recon_activity', 'Activity\ActivityController@channelCustomActivityRecom');
        // 派单替换书籍-- 设置开启替换书籍则显示替换书籍，否则则显示派单书籍
        Route::get('advReplaceBookInfo', 'SendOrder\AdReplaceBookController@getAdvReplaceBookInfo');
    });


    // 推送
    Route::group(['prefix' => 'api/push'], function () {
        Route::post('pushToUser', 'Push\PushController@pushToUser');
    });
});

//快应用派单推广
Route::group(['domain' => env('QUICKAPP_PROMOTION_DOMAIN'), 'namespace' => 'App\Http\Controllers\QuickApp'], function () {

    //快应用派单链接格式
    Route::get('qyun/{id}', 'WelcomeController@index')->where('id', '\w+');
});



Route::group(['domain' => env('QUICKAPP_BACK_DOMAIN'), 'namespace' => 'App\Http\Controllers\QuickApp'], function () {

    //支付回调
    Route::any('pay/wcback', 'Order\OrdersController@wxback');
    Route::any('pay/aliback', 'Order\OrdersController@aliback');
    Route::any('pay/wxapp/wait', 'Order\OrdersController@wait');

    //刷新token
    Route::get('api/refreshToken', 'Oauth\UsersController@refreshToken');

    // vivo推送回调
    Route::any('push/vivoback', 'Push\PushController@vivoCallback');

    Route::group(['prefix' => 'api', 'middleware' => 'checkSign'], function () {
        //登录
        Route::post('login', 'Oauth\UsersController@index');
    });

    // 无需登录的接口
    Route::group(['prefix' => 'api'], function () {

        // 首页
        Route::get('books/{sex}/index', 'Book\BookController@getBookLists');

        // 书库
        Route::get('books/library', 'Book\BookController@library');

        //热词
        Route::get('books/hotwords', 'Book\BookController@hotWords');

        // 分类列表
        Route::get('books/getCategory', 'Book\BookCategoryController@getCategory');

        // 相似推荐
        Route::get('books/similar', 'Book\BookController@similarRecom');

        //排行榜
        Route::get('books/rank', 'Book\BookController@rank');
    });

    Route::group(['prefix' => 'api', 'middleware' => 'jwttoken'], function () {
        //限免
        Route::get('books/free/{sex}', 'Book\BookController@free')->where('sex', '\d+');
        // 全局配置
        Route::get('options', 'WelcomeController@getOptions');
        // 客服相关
        Route::get('customer_img', 'WelcomeController@getCustomerServiceImg');
        //书库
        Route::get('books/recommen', 'Book\BookController@recommen');
        // 阅爱小说任务页面书籍位置
        Route::get('books/recommen_yueai', 'Book\BookController@recommenYueAi');
        // 书籍推荐书籍
        Route::get('books/shelf_recom', 'Book\BookController@shelfRecom');
        //阅爱小说返回推荐书单
        Route::get('books/back_recom_yueai', 'Book\BookController@yueaiBackRecom');
        //阅读完后的推荐
        Route::get('books/readOverRecommend', 'Book\BookController@readOverRecommend');
        //图书详情
        Route::get('book/{bid}', 'Book\BookController@index');
        //目录不分页
        Route::get('books/{bid}/allcatalog', 'Book\ChapterController@getCatalog');
        //目录分页
        Route::get('books/{bid}/catalog', 'Book\ChapterController@getCatalogPerPage');
        //章节详情
        Route::get('books/{bid}/chapters/{cid}', 'Book\ChapterController@index')->where('cid', '\d+');
        //余额订购
        Route::get('books/{bid}/balance/chapterOrders/{cid}', 'Book\ChapterController@pay');
        //充值列表
        Route::get('order/chargeList', 'Order\OrdersController@chargeList');
        //章节订购列表
        Route::get('order/chapterOrderList', 'Order\OrdersController@chapterOrderList');
        //单本订购列表
        Route::get('order/bookOrderList', 'Order\OrdersController@bookOrderList');
        //充值记录
        Route::get('order/chargeRecordLists', 'Order\OrdersController@chargeRecordLists');

        Route::get('order/issuccess', 'Order\OrdersController@isSuccess');
        //个人中心
        Route::get('userinfo', 'User\UserController@index');
        Route::post('user/sendCode', 'User\UserController@sendCode');
        Route::post('user/bindPhone', 'User\UserController@bindPhone');
        Route::any('user/task/get/{id}', 'User\UserController@getUserTaskReward')->where('id', '\d+');
        Route::any('user/task', 'User\UserController@taskList');
        //催更
        Route::post('user/urgeUpdate', 'User\UserController@urgeUpdate');
        //设置派单ID
        Route::post('user/setSendOrder', 'User\UserController@setSendOrder');
        //签到
        Route::get('sign', 'User\UserController@sign');
        Route::get('sign/new', 'User\UserController@newSign');
        Route::get('sign/info', 'User\UserController@findSignInfo');
        Route::get('user/sign_record', 'User\UserController@signRecord');
        Route::get('user/addDesktop', 'User\UserController@addDesktop');
        //书架
        Route::get('userShelfBooks', 'User\UserShelfBooksController@index');
        //添加书架
        Route::post('userShelfBooks', 'User\UserShelfBooksController@addShelf');
        //删除书架
        Route::get('userShelfBooks/delete', 'User\UserShelfBooksController@delShelf');

        Route::get('userShelfBooks/isonshelf', 'User\UserShelfBooksController@isOnshelf');
        //阅读记录
        Route::get('readrecord', 'User\ReadRecordController@index');
        // 最后阅读
        Route::get('lastreadrecord', 'User\ReadRecordController@lastReadRecord');
        //添加阅读记录
        Route::post('readrecord', 'User\ReadRecordController@addReadRecord');
        //删除阅读记录
        Route::get('readrecord/delete', 'User\ReadRecordController@delReadRecord');
        //支付
        Route::get('goToPay', 'Order\OrdersController@wxIndex');
        Route::get('goToH5Pay', 'Order\OrdersController@wxH5Index');
        Route::get('goToAliPay', 'Order\OrdersController@aliIndex');

        Route::get('checkOrder', 'Order\OrdersController@checkOrder');
        //添加快捷方式
        Route::get('shortcut/add', 'User\ShortcutController@add');
        //删除快捷方式
        Route::get('shortcut/delete', 'User\ShortcutController@delete');

        //自定义活动
        Route::get('activity/detail', 'Activity\ActivityController@channelCustomActivityV3');
    });

    // 推送
    Route::group(['prefix' => 'api/push'], function () {
        Route::post('pushToUser', 'Push\PushController@pushToUser');
    });
});

//快应用派单推广
Route::group(['domain' => env('QUICKAPP_BACK_PROMOTION_DOMAIN'), 'namespace' => 'App\Http\Controllers\QuickApp'], function () {

    //快应用派单链接格式
    Route::get('qyun/{id}', 'WelcomeController@index')->where('id', '\w+');
});

//快应用vivo审核

Route::group(['domain' =>env('QUICKAPP_VIVO_VERIFY_DOMAIN'),'namespace' => 'App\Http\Controllers\QuickApp'],function (){
    Route::any('vivo/{package}', 'VivoVerifyController@verify');

});