<?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');

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

    Route::group(['prefix' => 'api', 'middleware' => 'jwttoken'], function () {
        // Route::group(['prefix' => 'api'], function () {
        //首页
        Route::get('books/{sex}/index', 'Book\BookController@getBookLists');
        //书库
        Route::get('books/library', 'Book\BookController@library');
        //相似推荐
        Route::get('books/similar', 'Book\BookController@similarRecom');
        //阅读完后的推荐
        Route::get('books/readOverRecommend', 'Book\BookController@readOverRecommend');
        //排行榜
        Route::get('books/rank', 'Book\BookController@rank');
        //分类列表
        Route::get('books/getCategory', 'Book\BookCategoryController@getCategory');
        //图书详情
        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::post('user/urgeUpdate', 'User\UserController@urgeUpdate');
        //设置派单ID
        Route::post('user/setSendOrder', 'User\UserController@setSendOrder');
        //签到
        Route::get('sign', 'User\UserController@sign');
        Route::get('user/sign_record', 'User\UserController@signRecord');
        //书架
        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::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('customer_img', 'WelcomeController@getCustomerServiceImg');
    });
});

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

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