<?php

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

Route::any('callback/weixin', 'WeChatController@server');
Route::any('callback/miniprogram', 'Miniprogram\Server@message');
Route::any('callback/xunfei', function (Request $request) {
    \Log::info("xunfei".date('Y-m-d H:i:s'));
});


// 分配对象的监听
Route::any('server', 'Wechat\Server@index');;

// 时遇记
Route::any('weixin/server', 'WeChatController@server');

// 基础模块
Route::group(['prefix' => 'core'], function () {
    // 人脸识别
    Route::post('oauth/faceToken', 'Core\Oauth@faceToken');
    // 用户购买任意小fa下单
    Route::get('unify/flower/{gold_flower}', 'Order@unifyByFlower');
    // 小程序支付jssdk
    Route::get('pay/minijssdk/{order_id}', 'Order@miniProgram');
    // app支付jssdk
    Route::get('pay/app/{order_id}', 'Order@app');
    // 网页支付jssdk
    Route::get('pay/jssdk/{order_id}', 'Order@jssdk');
    // 支付通知
    Route::post('pay/notify', 'Order@notify');
    // 分配对象报名支付通知
    Route::post('pay/notify/fpdx', 'Order@notifyByfpdx');
    // 表白支付结果通知
    Route::post('pay/notify/confess', 'Order@notifyByconfess');
});

// 广告模块
Route::group(['prefix' => 'banner'], function () {
    // 添加广告
    Route::post('/store', 'BannerController@store');
    // 更新广告
    Route::post('/{banner_id}/update', 'BannerController@update');
    // 删除广告
    Route::get('/{banner_id}/delete', 'BannerController@delete');
    // 查看广告信息
    Route::get('/{banner_id}', 'BannerController@get');
    // 获取某个位置广告
    Route::get('/list/{position}', 'BannerController@listByPosition');
});

// 语音独白
Route::group(['prefix' => 'voice'], function () {
    // 创建独白
    Route::post('/store', 'Voice@store');
    // 更新独白
    Route::post('/{voice_id}/update', 'Voice@update');
    // 获取某种类型的独白
    Route::get('/{type}', 'Voice@get');
});

// 留言板
Route::group(['prefix' => 'messagewall', 'namespace' => 'Miniprogram'], function ($routes) {
    /** @var \Illuminate\Support\Facades\Route $routes */
    $routes->get('{master_uid?}', 'MessageWallController@show')->where('master_uid', '[0-9]+');
    $routes->get('qrcode', 'MessageWallController@qrcode');
    $routes->post('', 'MessageWallController@store');
    $routes->delete('{id}', 'MessageWallController@destroy')->where('id', '[0-9]+');
});

// 卖室友
Route::group(['prefix' => 'msy'], function () {
    // 获取用户信息
    Route::get('/user', "User\ProfileController@user");
    // 获取卡片
    Route::get('/partner/{partner_id}/get', 'User\PartnerController@getPartner')->where('partner_id', '[0-9]+');
    // 获取用户个人交友卡片
    Route::get('/partnerbyuser/{user_id}/get', 'User\PartnerController@getPartnerByUser')->where('user_id', '[0-9]+');

    // 创建个人交友卡片
    Route::get("/selfpartner/store", "User\ProfileController@storeSelfPartner");

    // 我喜欢的列表
    Route::get('/partner/likelist', 'User\HomeController@likeList');

    // 发起表白
    Route::post('/confess/store', 'Confess@store');
    // msy公众号收益总计
    Route::get('/media/{media_id}/income', 'Fpdx\Media@msyIncome');

    // 获取解锁邀请的信息
    Route::get('/buyinvite/{invite_id}', 'BuyInvite@get')->where('invite_id', '[0-9]+');
    // 解锁助力邀请检验
    Route::get('/buyinvite/{invite_id}/check', 'BuyInvite@invite')->where('invite_id', '[0-9]+');

    /**
     * 通过解锁卡解锁卡片
     * @deprecated
     */
    Route::post('/buy/partner/{patner_id}/ticket', 'Pay@buyByTicket')->where('patner_id', '[0-9]+');
    // 通过fa解锁卡片
    Route::post('/buy/partner/{patner_id}/flower', 'Pay@buyByflower')->where('patner_id', '[0-9]+');

    /**
     * 兑换解锁卡
     * @deprecated
     */
    Route::post('/exchange/ticket', 'Pay@exchangeTicket');
    // 我发布的卡片列表
    Route::get('/user/list/sell', "User\HomeController@sellList");
    // 聊天列表数量
    Route::get('/user/cnt/chat', 'User\HomeController@chatCount');
    // 匹配历史数量
    Route::get('/user/cnt/pair', 'User\HomeController@pairCount');
    /**
     * 解锁卡抽奖
     * @deprecated
     */
    Route::get('/ticket/rand', 'Ticket@randTicket');

    // 上传卡片
    Route::post('/partner/store', 'User\PartnerController@store');

    // 更新卡片
    Route::put('/partner/{partner_id}/update', 'User\PartnerController@update')->where('patner_id', '[0-9]+');

    // 上下架卡片
    Route::get('partner/{partner_id}/sell', 'User\PartnerController@sell')->where('patner_id', '[0-9]+');

    Route::get('questions', 'User\InterlocutionController@questions');
    Route::get('users/{uid}/answers', 'User\InterlocutionController@answers')->where('uid', '[0-9]+');
    Route::post('questions/{question_id}/answers', 'User\InterlocutionController@createAnswer')->where(
        'question_id',
        '[0-9]+'
    );
    Route::get('questions/{question_id}', 'User\InterlocutionController@getAnswer')->where('question_id', '[0-9]+');

    Route::get('form', 'Fpdx\FormController@show');
    Route::post('/form/submit', 'Fpdx\FormController@submit');
});

// 小fa兑换码
Route::group(['prefix' => 'msy/flowerticket'], function () {
    /**
     * 创建兑换码
     * @deprecated
     */
    Route::post('/store', 'FlowerTicket@store');
    /**
     * 更新兑换码
     * @deprecated
     */
    Route::post('/{ticket_id}/update', 'FlowerTicket@update');
    /**
     * 删除兑换码
     * @deprecated
     */
    Route::get('/{ticket_id}/delete', 'FlowerTicket@delete');
    /**
     * 兑换码列表
     * @deprecated
     */
    Route::get('/list/{page}', 'FlowerTicket@getList');
    /**
     * 领取兑换码
     * @deprecated
     */
    Route::get('/claim', 'FlowerTicket@claim');
});

// 房间路由
Route::group(['namespace' => 'Fpdx', 'prefix' => 'fpdx/room'], function () {
    Route::get('notice/online', function () {
        return array(
            'code' => 200,
            'message' => 'success'
        );
    });
    // 创建公众号聊天通道
    Route::get('/store/{partner_id}', 'RoomController@createRoom');
    // 进入房间
    Route::get('into/{room_id}', "RoomController@intoRoom");
    Route::get('exit/{uid}', "RoomController@exitRoom");
    // 获取聊天设置
    Route::get('/profile/{room_id}', "RoomController@profile");
    // 更新聊天设置
    Route::post('/updateProfile/{room_id}', "RoomController@updateProfile");
    // 设置是否允许查看照片
    Route::post('/updateAllowPhoto', "RoomController@updateAllowPhoto");
    // 清空聊天信息
    Route::get('/clearMsg/{room_id}', "RoomController@clearMsg");
    // 获取房间列表
    Route::get('/list', "RoomController@sessionRoomList");
    // 删除房间
    Route::get('/{room_id}/delete', "RoomController@delRoomList")->where('room_id', '[0-9]+');
    // 获取某期第活动房间列表
    Route::get('/groups/{stage_id}', "GroupChat@groupRooms");
    // 创建群聊房间
    Route::post('/create', "GroupChat@createGroupRoom");
    // 添加管理员|群主
    Route::post('{room_id}/master/join', "GroupChat@joinMaster");
    // 获取房主信息by房间
    Route::get('/{room_id}/master', "GroupChat@getMasterByRoom");
    // 获取管理员列表by房间
    Route::get("/{room_id}/administrator", "GroupChat@getAdministrator");
    // 删除发言
    Route::get("/message/{msg_id}/deleted", "GroupChat@delMsg");
    // 屏蔽某人
    Route::get('/{room_id}/forbid/{uid}', "GroupChat@forbid");
    // 点赞房主
    Route::get('/{room_id}/thumb/master', "GroupChat@thumb");
    // 获取某人点赞状态
    Route::get('/{room_id}/thumb/state', "GroupChat@thumbByUser");
    // 获取room聊天记录
    Route::get('/{room_id}/msg', "RoomController@roomMsgLogs");
    // 获取最新聊天记录
    Route::get('/{room_id}/latestmsg/{last_msg}', "RoomController@chatMsg");
    // 发送消息
    Route::post("/msg/send", "GroupChat@sendMsg");
    // 确认落单
    Route::get("alone", "RoomController@groups");
    Route::post("alone", "RoomController@alone");
    // 创建公告
    Route::post("/{room_id}/notice/create", "GroupChat@createNotice");
    // 删除公告
    Route::get("/notice/delete/{notice_id}", "GroupChat@deleteNotice");
    // 阅读公告
    Route::get("/notice/read/{notice_id}", "GroupChat@readNotice");
    // 群公告列表
    Route::get("/{room_id}/notice/list", "GroupChat@getNotices");
    // 群公告信息
    Route::get("/notice/{notice_id}", "GroupChat@getNotice");
    // 是否阅读公告
    Route::get("/notice/{notice_id}/is_read", "GroupChat@isRead");
    // 获取某人正在进行的活动房间
    Route::get('/current', 'RoomController@getCurrentRoom');
});

// 通知路由
Route::group(['namespace' => 'Fpdx', 'prefix' => 'fpdx/notive'], function () {
    Route::post("/receive/state", "NoticeController@getSendState");
    Route::post("/receive/send", "NoticeController@sendNotive");
});

// 分配对象路由
Route::group(['namespace' => 'Fpdx', 'prefix' => 'fpdx'], function () {
    // 同步时遇记数据
    Route::get('/syj/sync/{phone}', 'Syj@sync');
    // 操作报名成功
    Route::get('/enroll/success', 'PairController@successEnroll');
    // 最近报名气泡
    Route::get('/pair/lastenroll', 'PairController@lastEnroll');
    // 报名男女数量
    Route::get('/pair/sexproportion', 'PairController@sexProportion');
    // 分配对象报名下单
    Route::post('/pair/enroll', 'PairController@preEnroll');
    // 分配对象cp界面点赞
    Route::get('/partner/praise', 'PairController@isPraise');

    // 报名历史
    Route::get('/pairs', 'PairController@index');
    // 获取报名信息
    Route::get('/pair/{pair_id}', 'PairController@show')->where('pair_id', '[0-9]+');
    // 获取报名信息
    Route::get('/pairs/{pair_id}', 'PairController@show')->where('pair_id', '[0-9]+');
    // 修改报名
    Route::put('/pairs/{pair_id}', 'PairController@update')->where('pair_id', '[0-9]+');


    // fpdx退款
    Route::get('/pair/{pair_id}/refund', 'PairController@refund')->where('pair_id', '[0-9]+');
    // fpdx获取邀请信息
    Route::get('/invite/{invite_id}', 'Invite@get')->where('invite_id', '[0-9]+');
    // 获取最近邀请的人
    Route::get('/invite/get/lastinvite', 'Invite@lastInvite')->where('invite_id', '[0-9]+');
    // 应用第三方监听
    Route::group(['prefix' => 'listen'], function () {
        Route::any('/weixiao', 'WxListen@listen');
        Route::any('/koudai', 'KdListen@listen');
    });
    // 创建链接
    Route::post('/media/link/create', 'Media@createLink');
    // 获取公众号信息
    Route::get('/media/{media_id}/info', 'Media@info');
    // 广播通知 Method:POST $dns/api/fpdx/media/broadcastNotive
    Route::post('/media/broadcastNotive', 'Media@broadcastNotive');
    // 获取未读消息 Method:GET $dns/api/fpdx/media/{gh_efit23f18}/notive/unread
    Route::get('/media/{media_id}/notive/unread', 'Media@unread');
    // 获取消息列表 Method:GET $dns/api/fpdx/media/{gh_efit23f18}/notive/list
    Route::get('/media/{media_id}/notive/list/{page?}', 'Media@notivelist');
    // 阅读消息 Method:GET $dns/api/fpdx/media/notive/{1}/read
    Route::get('/media/notive/{notive_id}/read', 'Media@readNotive');
    // 卖室友收益总览
    Route::get('/media/{media_id}/income', 'Media@fpdxIncome');
    // 获取分配对象收益明细 Method:GET $dns/api/fpdx/media/{gh_efit23f18}/fxIncome
    Route::get('/media/{media_id}/fxIncome', 'Media@fxIncome');
    // 分销榜单 Method:GET $dns/api/fpdx/rank/fx/{1}
    Route::get('/rank/fx/{stage_id}', 'RankController@fxRank')->where('stage_id', '[0-9]+');
    // 报名榜单 Method:GET $dns/api/fpdx/rank/enroll
    Route::get('/rank/enroll', 'RankController@enrollRank');
    // 判断是否开启分配对象
    Route::get('/media/{media_id}/isOpen', "Media@isOpen");
    // 某学校正在报名的活动的男女生数量
    Route::post("/pair/count", "PairController@getCountBySchool");
    // 某地址正在报名的活动的男女生数量
    Route::post("/pair/address/count", "PairController@getCountByAddress");
    // 任务路由
    Route::post('task/complate', "Task@complate");
    // 消息路由
    Route::get('msg/push/{message_id}', "Message@pushKfMsg");
});


// 小程序核心路由
Route::group(['prefix' => 'miniprogram'], function () {
    // 是否开启
    Route::get('/qrcode/{kolid}', 'Miniprogram\Core@getKolQrcode');
    Route::get('/isopne', 'Miniprogram\Core@isOpen');
    // 监听小程序消息
    Route::any('message', 'Miniprogram\Server@message');
    // 解密
    Route::post('decrypt', "Miniprogram\Auth@decryptData");
    // 获取小程序码
    Route::get('getqrcodeb', "Miniprogram\Core@getQrcodeB");
    // 记录小程序formid
    Route::post('logform', 'Miniprogram\Guide@logFormid');
    // 绑定小程序的openid
    Route::post('auth/bind', 'Miniprogram\Auth@bindAuthType');
    Route::get('guide/custom/{type}', 'Miniprogram\Guide@custom');
    Route::get('auth/jscode/{jscode}', 'Miniprogram\Auth@jscode');
    // 获取配置信息
    Route::get('/profile/{app}', 'Miniprogram\App@show');
    // 创建配置信息
    Route::post('/profile/store', 'Miniprogram\App@store');
    // 修改配置信息
    Route::post('/profile/{app}/update', 'Miniprogram\App@update');

    Route::get('profile/course/{version}', 'Miniprogram\App@course');
    // 阅读教程
    Route::post('/profile/course', 'Miniprogram\App@readCourse');

    // 获取用户信息
    Route::get('user', 'Miniprogram\Auth@user');
    // 获取分享链接专属标记
    Route::get('/share/link', 'Miniprogram\Invite@getLink');
    // 通过邀请进入
    Route::get('/share/link/{link}/into', 'Miniprogram\Invite@intoLink');
    // 获取邀请统计
    Route::get('/share/link/list', 'Miniprogram\Invite@inviteList');
    // 创建动作意图
    Route::post('/action/store', 'Miniprogram\Action@store');
    // 获取动作意图
    Route::get('/action/{action}', 'Miniprogram\Action@get');
    // 举报
    Route::post('complaint', 'Miniprogram\ComplaintController@create');
    Route::get('complaint', 'Miniprogram\ComplaintController@show');
    // 反馈
    Route::post('feedback', 'Miniprogram\FeedbackController@create');
});


// 语音邮箱
Route::group(['prefix' => 'gnight'], function () {
    // 用户信息
    Route::get('user', 'Gnight\User@user');
    // 更新用户信息
    Route::put('user', 'Gnight\User@update');
    // 我的语音
    Route::get('user/voices', 'Gnight\User@voices');

    // 助力解锁
    Route::get('lockinvite/check/{get_voice_id}', 'Gnight\LockInvite@check');
    // 邀请页信息
    Route::get('lockinvite/invites/get/{get_voice_id}', 'Gnight\LockInvite@invites');

    // 分享小程序邀请
    Route::get('voiceinvite/check/{share_uid}', 'Gnight\VoiceInvite@check');

    // 语音信息
    Route::get('/voices/get/{voice_id}', 'Gnight\Voice@get');
    // 群分享获取语音
    Route::get('/voices/getbyshare', 'Gnight\Voice@getByShare');
    // 获取语音
    Route::get('/voices/getbyfirst', 'Gnight\Voice@getByFirst');
    // 获取语音信息
    Route::get('/voices/getshare/{voice_id}', 'Gnight\Voice@getShare');

    // 获得分享语音
    Route::get('/voices/getvoice/{voice_id}', 'Gnight\Voice@getVoice');
});


// 测脱单
Route::group(['prefix' => 'tuodan'], function () {
    Route::post('submit', 'Experience\TuodanController@index');
    Route::post('form', 'Experience\TuodanController@form');
    Route::get('info', 'Experience\TuodanController@info');
});


Route::get('/app/model/cnt', 'Home@modelCnt');


// 福利中心
Route::group(['prefix' => 'welfare'], function ($router) {
    /** @var \Illuminate\Support\Facades\Route $router */
    $router->get('signin', 'Welfare\SigninController@getSignin');
    $router->post('signin', 'Welfare\SigninController@signin');

    $router->get('lotterys', 'Welfare\LotteryController@lotterys');
    $router->get('historys', 'Welfare\LotteryController@historys');
    $router->get('luckys', 'Welfare\LotteryController@luckys');
    $router->get('lottery', 'Welfare\LotteryController@lottery');
    $router->get('mylotterys', 'Welfare\LotteryController@myLotterys');
    $router->post('ticket', 'Welfare\LotteryController@ticket');
    $router->post('invitation', 'Welfare\LotteryController@invitation');
    $router->post('firstinvitation', 'Welfare\LotteryController@firstInvitation');

    $router->get('prizes', 'Welfare\PrizeController@prizes');
    $router->post('prizes/fill', 'Welfare\PrizeController@fill');

    $router->get('stores', 'Welfare\JigsawController@stores');
    $router->get('flows', 'Welfare\JigsawController@flows');
    $router->post('shopping', 'Welfare\JigsawController@shopping');
});


// 心情日记
Route::group(['prefix' => 'diarys', 'namespace' => 'Diary'], function ($router) {
    $router->get('me', 'DiaryController@me');
    $router->get('/', 'DiaryController@index');
    $router->post('/', 'DiaryController@store');
    $router->get('{id}', 'DiaryController@show')->where('id', '[0-9]+');
    $router->delete('{id}', 'DiaryController@destroy')->where('id', '[0-9]+');
    $router->put('{id}/thumb', 'DiaryController@thumbing')->where('id', '[0-9]+');
    $router->put('{id}/selecting', 'DiaryController@setSelecting')->where('id', '[0-9]+');
    $router->put('{id}/topping', 'DiaryController@setTopping')->where('id', '[0-9]+');
});


// 日志回流

Route::put('logs/', 'NoticeController@read');


// 页面访问接口
Route::post('access_log', 'LogController@accessLog');
// 群日志接口
Route::post('group_log', 'LogController@groupLog');


// 校花校草榜单
Route::group(['prefix' => 'appearances', 'namespace' => 'Appearance'], function ($router) {
    // 全国榜
    $router->get('rank/province', 'RankController@countryRank');
    // 省榜
    $router->get('rank/province/{province}', 'RankController@provinceRank');
    // 学校榜
    $router->get('rank/school', 'RankController@schoolRank');

    //
    $router->get('medias', 'RankController@medias');
    // 卡片信息
    $router->get('partners/{partner_id}', 'RankController@partner');
    // 投票明细
    $router->get('votes', 'VoteController@votes');
    // 投票
    $router->post('vote', 'VoteController@vote');
    // 申请上榜
    $router->post('apply', 'VoteController@apply');
    // 下榜
    $router->put('apply', 'VoteController@updateApply');
});


Route::group(['prefix' => 'qqmini'], function ($router) {
    /** @var Route $router */
    $router->post('formid', 'QQMiniApp\FormController@store');
});


// 游戏玩法：测一测
Route::group(['prefix' => 'game', 'namespace' => 'Game'], function ($router) {
    /** @var Route $router */
    $router->get('cyc/questions', 'CycController@index');
    $router->get('cyc/questions/{question_id}', 'CycController@show');
    $router->post('cyc/questions/{question_id}/answers', 'CycController@answer');
});

//
Route::group(['prefix' => 'beta'], function ($router) {
    /** @var Route $router */
    $router->get('paint', 'User\BetaController@paint');
});


// 弹窗
Route::group(['prefix' => 'popup'], function ($router) {
    /** @var Route $router */
    $router->get('paint', 'User\PopupController@paint');
});


Route::group(['prefix' => 'custom_article', 'namespace' => 'CustomArticle'], function ($route) {
    // 文章
    $route->get('articles/{article}', 'ArticleController@show');

    // 评论
    $route->get('articles/{article}/comments', 'CommentController@index');
    $route->get('articles/{article}/comments/{comment}', 'CommentController@show');
    $route->post('articles/{article}/comments', 'CommentController@store');
    $route->delete('articles/{article}/comments/{comment}', 'CommentController@destroy');

    // 回复
    $route->post('articles/{article}/comments/reply', 'CommentController@store');
});
