<?php

//use Illuminate\Http\Request;
use App\Facades\ChatService;
use App\Http\Controllers\App\ShopController;
use App\Models\User;
use App\Models\WangYiYun;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\App\LoginController;
use App\Http\Controllers\App\UserController;
use App\Http\Controllers\App\HealthController;
use App\Http\Controllers\App\UploadController;
//use App\Http\Controllers\App\ServiceController;
use App\Http\Controllers\App\OrderController;
//use App\Http\Controllers\App\ChatController;
use App\Http\Controllers\App\UserInfoController;
use App\Http\Controllers\App\GuideController;
//use App\Http\Controllers\App\Controller;
use App\Http\Controllers\App\FatController;
//use App\Http\Controllers\App\ShopController;
//use App\Http\Controllers\App\UpdateInfoController;
use App\Http\Controllers\App\ConfigController;
use App\Http\Controllers\App\ChatController;
use cccdl\yunxin_sdk\Im\User as ImUser;
use App\Http\Controllers\App\VideoController;
use App\Http\Controllers\App\DeviceController;
use App\Http\Controllers\App\BandController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware("banlist")->group(function () {
    //获取用户token
    Route::get("/login/getUserToken", [LoginController::class, 'getUserToken'])->name('app.get.user.token');
    //手机号密码登录
    Route::post('mobile/pwd/login', [LoginController::class, 'pwdLogin'])->name('app.mobile.pwd.login');
    //手机号验证码登录
    Route::post('mobile/code/login', [LoginController::class, 'codeLogin'])->name('app.mobile.code.login');
    //手机号一键登录
    Route::post('mobile/local/login', [LoginController::class, 'localLogin'])->name('app.mobile.local.login');

    Route::post('mobile/register/login', [LoginController::class, 'mobileRegisterLogin'])->name('app.mobile.register.login');
    Route::post('local/mobile/register/login', [LoginController::class, 'localRegisterLogin'])->name('app.local.mobile.register.login');

    Route::post('mobile/register', [LoginController::class, 'register'])->name('app.mobile.register');
    Route::post('email/register', [LoginController::class, 'register'])->name('app.email.register');
    //找回密码
    Route::post("forget/passwd", [LoginController::class, 'findPwd'])->name('app.find.passwd');
    //邮箱验证码
    Route::post("email/code", [LoginController::class, 'sendEmailCode'])->name('app.send.email.code');
    //手机验证码
    Route::post('mobile/code', [LoginController::class, 'sendMobileCode'])->name('app.send.mobile.code')->middleware('checkeGainMobileCode');

    Route::middleware(['auth:api', 'setLanguage'])->group(function () {
        //切换语言
        Route::put('change/language', [UserController::class, 'changeLanguage'])->name('app.user.change.language');

        //注销账号
        Route::post("login/off", [LoginController::class, 'loginOff'])->name('app.login.off');
        /**
         * 用户信息
         */
        //获取手机号
        Route::post("/code/to/mobile", [UserController::class, 'codeMobile'])->name('app.code.mobile');
        //填写用户手机号
        Route::post('bind/mobile', [UserController::class, 'updateUserInfo'])->name('app.update.user.mobile')->middleware('checkInputUserInfo');
        //填写用户信息
        Route::put('user/info', [UserController::class, 'updateUserInfo'])->name('app.update.user.info')->middleware('checkInputUserInfo');
        //用户信息
        Route::get('get/user/info', [UserController::class, 'userInfo'])->name("app.user.info");

        /**
         * 公共
         */
        //上传
        Route::post('upload/image', [UploadController::class, 'uploadImage'])->name('app.upload.image');
        Route::post('netease/upload', [UploadController::class, 'neteaseUpload'])->name("app.netease.upload");
        //获取手机号验证码
        Route::get('mobile/code', [UserController::class, 'mobileCode'])->name('app.mobile.code')->middleware('checkeGainMobileCode');

        /**
         * 体脂信息
         */
        //首页
        Route::get('home', [HealthController::class, 'home'])->name('app.health.home');
        //保存体脂信息
        Route::post('health/log', [HealthController::class, 'storeHealthLog'])->name('app.store.health.log');
        Route::post('health/log/v1', [HealthController::class, 'storeHealthLogV1'])->name('app.store.health.log.v1');
        Route::post('send/health/log', [HealthController::class, 'sendHealthMsgToGroup'])->name('app.send.health.log');
        //深度报告
        Route::get('deep/health/report', [HealthController::class, 'deepReport'])->name('app.deep.health.report');
        //体脂记录
        Route::get('health/logs', [HealthController::class, 'healthLogs'])->name('app.health.logs');
        //体脂详情
        Route::get('health/logs/detail', [HealthController::class, 'healthLog'])->name('app.health.logs.detail');
        //体脂对比
        Route::post('compare/health/logs', [HealthController::class, 'compareHealthLogs'])->name('app.compare.health.logs');
        //删除体脂信息
        Route::delete('health/log', [HealthController::class, 'deleteHealthLog'])->name('app.delete.health.log');
        //图表统计
        Route::get('health/stat', [HealthController::class, 'healthStat'])->name('app.health.stat');
        //图标数据
        Route::get('health/kinds', [HealthController::class, 'healthKinds'])->name('app.health.kinds');

        /**
         * 体脂新-第二版
         */
        //首页
        Route::get('fat/home', [FatController::class, 'home'])->name('app.fat.home');
        //保存体脂信息
        Route::post('fat/log', [FatController::class, 'storeFatLog'])->name('app.store.fat.log');
        //体脂记录
        Route::get('fat/logs', [FatController::class, 'fatLogs'])->name('app.fat.logs');
        //体脂详情
        Route::get('fat/logs/detail', [FatController::class, 'fatLog'])->name('app.fat.logs.detail');
        //删除体脂信息
        Route::delete('fat/log', [FatController::class, 'deleteFatLog'])->name('app.delete.fat.log');
        //图标数据
        Route::get('fat/kinds', [FatController::class, 'fatKinds'])->name('app.fat.kinds');
        //图表统计
        Route::get('fat/stat', [FatController::class, 'fatStat'])->name('app.fat.stat');
        //体脂对比
        Route::get('compare/fat/logs', [FatController::class, 'getDaysCompare'])->name('app.compare.fat.logs');




        /**
         * 服务
         */
        //获取服务人员
        Route::get("get/service/user", [ChatController::class, 'getServiceUser'])->name("app.get.service.user");

        /**
         * 餐单
         */
        Route::get('user/guides', [GuideController::class, 'guides'])->name('app.guides');
        Route::get('user/guides/v1', [GuideController::class, 'guidesV1'])->name('app.guides.v1');

        Route::get('/get/user/guides', [GuideController::class, 'getGuides'])->name('app.get.guides');


        /**
         * 订单
         */
        //下单
        Route::post('pay/order/services/{service_id}', [OrderController::class, 'payOrder'])->name('app.pay.order');
        //订单列表
        Route::get('orders', [OrderController::class, 'orders'])->name('app.orders');
        Route::get('order/log', [OrderController::class, 'getOrderLog'])->name('app.order.logs');
        Route::post('order/update/server/status', [OrderController::class, 'updateServerStatus'])->name('app.order.update.server.status');
        //订单详情
        Route::get('orders/{order_id}', [OrderController::class, 'order'])->name("app.order.detail");
        //虚拟订单绑定用户
        Route::post('order/bind/{order_id}', [OrderController::class, 'bindUser'])->name('app.order.bind');

        /**
         * app群聊相关接口
         */
        //发送消息敏感词过滤
        Route::post('filter/message', [ChatController::class, 'filterMessage'])->name('app.filter.message');
        //离开群聊
        Route::post('leave/group', [ChatController::class, 'leaveGroup'])->name("app.leave.group");
        //群聊记录
        Route::get('groups/{group_id}/messages', [ChatController::class, 'chatMessages'])->name("app.group.messages");
        //群资料
        Route::get('groups/{group_id}/info', [ChatController::class, 'groupInfo'])->name('app.group.info');
        Route::get('get/group/info', [ChatController::class, 'getGroupInfo'])->name('app.get.group.info');
        //修改用户在群聊的昵称
        Route::post('groups/{group_id}/updateUserNick', [ChatController::class, 'updateGroupUserNickname'])->name('app.group.updateUserNick');


        /**
         * 个人信息
         */
        //个人健康信息
        Route::get('user/health/info', [UserInfoController::class, 'healthInfo'])->name('app.user.health.info');
        Route::get('user/health/info/v1', [UserInfoController::class, 'healthInfoV1'])->name('app.user.health.info/v1');
        //个人健康信息修改
        Route::put('user/health/info', [UserInfoController::class, 'updateHealthInfo'])->name('app.update.health.info');

        Route::delete('delete/body/images', [UserInfoController::class, 'deleteBodyImages'])->name('app.delete.body.images');
        Route::delete('delete/after/body/images', [UserInfoController::class, 'deleteAfterBodyImages'])->name('app.delete.after.body.images');

        //体检报告
        Route::get('user/health/report', [UserInfoController::class, 'healthReport'])->name("app.user.health.report");
        Route::get('user/health/report/v2', [UserInfoController::class, 'healthReportV2'])->name("app.user.health.report.v2");
        //修改报告
        Route::put("user/health/report", [UserInfoController::class, 'updateHealthReport'])->name('app.health.report');
        //上传体检报告
        Route::post('user/health/report', [UserInfoController::class, 'storeHealthReport'])->name("app.store.health.report");
        //删除报告
        Route::delete('user/health/report/{report_id}', [UserInfoController::class, 'deleteHealthReport'])->name('app.delete.health.report');
        //服务状态
        Route::get('user/service/status', [UserInfoController::class, 'serviceStatus'])->name("app.service.status");
        //生成营养素
        Route::post('make/user/nutrient', [UserInfoController::class, 'makeNutrient'])->name('app.make.user.nutrient');

        //添加补充资料
        Route::post('add/other/health/file', [UserInfoController::class, 'addOtherHealthFile'])->name('app.add.other.health.file');
        //获取补充资料列表
        Route::get('get/other/health/list', [UserInfoController::class, 'getOtherHealthFileList'])->name('app.add.other.health.list');
        //获取补充资料详情
        Route::get('get/other/health/detail', [UserInfoController::class, 'getOtherHealthFileDetail'])->name('app.get.other.health.detail');
        //删除补充资料
        Route::delete('delete/other/health/file', [UserInfoController::class, 'deleteOtherHealthFile'])->name('app.delete.user.other.health.file');

        /**
         * 商城接口
         */
        //获取商品列表
        Route::get('get/shop/goods/list', [ShopController::class, 'getGoodsList'])->name('app.get.goods.list');
        //获取商品详情
        Route::get('get/shop/goods/detail', [ShopController::class, 'getGoodsDetail'])->name('app.get.goods.detail');
        //获取订单列表
        Route::get('get/shop/order/list', [ShopController::class, 'getShopOrderList'])->name('app.get.shop.order.list');
        //获取订单详情
        Route::get('get/shop/order/detail', [ShopController::class, 'getOrderDetail'])->name('app.get.shop.order.detail');
        //购买商品
        Route::post('pay/shop/order', [ShopController::class, 'payOrder'])->name('app.pay.shop.order');
        //收货
        Route::post('shop/take/goods', [ShopController::class, 'takeGoods'])->name('app.shop.take.goods');

        /**
         * app配置相关接口
         */
        //意见反馈
        Route::post('send/feedback', [UserController::class, 'sendFeedback'])->name('app.send.feedback');
        //举报
        Route::post('send/report', [UserController::class, 'sendReport'])->name('app.send.report');

        //获取服务人员信息
        Route::get('get/service/user/info', [UserInfoController::class, 'getServiceUserInfo'])->name('app.get.service.user.info');
        Route::put('update/service/user/info', [UserInfoController::class, 'updateServiceUserInfo'])->name('app.update.service.user.info');

        /**
         * 分享
         */
        Route::get('get/mp/share/config', [ConfigController::class, 'getMpShareConfig'])->name('app.get.mp.share.config');

        /*
         * 视频
         */
        Route::get('search/video', [VideoController::class, 'searchVideo'])->name('app.search.video');
        Route::get('get/search/log', [VideoController::class, 'getSearchLog'])->name('app.get.search.log');
        Route::delete('delete/search/log', [VideoController::class, 'delSearchLog'])->name('app.del.search.log');
        Route::get('get/video/list', [VideoController::class, 'getVideoList'])->name('app.get.video.list');
        Route::get('get/video/detail/{id}', [VideoController::class, 'getVideoDetail'])->name('app.get.video.detail');
        Route::post('collect/video', [VideoController::class, 'collectVideo'])->name('app.collect.video');
        Route::get('get/collect/video', [VideoController::class, 'getCollect'])->name('app.get.collect.video');
        Route::post('visitor', [VideoController::class, 'visitor'])->name('app.video.visitor');
        Route::get('get/my/visitor', [VideoController::class, 'getMyVisitor'])->name('app.get.my.visitor');

        /**
         * 设备
         */
        Route::post('add/device', [DeviceController::class, 'addDevice'])->name('app.add.device');
        Route::get('get/device', [DeviceController::class, 'getDevice'])->name('app.get.device');
        Route::put('update/device/{id}', [DeviceController::class, 'updateDevice'])->name('app.update.device');

        /**
         * 快捷回复
         */
        Route::post('add/quick/reply', [ChatController::class, 'addQuickReply'])->name('app.add.quick.reply');
        Route::get('get/quick/reply', [ChatController::class, 'getQuickReply'])->name('app.get.quick.reply');
        Route::put('update/quick/reply/{id}', [ChatController::class, 'updateQuickReply'])->name('app.update.quick.reply');
        Route::get('get/quick/reply/detail/{id}', [ChatController::class, 'getQuickReplyDetail'])->name('app.get.quick.reply.detail');
        Route::delete('delete/quick/reply/{id}', [ChatController::class, 'deleteQuickReply'])->name('app.delete.quick.reply.detail');

        /**
         * 发送网易云视频
         */
        Route::post('send/im/video', [ChatController::class, 'sendImVideo'])->name('app.send.im.video');

        /**
         * 手环
         */
        //绑定手环
        Route::post("bind/band", [BandController::class, 'bindBand'])->name('app.bind.band');
        //手环列表
        Route::get("bands", [BandController::class, 'bands'])->name('app.bands');
        //解绑
        Route::post("unbind/band", [BandController::class, 'unbindBand'])->name('app.unbind.band');
        //切换手环
        Route::post("connect/band", [BandController::class, 'connectBand'])->name('app.connect.band');
        //断连手环
        Route::post("break/band", [BandController::class, 'breakBand'])->name('app.break.band');
        //设置目标
        Route::post("set/goals", [BandController::class, 'setGoals'])->name('app.set.goals');
        //查看目标
        Route::get("goals", [BandController::class, 'goals'])->name('app.goals');
        //上传数据
        Route::post("upload/sleep/data", [BandController::class, 'uploadSleepData'])->name('app.upload.sleep.data');
        Route::post("upload/hrrest/data", [BandController::class, 'uploadHrrestData'])->name('app.upload.hrrest.data');
        Route::post("upload/temp/data", [BandController::class, 'uploadTempData'])->name('app.upload.temp.data');
        Route::post("upload/hrv/data", [BandController::class, 'uploadHrvData'])->name('app.upload.hrv.data');
        Route::post("upload/blood/data", [BandController::class, 'uploadBloodData'])->name('app.upload.blood.data');
        Route::post("upload/syn/data", [BandController::class, 'uploadSynData'])->name('app.upload.syn.data');

        Route::post("upload/origin/sleep/data", [BandController::class, 'uploadOriginSleepData'])->name('app.upload.origin.sleep.data');
        Route::post("upload/origin/hrrest/data", [BandController::class, 'uploadOriginHrrestData'])->name('app.upload.origin.hrrest.data');
        Route::post("upload/origin/temp/data", [BandController::class, 'uploadOriginTempData'])->name('app.upload.origin.temp.data');
        Route::post("upload/origin/hrv/data", [BandController::class, 'uploadOriginHrvData'])->name('app.upload.origin.hrv.data');
        Route::post("upload/origin/blood/data", [BandController::class, 'uploadOriginBloodData'])->name('app.upload.origin.blood.data');
        Route::post("upload/origin/syn/data", [BandController::class, 'uploadOriginSynData'])->name('app.upload.origin.syn.data');
        Route::post("upload/origin/battery/data", [BandController::class, 'uploadOriginBatteryData'])->name('app.upload.origin.battery.data');

        //查看睡眠数据
        Route::get("daily/sleep", [BandController::class, 'dailySleep'])->name('app.daily.sleep');
        //手环绑定状态
        Route::get("band/bind/status", [BandController::class, 'bindStatus'])->name('app.band.status');
        //数据
        Route::post("insert/data", [BandController::class, 'insertData']);
        //最新数据日期
        Route::get("newest/date", [BandController::class, 'newestDate']);
        Route::get("newest/origin/date", [BandController::class, 'newestOriginDate']);
        //最新一组数据开始记录时间
        Route::get("newest/origin/first/date", [BandController::class, 'newestOriginFirstDate']);
        //上传手环状态信息
        Route::post("upload/band/consume/data", [BandController::class, 'uploadBandConsumeData'])->name('app.upload.band.consume.data');
        //查看睡眠原始数据
        Route::get("daily/origin/sleep", [BandController::class, 'dailyOriginSleep'])->name('app.daily.origin.sleep');
        Route::get("daily/origin/hrrest", [BandController::class, 'dailyOriginHrrest'])->name('app.daily.origin.hrrest');
        Route::get("daily/origin/temp", [BandController::class, 'dailyOriginTemp'])->name('app.daily.origin.temp');
        Route::get("daily/origin/hrv", [BandController::class, 'dailyOriginHrv'])->name('app.daily.origin.hrv');
        Route::get("daily/origin/blood", [BandController::class, 'dailyOriginBlood'])->name('app.daily.origin.blood');
        Route::get("daily/origin/syn", [BandController::class, 'dailyOriginSyn'])->name('app.daily.origin.syn');
        Route::get("daily/origin/battery", [BandController::class, 'dailyOriginBattery'])->name('app.daily.origin.battery');

        //发送网易云消息
        Route::post("send/im/msg", [ChatController::class, 'sendImMsg']);

    });

    Route::get("get/oss/config", [UploadController::class, 'stsConfig'])->name('app.get.oss.config');

    //网易云信消息回调
    Route::post('message/callback', [ChatController::class, 'chatCallback'])->name('app.message.callback');

    //获取隐私协议
    Route::get('get/privacy', [ConfigController::class, 'getPrivacy'])->name('app.get.privacy');
    //获取服务协议
    Route::get('get/service/term', [ConfigController::class, 'getServiceTerm'])->name('app.get.service.term');
    //根据版本号获取配置
    Route::get('get/version/status', [ConfigController::class, 'getVersionStatus'])->name('app.get.version.status');
    Route::get('get/app/version/config', [ConfigController::class, 'getAppVersionConfigV1'])->name('app.get.app.version.config');
    Route::get('get/ios/version/config', [ConfigController::class, 'getIosVersionConfig'])->name('app.get.ios.version.config');
    //获取国家电话编号
    Route::get('get/country/phone/code', [ConfigController::class, 'getCountryPhoneCode'])->name('app.get.country.phone.code');

    //订单回调
    Route::post('shop/order/callback', [ShopController::class, 'orderCallback'])->name('app.shop.order.callback');


    Route::post("send/error/notice", [\App\Http\Controllers\Controller::class, 'sendAppError']);


});

