<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;

// 登录相关接口
Route::group([
    'namespace' => 'Auth',
    'prefix'    => 'auth',
], function (Router $router) {
    $router->post('login', 'LoginController@index');
    $router->post('register', 'RegisterController@index');
    // 获取登录短信验证码
    $router->post('verify', 'SmsController@send');
    // 验证码登录
    $router->post('sms', 'SmsController@login');
    // 退出登录
    $router->post('logout', 'LoginController@logout')->middleware('token.guess');

    //获取跳转地址
    $router->get('get_auth_url', 'WechatController@getAuthUrl');
    $router->get('get_jssdk', 'WechatController@getJsSdk');
    $router->get('official_share', 'WechatController@officialShare');
    $router->get('mini_openid', 'WechatController@getMiniOpenid');
    $router->get('official_openid', 'WechatController@getOfficialOpenid');
});

// 社会化登录
Route::group([
    'namespace'  => 'Socialite',
    'prefix'     => 'socialite',
    'middleware' => config('api.route.middleware_guess'),
], function (Router $router) {
    //微信APP登录
    $router->post('login/wechat/app', 'WeChatController@app');
    //微信小程序登录
    $router->post('login/wechat/mini', 'WeChatController@mini');
    //微信公众号登陆
    $router->post('login/wechat/official', 'WeChatController@official');
    //微信union_id 快速登录
    $router->post('login/wechat/query', 'WeChatController@query');
    //UniCloud本机一键登录（后端获取手机号）
    $router->post('login/unicloud/app', 'UniCloudController@app');
    //UniCloud本机一键登录（前端获取手机号）
    $router->post('login/unicloud/query', 'UniCloudController@query');
    //入库微信用户信息
    $router->post('login/wechat/add', 'WeChatController@addWechatUser');
    $router->post('login/wechat/mini/add', 'WeChatController@miniAddWechatUser');

});

Route::group([
    'namespace' => 'Certification',
    'prefix'    => 'certification',
], function (Router $router) {
    // 个人认证
    $router->get('', 'IndexController@index');
    $router->post('', 'IndexController@store');
});

Route::group([
    'middleware' => config('api.route.middleware_guess'),
], function (Router $router) {
    // 用户是否有身份认证
    $router->get('certified', 'Certification\IndexController@certified');
    // 获取身份对应的折扣
    $router->get('identity/rule', 'Identity\IndexController@rule');
});

Route::group([
    'namespace'  => 'Identity',
    'prefix'     => 'identities',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('create/{identity}', 'IndexController@create');
    $router->post('create/{identity}', 'IndexController@store');
    //获取支付数据
    $router->get('pay/{order}/wechat', 'IndexController@wechat');
    $router->get('pay/{order}/alipay', 'IndexController@alipay');
});
Route::group([
    'namespace'  => 'Identity',
    'prefix'     => 'identities',
    'middleware' => config('api.route.middleware_guess'),
], function (Router $router) {
    $router->get('', 'IndexController@index');
    $router->get('{identity}', 'IndexController@show');
});
Route::group([
    'namespace'  => 'Sign',
    'prefix'     => 'sign',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('', 'IndexController@index');
    $router->post('', 'IndexController@sign');
    // 预留的补签接口
    $router->post('replenish', 'IndexController@replenish');
    // 测试日历接口
    $router->get('date', 'IndexController@date');
    $router->get('backgrounds', 'IndexController@backgrounds');
    $router->get('ranks', 'IndexController@rank');

});

// 账户
Route::group([
    'namespace'  => 'Account',
    'prefix'     => 'account',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('score', 'LogController@score');
    $router->get('balance', 'LogController@balance');
});

// 用户中心
Route::group([
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('', 'IndexController@index');
    // 资料和修改资料
    $router->get('info', 'IndexController@info');
    $router->put('{key}', 'IndexController@update');
    // 我的邀请码
    $router->get('invite', 'IndexController@invite');
    // 我的小程序码
    $router->get('mini_share', 'IndexController@getMiniCode');

    // 绑定邀请码
    $router->post('bind', 'IndexController@bind');
    // 我的专属客服
    $router->get('services', 'Service\IndexController@index');
});

//设置
Route::group([
    'namespace'  => 'Setting',
    'prefix'     => 'setting',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('', 'IndexController@index');
    $router->put('{key}', 'IndexController@update');
});

Route::group([
    'namespace'  => 'Stock',
    'prefix'     => 'stock',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    // 个人认证
    $router->get('', 'IndexController@index');
    $router->get('pick', 'IndexController@create');
    $router->post('pick', 'IndexController@Store');
    $router->get('logs', 'IndexController@logs');
});

//我的伙伴
Route::group([
    'namespace'  => 'Relation',
    'prefix'     => 'relations',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('', 'IndexController@index');
});

//排行
Route::group([
    'namespace'  => 'Rank',
    'prefix'     => 'rank',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('total', 'IndexController@total');
    $router->get('totaluser', 'IndexController@totalUser');

    $router->get('week', 'IndexController@week');
});


//我的收藏
Route::group([
    'namespace'  => 'Favorite',
    'middleware' => config('api.route.middleware_auth'),
], function (Router $router) {
    $router->get('favorites', 'IndexController@index');
});


