<?php

//use Illuminate\Http\Request;
use App\Facades\ChatService;
use App\Http\Controllers\StepController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\HealthController;
use App\Http\Controllers\UploadController;
use App\Http\Controllers\ServiceController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\ChatController;
use App\Http\Controllers\UserInfoController;
use App\Http\Controllers\GuideController;
use App\Http\Controllers\Controller;
use App\Http\Controllers\FatController;
use App\Http\Controllers\ShopController;
use App\Http\Controllers\UpdateInfoController;
use App\Http\Controllers\PublicController;

/*
|--------------------------------------------------------------------------
| 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!
|
*/

//小程序登录  code换token
Route::post("/code/to/login", [LoginController::class, 'codeLogin'])->name('mp.code.login');

//体脂详情V2
Route::get('health/logs/detail/v2', [HealthController::class, 'healthLogV2'])->name('mp.health.logs.detail.v2');
//体脂详情V2
Route::get('fat/logs/detail/v2', [FatController::class, 'fatLog'])->name('mp.fat.logs.detail.v2');
//深度报告
Route::get('users/{user_id}/deep/health/report', [HealthController::class, 'deepReport'])->name('mp.deep.health.report.v2');
//分享
Route::get('users/{user_id}/health/home', [HealthController::class, 'home'])->name('mp.health.share.home');
Route::get('users/{user_id}/fat/home', [FatController::class, 'home'])->name('mp.fat.home.v2');

//按照手机号删除某个记录
Route::post('user/mobile/del', [UserInfoController::class, 'deleteUserInfoByMobile'])->name('mp.user.mobile.del');

//获取用户token
Route::get("/login/getUserToken", [LoginController::class, 'getUserToken'])->name('mp.get.user.token');
Route::match(['get', 'post'],'mobile/code', [UserController::class, 'mobileCode'])->name('mp.mobile.code')->middleware('checkeGainMobileCode');


Route::middleware(['auth:api','setLanguage'])->group(function () {
    //切换语言
    Route::put('change/language', [UserController::class, 'changeLanguage'])->name('mp.user.change.language');
    //设置体脂秤
    Route::put('set/fat/device', [UserController::class, 'setFatDevice'])->name('mp.user.set.fat.device');
    /**
     * 用户信息
     */
    //获取手机号
    Route::post("/code/to/mobile", [UserController::class, 'codeMobile'])->name('mp.code.mobile');
    //填写用户手机号
    Route::post('bind/mobile', [UserController::class, 'updateUserInfo'])->name('mp.update.user.mobile')->middleware('checkInputUserInfo');
    //填写用户信息
    Route::put('user/info', [UserController::class, 'updateUserInfo'])->name('mp.update.user.info')->middleware('checkInputUserInfo');
    //用户信息
    Route::get('user/info', [UserController::class, 'userInfo'])->name("mp.user.info");
    //用户邀请二维码
    Route::get('user/get/qrcode', [UserController::class, 'getUserInviteQrcode'])->name("mp.user.get.qrcode");

    /**
     * 体脂信息
     */
    //首页
    Route::get('home', [HealthController::class, 'home'])->name('mp.health.home');
    //首页v2
    Route::get('get/home/data', [HealthController::class, 'getHomeData'])->name('mp.get.home.data');
    //保存体脂信息
    Route::post('health/log', [HealthController::class, 'storeHealthLog'])->name('mp.store.health.log');
    //保存体脂信息v2
    Route::post('save/fat/log', [HealthController::class, 'saveFatLog'])->name('mp.save.fat.log');
    //深度报告
    Route::get('deep/health/report', [HealthController::class, 'deepReport'])->name('mp.deep.health.report');
    //体脂记录
    Route::get('health/logs', [HealthController::class, 'healthLogs'])->name('mp.health.logs');
    //体脂记录v2
    Route::get('get/fat/logs', [HealthController::class, 'getFatLogList'])->name('mp.get.fat.logs');
    //体脂详情
    Route::get('health/logs/detail', [HealthController::class, 'healthLog'])->name('mp.health.logs.detail');
    //体脂详情v2
    Route::get('get/fat/detail', [HealthController::class, 'getFatDetail'])->name('mp.get.fat.detail');
    //体脂对比
    Route::post('compare/health/logs', [HealthController::class, 'compareHealthLogs'])->name('mp.compare.health.logs');
    //体脂对比v2
    Route::get('compare/fat/data', [HealthController::class, 'getCompareFatData'])->name('mp.compare.fat.data');
    //删除体脂信息
    Route::delete('health/log', [HealthController::class, 'deleteHealthLog'])->name('mp.delete.health.log');
    //图表统计
    Route::get('health/stat', [HealthController::class, 'healthStat'])->name('mp.health.stat');
    //图表统计v2
    Route::get('get/fat/stat', [HealthController::class, 'getFatStat'])->name('mp.get.fat.stat');
    //图标数据
    Route::get('health/kinds', [HealthController::class, 'healthKinds'])->name('mp.health.kinds');
    //图标数据v2
    Route::get('get/fat/kinds', [HealthController::class, 'getFatKinds'])->name('mp.get.fat.kinds');
    //保存弱网环境数据
    Route::post('save/weak/network/fat', [HealthController::class, 'saveWeakNetworkFat'])->name('mp.save.weak.network.fat');

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




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

    /**
     * 服务
     */
    Route::get("service/detail", [ServiceController::class, 'service'])->name("mp.service.detail");


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

    /**
     * 订单
     */
    //下单
    Route::post('pay/order/services/{service_id}', [OrderController::class, 'payOrder'])->name('mp.pay.order');
    //订单列表
    Route::get('orders', [OrderController::class, 'orders'])->name('mp.orders');
    Route::get('order/log', [OrderController::class, 'getOrderLog'])->name('mp.order.logs');
    Route::post('order/update/server/status', [OrderController::class, 'updateServerStatus'])->name('mp.order.update.server.status');
    //订单详情
    Route::get('orders/{order_id}', [OrderController::class, 'order'])->name("mp.order.detail");
    //虚拟订单绑定用户
    Route::post('order/bind/{order_id}', [OrderController::class, 'bindUser'])->name('mp.order.bind');
    /**
     * 群聊
     */
    //进入群聊
    Route::post('join/group', [ChatController::class, 'joinGroup'])->name('mp.join.group');
    //离开群聊
    Route::post('leave/group', [ChatController::class, 'leaveGroup'])->name("mp.leave.group");
    //群聊记录
    Route::get('groups/{group_id}/messages', [ChatController::class, 'chatMessages'])->name("mp.group.messages");
    //发送聊天消息
    Route::post('send/groups/{group_id}/message', [ChatController::class, 'sendMessage'])->name("mp.send.group.message");
    //绑定客户端
    Route::post("bind/client/{client_id}", [ChatController::class, 'bindClient'])->name("mp.bind.client");
    //群资料
    Route::get('groups/{group}/info', [ChatController::class, 'groupInfo'])->name('mp.group.info');

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

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

    /**
     * 商城接口
     */
    //获取商品列表
    Route::get('get/shop/goods/list', [ShopController::class, 'getGoodsList'])->name('mp.get.goods.list');
    //获取商品列表V2
    Route::get("get/shop/goods/list/v2", [ShopController::class, 'getGoodsListV2']);
    //获取商品详情
    Route::get('get/shop/goods/detail', [ShopController::class, 'getGoodsDetail'])->name('mp.get.goods.detail');
    //商品详情V2
    Route::get('get/shop/goods/detail/v2', [ShopController::class, 'getGoodsDetailV2']);
    //商品详情V3
    Route::get('get/shop/goods/detail/v3', [ShopController::class, 'getGoodsDetailV3']);
    //获取订单列表
    Route::get('get/shop/order/list', [ShopController::class, 'getShopOrderList'])->name('mp.get.shop.order.list');
    //订单列表V2
    Route::get('get/shop/order/list/v2', [ShopController::class, 'getShopOrderListV2']);

    //获取订单详情
    Route::get('get/shop/order/detail', [ShopController::class, 'getOrderDetail'])->name('mp.get.shop.order.detail');
    //获取订单详情V2
    Route::get('get/shop/order/detail/v2', [ShopController::class, 'getOrderDetailV2']);

    //购买商品
    Route::post('pay/shop/order', [ShopController::class, 'payOrder'])->name('mp.pay.shop.order');
    //购买商品V2
    Route::post('pay/shop/order/v2', [ShopController::class, 'payOrderV2']);
    //购买商品V3
    Route::post('pay/shop/order/v3', [ShopController::class, 'payOrderV3']);

    //收货
    Route::post('shop/take/goods', [ShopController::class, 'takeGoods'])->name('mp.shop.take.goods');
    Route::post('shop/take/goods/v2', [ShopController::class, 'takeGoodsV2']);

    //获取三步曲配置
    Route::get("get/info/step/config", [PublicController::class, 'getInfoStepConfig'])->name('mp.get.info.step.config');

    /**
     * 微信步数
     */
    //获取步数
    Route::get("get/user/step", [StepController::class, 'getUserStep'])->name('mp.get.user.step');
    //步数排行榜
    Route::get('get/step/ranks', [StepController::class, 'getStepRanks'])->name('mp.get.step.ranks');
    //历史步数
    Route::get('get/history/step', [StepController::class, 'getHistoryStep'])->name('mp.get.history.step');
    //保存身高体重数据
    Route::post('step/save/body/data', [StepController::class, 'saveBodyData'])->name('mp.step.save.body.data');
    Route::post('step/apply', [StepController::class, 'applyStep'])->name('mp.step.apply');

    Route::get('get/my/info', [UserController::class, 'getMyInfo'])->name('mp.get.my.info');
});
//订单回调
Route::any('notify/orders/{trade_no}', [OrderController::class, 'notifyOrder'])->name("mp.notify.order");

//订单回调
Route::post('shop/order/callback', [ShopController::class, 'orderCallback'])->name('mp.shop.order.callback');
//订单回调V2
Route::any('shop/order/{trade_no}/callback', [ShopController::class, 'orderCallbackV2']);

/**
 * 微信服务端
 */
Route::any('server', [Controller::class, 'wechatServer'])->name('wechat.server');


/**
 * 更新数据
 */
Route::get('update/partners/info', [UpdateInfoController::class, 'updatePartnersInfo'])->name('test.update.partners.info');
//更新用户旧全身照
Route::post('update/user/body/images', [UpdateInfoController::class, 'updateBodyImages'])->name('test.update.user.body.images');
//更新用户旧测量记录
Route::get('update/user/fat/logs', [UpdateInfoController::class, 'updateOldFatLogs'])->name('test.update.user.fat.logs');
Route::get('update/user/health/logs', [UpdateInfoController::class, 'updateOldHealthLogs'])->name('test.update.user.health.logs');
Route::get('test/send/work/msg', [UpdateInfoController::class, 'testSendWorkMsg'])->name('test.send.work.msg');
//根据订单号删除订单
Route::delete('delete/order/by/number', [UpdateInfoController::class, 'deleteOrderByTradeNo'])->name('delete.order.by.number');
Route::post('add/restaurant/date', [UpdateInfoController::class, 'addRestaurantDate'])->name('update.add.restaurant.date');
//插入省市区
//Route::get('add/china', [UpdateInfoController::class, 'insertChina'])->name('mp.add.china');
//获取公众号二维码
//Route::get('get/official/qrcode', [UpdateInfoController::class, 'getQrcode'])->name('get.official.qrcode');
//清空表数据
//Route::get('clear/fat/log', [UpdateInfoController::class, 'clearFatLog'])->name('clear.fat.log');
//Route::get('clear/public/config', [UpdateInfoController::class, 'clearPublicConfig'])->name('clear.public.config');
//Route::get('update/user/fat/data', [UpdateInfoController::class, 'updateUserFatData'])->name('update.user.fat.data');
//Route::post('send/wang/yi/msg', [UpdateInfoController::class, 'sendWangYiMsg'])->name('send.wang.yi.msg');
//Route::put('update/collaborator/status', [UpdateInfoController::class, 'updateCollaboratorStatus'])->name('update.collaborator.status');
//Route::put('update/collaborator/type', [UpdateInfoController::class, 'updateCollaboratorType'])->name('update.collaborator.type');
//Route::put('update/coach/status', [UpdateInfoController::class, 'updateCoachStatus'])->name('update.coach.status');
//Route::put('update/service/role/user', [UpdateInfoController::class, 'updateServiceUserRole'])->name('update.service.role.user');
//Route::get('update/restaurant/user', [UpdateInfoController::class, 'updateRestaurantUser'])->name('update.restaurant.user');
//Route::post('test/send/msg', [UpdateInfoController::class, 'testSendMsg'])->name('update.test.send.msg');
//Route::get('update/service/user/to/wechat', [UpdateInfoController::class, 'updateServiceUserToWechat'])->name('update.service.user.to.wechat');
//Route::get('clear/video', [UpdateInfoController::class, 'clearVideoTable'])->name('update.clear.video');
//Route::get('insert/video', [UpdateInfoController::class, 'insertVideo'])->name('update.insert.video');
//Route::get('clear/import/apply', [UpdateInfoController::class, 'clearImportActivityUser'])->name('update.clear.activity.apply');
//Route::get('clear/apply/log', [UpdateInfoController::class, 'clearMeetingApplyTable'])->name('update.clear.activity.apply.meeting');
//Route::get('update/activity', [UpdateInfoController::class, 'updateActivity'])->name('update.activity');
//Route::post('insert/activity/apply', [UpdateInfoController::class, 'insertActivityApply'])->name('update.insert.activity.apply');
//Route::get('update/update/user/info', [UpdateInfoController::class, 'updateUserInfo'])->name('update.update.user.info');
//Route::put('update/wechat/user/info', [UpdateInfoController::class, 'updateWechatInfo'])->name('update.wechat.user.info');
//Route::put('update/partner/user/info', [UpdateInfoController::class, 'updatePartnerInfo'])->name('update.partner.user.info');
//Route::put('update/collaborator/user/info', [UpdateInfoController::class, 'updateCollaboratorInfo'])->name('update.collaborator.user.info');
//Route::get('update/get/mp/user', [UpdateInfoController::class, 'getMpUser'])->name('update.get.mp.user');
//Route::put('update/service/user', [UpdateInfoController::class, 'updateServiceUser']);
//Route::put('update/restaurant/date', [UpdateInfoController::class, 'updateRestaurantDate']);
//Route::put('update/user/infos', [UpdateInfoController::class, 'updateUserInfoV1']);
//Route::put('update/user/source', [UpdateInfoController::class, 'updateUserSource']);
//Route::put('rollback/user/data', [UpdateInfoController::class, 'rollbackUserData']);
//Route::put('update/china', [UpdateInfoController::class, 'updateChina']);
//Route::delete('delete/service/user', [UpdateInfoController::class, 'deleteServiceUser']);
//Route::put('update/collaborator/to/user', [UpdateInfoController::class, 'updateCollaboratorMobileToUser']);
//Route::put('update/survey', [UpdateInfoController::class, 'updateSurvey']);
//Route::put('update/wechat/user', [UpdateInfoController::class, 'updateWechatUser']);
//Route::post('test/send/im/msg', [UpdateInfoController::class, 'testSendImMsg']);
//Route::put('update/user/source/v1', [UpdateInfoController::class, 'updateUserSourceV1']);
//Route::get('update/order/group', [UpdateInfoController::class, 'addOrderGroup']);
//Route::get('get/user/im/group', [UpdateInfoController::class, 'getImGroups']);
//Route::delete('remove/user/im/group', [UpdateInfoController::class, 'removeImGroups']);
//Route::put('update/mobile/code', [UpdateInfoController::class, 'updateMobileCode']);
//Route::put('update/user/body/image', [UpdateInfoController::class, 'updateUserBodyImage']);
//Route::put('update/regular/activity', [UpdateInfoController::class, 'updateRegularActivity']);
Route::post('execute/sql', [UpdateInfoController::class, 'executeSql']);
Route::post('update/im/user/group/name', [UpdateInfoController::class, 'updateImUserGroupName']);
Route::post('send/msg/user/to/user', [UpdateInfoController::class, 'sendImMsgUserToUser']);
Route::post('update/im/extend', [UpdateInfoController::class, 'updateImExtend']);
Route::post('send/system/msg', [UpdateInfoController::class, 'sendTestSystemMsg']);
Route::post('update/im/user/info', [UpdateInfoController::class, 'updateImUserInfo']);
Route::post('update/user/to/user/info', [UpdateInfoController::class, 'updateUserToUserInfo']);
//Route::post('test/send/guide/msg', [UpdateInfoController::class, 'testSendGuideMsg']);
Route::post('update/old/fat/data', [UpdateInfoController::class, 'updateOldFatData']);
Route::post('insert/phone/code', [UpdateInfoController::class, 'insertPhoneCode']);
Route::post('send/mp/notice', [UpdateInfoController::class, 'sendMpNotice']);
Route::post('add/process', [UpdateInfoController::class, 'addProcess']);

//发送网易云信app自定义系统消息
Route::post('send/app/system/msg', [UpdateInfoController::class, 'sendAppSystemMsg']);
//获取心率手环统计数据
Route::get('get/band/heart/data', [UpdateInfoController::class, 'getHeartData'])->name('get.heart.data');
/**
 * 公共接口
 */

//获取阿里云oss配置
Route::get("get/oss/config", [PublicController::class, 'aliYunSignature'])->name('mp.get.oss.config');
//获取举报类型
Route::get("get/report/type", [PublicController::class, 'getReportType'])->name('mp.get.report.type');
//获取小程序jssdk配置
Route::get("get/js/sdk/config", [PublicController::class, 'getJsSdkConfig'])->name('mp.get.js.sdk.config');
Route::get("get/china", [PublicController::class, 'getChina'])->name('mp.get.china');
Route::get("get/version", [PublicController::class, 'getVersion'])->name('mp.public.get.version');
Route::get("get/policy", [PublicController::class, 'getPrivacy'])->name('mp.public.get.policy');
Route::get("get/official/qrcode/img", [PublicController::class, 'getOfficialQrcodeImg'])->name('mp.public.get.official.qrcode');
//获取订阅通知模板id
Route::get('get/subscribe/template/id', [PublicController::class, 'getSubscribeTemplateId'])->name('mp.get.subscribe.template.id');

Route::any('test/code/update',function (){
   dd(1111);
});
//增加抽奖用户
Route::post("lottery/{id}/member", [Controller::class, 'addLotteryMember']);
