<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

use App\Controller\AreaController;
use App\Controller\BasicDataController;
use App\Controller\CallBackController;
use App\Controller\DoctorAccountController;
use App\Controller\DoctorAuthController;
use App\Controller\IndexController;
use App\Controller\InquiryController;
use App\Controller\LoginController;
use App\Controller\CodeController;
use App\Controller\MessageNoticeController;
use App\Controller\PatientCaseController;
use App\Controller\PatientCenterController;
use App\Controller\PatientDoctorController;
use App\Controller\PatientFamilyController;
use App\Controller\PatientOrderController;
use App\Controller\SafeController;
use App\Controller\SystemController;
use App\Controller\TestController;
use App\Controller\UserController;
use App\Controller\UserDoctorController;
use App\Controller\UserPatientController;
use App\Controller\UserPharmacistController;
use App\Services\SafeService;
use Hyperf\HttpServer\Router\Router;


/**
 * ------------医生端api---------------------
 */
// 医生端api
Router::addGroup('/doctor', function () {
    // 首页
    Router::get('/index', [IndexController::class, 'doctorIndex']);

    // 身份认证
    Router::addGroup('/auth', function () {
        // 获取实名认证信息
        Router::get('/real', [DoctorAuthController::class, 'getAuthReal']);

        // 新增实名认证
        Router::post('/real', [DoctorAuthController::class, 'addAuthReal']);

        // 获取身份认证信息
        Router::get('/iden', [DoctorAuthController::class, 'getAuthIden']);

        // 新增身份认证信息
        Router::post('/iden', [DoctorAuthController::class, 'addAuthIden']);

        // 获取多点执业认证信息
        Router::get('/multi', [DoctorAuthController::class, 'getAuthMulti']);

        // 新增多点执业认证信息
        Router::post('/multi', [DoctorAuthController::class, 'addAuthMulti']);
    });

    // 问诊
    Router::addGroup('/inquiry', function () {
        // 获取医生问诊配置
        Router::get('/config', [UserDoctorController::class, 'getInquiryConfig']);

        // 医生问诊开关
        Router::put('/open', [UserDoctorController::class, 'putInquiryOpen']);

        // 修改医生问诊配置
        Router::put('/config', [UserDoctorController::class, 'putInquiryConfig']);

        // 获取患者问诊病例
        Router::get('/case', [InquiryController::class, 'getPatientInquiryCase']);

        // 获取医生问诊消息列表
        Router::get('/message', [UserDoctorController::class, 'getDoctorMessageList']);

        // 获取医生问诊消息用户属性
        Router::post('/message/attr', [UserDoctorController::class, 'getDoctorMessageAttrList']);

        // 医生接诊
        Router::post('/{order_inquiry_id:\d+}', [UserDoctorController::class, 'addDoctorInquiry']);

        // 结束问诊
        Router::put('/finish/{order_inquiry_id:\d+}', [UserDoctorController::class, 'putDoctorFinishInquiry']);
    });

    //银行卡
    Router::addGroup('/bank', function () {
        // 获取医生银行卡
        Router::get('', [UserDoctorController::class, 'getDoctorBankCard']);

        // 获取绑定银行卡详情信息
        Router::get('/info', [UserDoctorController::class, 'getDoctorBankCardInfo']);

        // 新增绑定医生银行卡
        Router::post('', [UserDoctorController::class, 'addDoctorBankCard']);

        // 更换医生银行卡
        Router::put('/{bank_card_id:\d+}', [UserDoctorController::class, 'putDoctorBankCard']);
    });

    // 个人中心
    Router::addGroup('/center', function () {
        // 获取医生个人中心数据
        Router::get('', [UserDoctorController::class, 'getDoctorCenter']);

        // 获取医生信息
        Router::get('/info', [UserDoctorController::class, 'getDoctorCenterInfo']);
    });

    // 我的账户
    Router::addGroup('/account', function () {
        // 获取我的账户数据
        Router::get('', [DoctorAccountController::class, 'getDoctorAccount']);

        // 获取我的账户日账单明细数据
        Router::get('/info', [DoctorAccountController::class, 'getDoctorAccountInfo']);
    });

    // 提现
    Router::addGroup('/withdrawal', function () {
        // 获取提现数据
        Router::get('', [DoctorAccountController::class, 'getDoctorWithdrawal']);

        // 获取可提现问诊订单列表
        Router::get('/order', [DoctorAccountController::class, 'getDoctorWithdrawalOrderList']);

        // 获取医生提现记录列表
        Router::get('/record', [DoctorAccountController::class, 'getDoctorWithdrawalRecordList']);
    });

    // 订单
    Router::addGroup('/order', function () {
        // 获取提现数据
        Router::get('/inquiry', [DoctorAccountController::class, 'getDoctorWithdrawal']);
    });

    // 处方
    Router::addGroup('/prescription', function () {
        // 获取处方列表
        Router::get('', [UserDoctorController::class, 'getPrescriptionList']);

        // 获取处方详情
        Router::get('/info', [UserDoctorController::class, 'getPrescriptionInfo']);

        // 修改处方
        Router::put('', [UserDoctorController::class, 'putPrescription']);

        // 新增处方
        Router::post('', [UserDoctorController::class, 'addPrescription']);
    });

    // 常用语
    Router::addGroup('/words', function () {
        // 获取常用语列表
        Router::get('', [UserDoctorController::class, 'getDoctorWords']);

        // 新增常用语列表
        Router::post('', [UserDoctorController::class, 'addDoctorWords']);

        // 删除常用语列表
        Router::delete('/{doctor_words_id:\d+}', [UserDoctorController::class, 'deleteDoctorWords']);
    });

    // 医生数据
    Router::addGroup('/info', function () {
        // 获取医生证书信息
        Router::get('/cret', [UserDoctorController::class, 'getDoctorCret']);

        // 获取医生专长列表-身份认证
        Router::get('/expertise', [UserDoctorController::class, 'getAuthDoctorExpertise']);

        // 获取医生名片
        Router::get('/card', [UserDoctorController::class, 'getDoctorInfoCard']);

        Router::addGroup('/brief', function () {
            // 获取医生个人简介数据
            Router::get('', [UserDoctorController::class, 'getDoctorBrief']);
        });
    });

    // 消息通知
    Router::addGroup('/message', function () {
        // 获取医生服务消息列表-分页
        Router::get('/service', [MessageNoticeController::class, 'getDoctorMessageService']);

        // 获取医生系统公告列表-分页
        Router::get('/system', [MessageNoticeController::class, 'getDoctorMessageSystem']);

        // 获取医生系统公告详情
        Router::get('/system/{notice_id:\d+}', [MessageNoticeController::class, 'getDoctorMessageSystemInfo']);
    });
});

/**
 * ------------患者端api---------------------
 */
// 患者端api
Router::addGroup('/patient', function () {
    // 首页
    Router::get('/index', [IndexController::class, 'patientIndex']);

    // 个人中心
    Router::addGroup('/center', function () {
        // 获取患者个人中心数据
        Router::get('', [UserPatientController::class, 'getPatientCenter']);

        // 获取患者信息
        Router::get('/info', [UserPatientController::class, 'getPatientCenterInfo']);
    });

    // 我的福利
    Router::addGroup('/coupon', function () {
        // 获取患者优惠卷列表
        Router::get('', [UserPatientController::class, 'getPatientCouponlist']);
    });

    // 问诊
    Router::addGroup('/inquiry', function () {
        // 创建问诊订单
        Router::post('', [InquiryController::class, 'addInquiryOrder']);

        // 检测是否可以接诊
        Router::get('/check', [PatientDoctorController::class, 'getDoctorInquiryCheck']);

        // 检测快速、购药订单分配医生状态
        Router::get('/assign/{order_inquiry_id:\d+}', [InquiryController::class, 'getInquiryAssign']);

        // 新增问诊评价
        Router::post('/evaluation', [InquiryController::class, 'addInquiryEvaluation']);

        // 获取问诊最低价格
        Router::get('/lowest-price', [InquiryController::class, 'getInquiryLowestPrice']);
    });

    // 医生数据
    Router::addGroup('/doctor', function () {
        // 获取医生列表-问诊
        Router::get('/inquiry', [PatientDoctorController::class, 'getInquiryDoctorList']);

        // 获取医生详情-问诊
        Router::get('/{doctor_id:\d+}', [PatientDoctorController::class, 'getInquiryDoctorInfo']);

        // 医生详情简介-详情中的简介-废弃
        Router::get('/profile/{doctor_id:\d+}', [PatientDoctorController::class, 'getDoctorProfile']);

        // 删除服务过患者的医生
        Router::delete('/history/{doctor_id:\d+}', [UserPatientController::class, 'deletePatientDoctor']);

        // 获取我的问诊、关注医生列表
        Router::get('/my', [PatientDoctorController::class, 'getDoctorList']);

        // 获取医生评价
        Router::get('/evaluation/{doctor_id:\d+}', [PatientDoctorController::class, 'getDoctorEvaluationList']);

        // 新增关注医生
        Router::post('/follow/{doctor_id:\d+}', [PatientDoctorController::class, 'addDoctorFollow']);

        // 取消关注医生
        Router::delete('/follow/{doctor_id:\d+}', [PatientDoctorController::class, 'deleteDoctorFollow']);
    });

    // 家庭成员
    Router::addGroup('/family', function () {
        // 获取家庭成员列表
        Router::get('', [PatientFamilyController::class, 'getFamilyList']);

        // 新增家庭成员
        Router::post('', [PatientFamilyController::class, 'addFamily']);

        // 修改家庭成员
        Router::put('/{family_id:\d+}', [PatientFamilyController::class, 'editFamily']);

        // 删除家庭成员
        Router::delete('/{family_id:\d+}', [PatientFamilyController::class, 'deleteFamily']);

        // 获取家庭成员详情
        Router::get('/{family_id:\d+}', [PatientFamilyController::class, 'getFamily']);

        // 个人情况
        Router::addGroup('/personal', function () {
            // 获取家庭成员详情-个人情况
            Router::get('/{family_id:\d+}', [PatientFamilyController::class, 'getFamilyPersonal']);

            // 修改家庭成员-个人情况
            Router::put('/{family_personal_id:\d+}', [PatientFamilyController::class, 'editFamilyPersonal']);

            // 新增家庭成员-个人情况
            Router::post('', [PatientFamilyController::class, 'addFamilyPersonal']);
        });

        // 健康情况
        Router::addGroup('/health', function () {
            // 获取家庭成员-健康状况
            Router::get('/{family_id:\d+}', [PatientFamilyController::class, 'getFamilyHealth']);

            // 修改家庭成员-健康情况
            Router::put('/{family_health_id:\d+}', [PatientFamilyController::class, 'editFamilyHealth']);

            // 新增家庭成员-健康情况
            Router::post('', [PatientFamilyController::class, 'addFamilyHealth']);
        });

        // 药品
        Router::addGroup('/product', function () {
            // 获取家庭成员用药记录列表
            Router::get('/record', [PatientFamilyController::class, 'getFamilyProductRecord']);
        });
    });

    // 病例
    Router::addGroup('/case', function () {
        // 获取患者最后一份问诊病例
        Router::get('/last/{family_id:\d+}', [PatientCaseController::class, 'getLastCase']);
    });

    // 药品
    Router::addGroup('/product', function () {
        // 购物车
        Router::addGroup('/shopping', function () {
            // 获取购物车药品数据
            Router::get('/cart', [UserPatientController::class, 'getShoppingCart']);

            // 修改购物车药品数据
            Router::put('/cart', [UserPatientController::class, 'putShoppingCart']);
        });
    });

    // 订单
    Router::addGroup('/order', function () {
        Router::addGroup('/inquiry', function () {
            // 获取患者问诊订单列表
            Router::get('', [PatientOrderController::class, 'getPatientInquiryOrderList']);

            // 获取患者问诊订单详情
            Router::get('/{order_inquiry_id:\d+}', [PatientOrderController::class, 'getPatientInquiryOrderInfo']);

            // 删除问诊订单-1:待支付 5:已完成
            Router::delete('/{order_inquiry_id:\d+}', [PatientOrderController::class, 'deletePatientInquiryOrder']);

            // 取消问诊订单-1:待支付 2:待分配 3:待接诊
            Router::put('/cancel/{order_inquiry_id:\d+}', [PatientOrderController::class, 'putCancelPatientInquiryOrder']);

            // 问诊订单取消支付-1未支付
            Router::put('/cancel-pay/{order_inquiry_id:\d+}', [PatientOrderController::class, 'putPatientInquiryOrderCancelPay']);
        });

        // 药品订单
        Router::addGroup('/product', function () {
            // 获取药品订单列表
            Router::get('', [PatientOrderController::class, 'getPatientProductOrderList']);

            // 获取药品订单详情
            Router::get('/{order_product_id:\d+}', [PatientOrderController::class, 'getPatientProductOrderInfo']);

            // 药品订单取消支付
            Router::put('/cancel-pay/{order_product_id:\d+}', [PatientOrderController::class, 'putPatientProductOrderCancelPay']);

            // 删除药品订单
            Router::delete('/{order_product_id:\d+}', [PatientOrderController::class, 'deletePatientProductOrder']);

            // 创建药品订单
            Router::post('', [PatientOrderController::class, 'addPatientProductOrder']);
        });

        // 处方订单
        Router::addGroup('/prescription', function () {
            // 获取处方订单列表
            Router::get('', [PatientOrderController::class, 'getPatientPrescriptionOrderList']);

            // 获取处方订单详情
            Router::get('/{order_prescription_id:\d+}', [PatientOrderController::class, 'getPatientPrescriptionOrderInfo']);

            // 获取处方订单支付页详情
            Router::get('/pay/{order_prescription_id:\d+}', [PatientOrderController::class, 'getPatientPrescriptionOrderPayInfo']);

            // 删除处方订单记录
            Router::delete('/{order_prescription_id:\d+}', [PatientOrderController::class, 'deletePatientPrescriptionOrder']);
        });

        // 获取患者订单支付数据
        Router::get('/pay', [PatientOrderController::class, 'getPatientOrderPayInfo']);

        // 模拟支付成功-金额为0时使用
        Router::post('/pay', [PatientOrderController::class, 'addPatientOrderPay']);
    });

    // 消息通知
    Router::addGroup('/message', function () {
        // 获取患者系统消息通知最后一条消息列表
        Router::get('/system/last', [MessageNoticeController::class, 'getPatientMessageServiceLast']);

        // 获取患者服务、福利、退款、物流消息通知列表-分页
        Router::get('/system', [MessageNoticeController::class, 'getPatientMessageSystem']);
    });
});

// 药师端api
Router::addGroup('/pharmacist', function () {
    // 首页
    Router::get('/index', [IndexController::class, 'pharmacistIndex']);

    // 设置上下线
    Router::put('/on-off', [UserPharmacistController::class, 'putOnOff']);

    // 处方
    Router::addGroup('/prescription', function () {
        // 获取药师审核处方列表
        Router::get('', [UserPharmacistController::class, 'getPrescriptionList']);

        // 获取处方详情
        Router::get('/info/{order_prescription_id:\d+}', [UserPharmacistController::class, 'getPrescriptionInfo']);

        // 审核处方
        Router::put('/verify/{order_prescription_id:\d+}', [UserPharmacistController::class, 'putPrescriptionVerify']);
    });

    // 药师基本资料
    Router::get('/info', [UserPharmacistController::class, 'getPharmacistInfo']);
});

/**
 * ------------公共api---------------------
 */
// 登陆api
Router::addGroup('/login', function () {
    // 微信登陆
    Router::post('/wechat_mobile_login', [LoginController::class, 'wechatMobileLogin']);

    // 手机号登陆
    Router::post('/mobile_login', [LoginController::class, 'mobileLogin']);

    // 微信授权接口
    Router::post('/authorize', [LoginController::class, 'wxAuthorize']);
});

// 验证码api
Router::addGroup('/code', function () {
    // 获取手机号验证码
    Router::post('/phone', [CodeController::class, 'getPhoneCode']);
});

// 省市区
Router::addGroup('/area', function () {
    // 获取省份信息
    Router::get('/province', [AreaController::class, 'getProvince']);

    // 获取城市信息
    Router::get('/city', [AreaController::class, 'getCity']);

    // 获取区县信息
    Router::get('/county', [AreaController::class, 'getCounty']);
});

// 签名
Router::addGroup('/sign', function () {
    // 获取oss签名数据
    Router::get('/oss', [SafeController::class, 'getOssSign']);

    // 获取im签名数据
    Router::get('/im', [SafeController::class, 'getImSign']);
});

// 基础数据
Router::addGroup('/basic', function () {
    // 获取医院数据
    Router::get('/hospital', [BasicDataController::class, 'getHospital']);

    // 获取自定义科室数据
    Router::get('/department', [BasicDataController::class, 'getCustomDepartment']);

    // 获取银行列表
    Router::get('/bank', [BasicDataController::class, 'getBank']);

    // 获取操作手册列表
    Router::get('/operation/manual', [BasicDataController::class, 'getOperationManual']);

    // 获取操作手册详情
    Router::get('/operation/manual/{manual_id:\d+}', [BasicDataController::class, 'getOperationManualInfo']);

    // 自定义疾病分类
    Router::addGroup('/disease', function () {
        // 搜索疾病分类
        Router::get('/search', [BasicDataController::class, 'getDiseaseSearch']);

        // 获取常见疾病分类
        Router::get('/hot', [BasicDataController::class, 'getDiseaseHot']);

        // 获取疾病专长列表
        // 搜索使用
        Router::get('/expertise', [BasicDataController::class, 'getDiseaseExpertiseList']);
    });

    // 平台疾病分类
    Router::addGroup('/icd', function () {
        // 搜索平台疾病分类
        Router::get('/search', [BasicDataController::class, 'getDiseaseIcdSearch']);
    });

    // 搜索商品
    Router::addGroup('/product', function () {
        // 搜索商品
        Router::get('/search', [BasicDataController::class, 'getProductSearch']);
    });

    // 获取民族数据
    Router::get('/nation', [BasicDataController::class, 'getNation']);

    // 获取职业数据
    Router::get('/job', [BasicDataController::class, 'getJob']);
});

// 获取医生评价
Router::get('/evaluation', [UserDoctorController::class, 'getDoctorEvaluationList']);

// 系统配置
Router::addGroup('/system', function () {
    // 问诊
    Router::addGroup('/inquiry', function () {
        // 获取系统问诊时间 快速问诊-问诊购药
        Router::get('/time', [SystemController::class, 'getSystemInquiryTime']);
    });
});

// 回调
Router::addGroup('/callback', function () {
    // 支付回调
    Router::addGroup('/wxpay', function () {
        // 问诊
        Router::addGroup('/inquiry', function () {
            // 支付成功回调
            Router::post('/success', [CallBackController::class, 'wxPayInquirySuccessCallBack']);

            // 退款回调
            Router::post('/refund', [CallBackController::class, 'wxPayInquiryRefundCallBack']);
        });
        // 药品
        Router::addGroup('/product', function () {
            // 支付成功回调
            Router::post('/success', [CallBackController::class, 'wxPayProductSuccessCallBack']);

            // 退款回调
            Router::post('/refund', [CallBackController::class, 'wxPayProductRefundCallBack']);
        });
    });

    // im回调
    Router::post('/im', [CallBackController::class, 'imCallBack']);

    // 处方平台物流回调
    Router::post('/platform/logistics', [CallBackController::class, 'platformLogisticsCallBack']);
});

// 用户
Router::addGroup('/user', function () {
    // 修改用户头像
    Router::put('/avatar', [UserController::class, 'putUserAvatar']);

    // 修改用户名
    Router::put('/name', [UserController::class, 'putUserName']);

    // 退出登陆
    Router::put('/loginout', [UserController::class, 'putLoginout']);
});

// 获取患者问诊病例
Router::get('/case', [InquiryController::class, 'getPatientInquiryCase']);


Router::get('/test', [TestController::class, 'test']);

// 地址管理
Router::addGroup('/address', function () {
    // 获取用户收获地址列表
    Router::get('', [UserController::class, 'getUserAddress']);

    // 获取用户收获地址详情
    Router::get('/{address_id:\d+}', [UserController::class, 'getUserAddressInfo']);

    // 添加用户收获地址
    Router::post('', [UserController::class, 'addUserAddress']);

    // 修改用户收获地址
    Router::put('/{address_id:\d+}', [UserController::class, 'putUserAddress']);

    // 删除用户收获地址
    Router::delete('/{address_id:\d+}', [UserController::class, 'deleteUserAddress']);
});

// 消息
Router::addGroup('/message', function () {
    // 消息通知
    Router::addGroup('/notice', function () {
        // 消息已读
        Router::put('/read/{notice_id:\d+}', [MessageNoticeController::class, 'putMessageReadId']);

        // 一键消息已读
        Router::put('/read', [MessageNoticeController::class, 'putMessageRead']);
    });
});

// 问诊订单
Router::addGroup('/inquiry', function () {
    // 获取问诊订单消息内页基础数据
    Router::get('/message/basic/{order_inquiry_id:\d+}', [InquiryController::class, 'getInquiryMessageBasic']);
});

// 未开发接口






// 获取系统消息列表-系统消息
Router::post('/20', [CallBackController::class, 'imCallBack']);

// 获取服务、退款、福利、物流消息列表-系统消息
Router::post('/21', [CallBackController::class, 'imCallBack']);

// 消息已读-系统消息
Router::post('/22', [CallBackController::class, 'imCallBack']);

// 全部消息已读-系统消息-服务消息
Router::post('/23', [CallBackController::class, 'imCallBack']);


// 获取问诊消息列表-消息
Router::post('/24', [CallBackController::class, 'imCallBack']);


// 获取患者-医生关注状态
Router::post('/26', [CallBackController::class, 'imCallBack']);

// 获取患者简短问诊病例-聊天界面
Router::post('/27', [CallBackController::class, 'imCallBack']);
