package com.dahe.gldriver.net

import com.dahe.gldriver.BuildConfig
import com.dahe.gldriver.BuildConfig.BASE_URL
import com.dahe.gldriver.bean.AuthTeamBean
import com.dahe.gldriver.bean.CaptainBean
import com.dahe.gldriver.bean.CarBean
import com.dahe.gldriver.bean.DiCarColor
import com.dahe.gldriver.bean.DriverBean
import com.dahe.gldriver.bean.InviteRecord
import com.dahe.gldriver.bean.OcrPersonBean
import com.dahe.gldriver.bean.OrderChild
import com.dahe.gldriver.bean.OrderDetailBean
import com.dahe.gldriver.bean.OssBean
import com.dahe.gldriver.bean.RateBean
import com.dahe.gldriver.bean.UpBankInfoBean
import com.dahe.gldriver.bean.UpCaptain
import com.dahe.gldriver.bean.UpDriverInfoBean
import com.dahe.gldriver.bean.UpDrivingInfoBean
import com.dahe.gldriver.bean.UpPart
import com.dahe.gldriver.bean.UpPersonInfoBean
import com.dahe.gldriver.bean.UpPicBean
import com.dahe.gldriver.bean.UpQualiInfoBean
import com.dahe.gldriver.bean.UpRate
import com.dahe.gldriver.bean.UpRoadInfoBean
import com.dahe.glex.bean.*
import com.dahe.mylibrary.net.CommonResponseBean
import io.reactivex.rxjava3.core.Observable
import okhttp3.MultipartBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query
import java.util.Objects


/**
 * Created by Administrator on 2024/01/8 0008.
 */
interface Api {
    /*-------------------登录----------------------------*/
    @POST(BASE_URL + "common/register")
    fun log(@Body logBean: LogBean?): Observable<CommonResponseBean<UserBean>>

    @GET(BASE_URL + "auth/driver/login")
    fun login(
        @Query("contactPhone") contactPhone: String,
        @Query("code") code: String
    ): Observable<CommonResponseBean<UserBean>>


    /**
     * 根据字典类型查询字典-不分页
     * @param dictType String
     * @return Observable<CommonResponseBean<MutableList<>>>
     */
    @GET(BASE_URL + "driver/common/dict/getSysDictDataList/all")
    fun getSysDictDataList(
        @Query("dictType") dictType: String
    ): Observable<CommonResponseBean<MutableList<DiCarColor>>>


    /**
     * 获取验证码
     * */
    @GET(BASE_URL + "auth/driver/code")
    fun getCode(@Query("contactPhone") contactPhone: String): Observable<CommonResponseBean<UserBean>>


    /**
     * 司机一键登录
     * @param token String
     * @return Observable<CommonResponseBean<UserBean>>
     */
    @GET(BASE_URL + "auth/driver/oneClickLogin")
    fun oneClickLogin(@Query("token") token: String): Observable<CommonResponseBean<UserBean>>


    /**
     * 上传到oss
     * */
    @Multipart
    @POST(BASE_URL + "file/uploadToOss")
    fun uploadToOss(
        @Part file: MultipartBody.Part
    ): Observable<CommonResponseBean<OssBean>>

    /**
     * 个人身份证识别
     * */
    @GET(BASE_URL + "ocr/aliyunOcr/recognizeIdcard")
    fun recognizeIdcard(
        @Query("imgUrl") imgUrl: String
    ): Observable<CommonResponseBean<OcrPersonBean>>

    /**
     * 驾驶证识别
     * */
    @GET(BASE_URL + "ocr/aliyunOcr/recognizeDrivingLicense")
    fun recognizeDrivingLicense(
        @Query("imgUrl") imgUrl: String
    ): Observable<CommonResponseBean<OcrPersonBean>>

    /**
     * 银行卡识别
     * */
    @GET(BASE_URL + "ocr/aliyunOcr/recognizeBankCard")
    fun recognizeBankCard(
        @Query("imgUrl") imgUrl: String
    ): Observable<CommonResponseBean<OcrPersonBean>>

    /**
     * 行驶证识别
     * */
    @GET(BASE_URL + "ocr/aliyunOcr/recognizeVehicleLicense")
    fun recognizeVehicleLicense(
        @Query("imgUrl") imgUrl: String
    ): Observable<CommonResponseBean<OcrPersonBean>>

    /**
     * 营业执照识别
     * */
    @GET(BASE_URL + "ocr/aliyunOcr/recognizeBusinessLicense")
    fun recognizeBusinessLicense(
        @Query("imgUrl") imgUrl: String
    ): Observable<CommonResponseBean<OcrPersonBean>>

    /**
     * 获取用户信息
     * */
    @GET(BASE_URL + "driver/driver/getUserInfo")
    fun getUserInfo(): Observable<CommonResponseBean<UserBean>>

    /**
     * 司机上传身份证
     * */
    @POST(BASE_URL + "driver/driver/setUpDriverIdCard")
    fun setUpDriverIdCard(@Body carBean: UpPersonInfoBean): Observable<CommonResponseBean<Any>>


    /**
     * 司机上传驾驶证
     * */
    @POST(BASE_URL + "driver/driver/setUpDriverLicense")
    fun setUpDriverLicense(@Body driverBean: UpDriverInfoBean): Observable<CommonResponseBean<Any>>

    /**
     * 司机上传从业资格证
     * */
    @POST(BASE_URL + "driver/driver/setUpDriverQualificationCertificate")
    fun setUpDriverQualificationCertificate(@Body qualiBean: UpQualiInfoBean): Observable<CommonResponseBean<Any>>

    /**
     * 上传车辆的道路运输证
     * */
    @POST(BASE_URL + "driver/car/setUpRoadLicense")
    fun setUpRoadLicense(@Body roadBean: UpRoadInfoBean): Observable<CommonResponseBean<Any>>

    /**
     * 司机上传银行卡
     * */
    @POST(BASE_URL + "driver/driver/setUpDriverBankCard")
    fun setUpDriverBankCard(@Body bankBean: UpBankInfoBean): Observable<CommonResponseBean<Any>>


    /**
     * 司机认证成为车队长
     * */
    @POST(BASE_URL + "driver/driver/authenticationCaptain")
    fun authenticationCaptain(@Body bankBean: AuthTeamBean): Observable<CommonResponseBean<Any>>


    /**
     * 提交党员认证资料
     * @param upPart UpPart
     * @return Observable<CommonResponseBean<String>>
     */
    @POST(BASE_URL + "driver/driver/submitToCpcAuthentication")
    fun submitToCpcAuthentication(@Body upPart: UpPart): Observable<CommonResponseBean<Any>>

    /**
     * 查询党员认证资料
     * @param upPart UpPart
     * @return Observable<CommonResponseBean<String>>
     */
    @GET(BASE_URL + "driver/driver/getCpcAuthenticationInfo")
    fun getCpcAuthenticationInfo(): Observable<CommonResponseBean<UpPart>>


    /**
     * 货源列表
     * */
    @GET(BASE_URL + "driver/order/list")
    fun orderList(): Observable<CommonResponseBean<MutableList<OrderBean>>>

    /**
     * 运单列表
     * */
    @GET(BASE_URL + "driver/driverWaybill/selectMyWaybillList")
    fun selectMyWaybillList(
        @Query("pageNum") pageNum: Int = 1,
        @Query("pageSize") pageSize: Int = 20,
        @Query("waybillStatus") waybillStatus: String = "",
        @Query("searchValue") searchValue: String = ""
    ): Observable<CommonResponseBean<MutableList<OrderBean>>>


    /**
     * 货源详情
     * */
    @GET(BASE_URL + "driver/order/detail")
    fun orderDetail(@Query("orderId") orderId: String): Observable<CommonResponseBean<OrderDetailBean>>


    /**
     * 司机接单
     * */
    @GET(BASE_URL + "driver/driverWaybill/receivingOrders")
    fun receivingOrders(
        @Query("orderId") orderId: String,
        @Query("carId") carId: String
    ): Observable<CommonResponseBean<Any>>

    /**
     * 司机装卸货
     * */
    @POST(BASE_URL + "driver/driverWaybill/driverLoadOrUnload")
    fun driverLoadOrUnload(
        @Body upPicBean: UpPicBean
    ): Observable<CommonResponseBean<Any>>


    /**
     * 评价运单
     * @param upRate UpRate
     * @return Observable<CommonResponseBean<Any>>
     */
    @POST(BASE_URL + "driver/opinions/submitComments")
    fun submitComments(@Body upRate: UpRate): Observable<CommonResponseBean<Any>>


    /**
     * 设置司机账号类型
     * @param role String  0普通司机，1车队长
     * @return Observable<CommonResponseBean<String>>
     */
    @GET(BASE_URL + "driver/driver/setUpDriverRole")
    fun setUpDriverRole(@Query("role") role: String): Observable<CommonResponseBean<Any>>


    /**
     *
     * 车辆列表
     * */
    @GET(BASE_URL + "driver/car/carList")
    fun carList(): Observable<CommonResponseBean<MutableList<CarBean>>>

    /**
     *
     * 根据车牌号查询车辆信息
     * */
    @GET(BASE_URL + "driver/car/getCarByCarVehicleNum")
    fun getCarByCarVehicleNum(@Query("vehicleNum") vehicleNum: String): Observable<CommonResponseBean<UpDrivingInfoBean>>

    /**
     *
     * 解绑车辆
     * */
    @POST(BASE_URL + "driver/car/unBindCar")
    fun unBindCar(@Body carBean: CarBean): Observable<CommonResponseBean<Any>>

    /**
     *
     * 绑定车辆
     * */
    @POST(BASE_URL + "driver/car/bindCar")
    fun bindCar(@Body carBean: CarBean): Observable<CommonResponseBean<Any>>

    /**
     *
     * 新增车辆
     * */
    @POST(BASE_URL + "driver/car/addCar")
    fun addCar(@Body upDrivingInfoBean: UpDrivingInfoBean): Observable<CommonResponseBean<UpDrivingInfoBean>>

    /**
     *
     * 新增挂车信息
     * */
    @POST(BASE_URL + "driver/car/addTrailer")
    fun addTrailer(@Body upDrivingInfoBean: UpDrivingInfoBean): Observable<CommonResponseBean<Int>>

    /**
     *
     *邀请司机加入车队
     * */
    @POST(BASE_URL + "driver/captain/askToDriver")
    fun askToDriver(@Body upDrivingInfoBean: DriverBean): Observable<CommonResponseBean<Int>>


    /**
     *
     *根据手机号查询司机
     * */
    @GET(BASE_URL + "driver/captain/selectDriverList")
    fun selectDriverList(@Query("phone") phone: String): Observable<CommonResponseBean<MutableList<DriverBean>>>


    /**
     * 获取司机详细信息
     * @return Observable<CommonResponseBean<UserDetail>>
     */
    @GET(BASE_URL + "driver/driver/getUserDetail")
    fun getUserDetail(): Observable<CommonResponseBean<UserDetail>>


    /**
     *
     *查询司机所在车队信息
     * */
    @GET(BASE_URL + "driver/captain/selectCaptainListInDriver")
    fun selectCaptainListInDriver(): Observable<CommonResponseBean<MutableList<CaptainBean>>>

    /**
     *
     *查询车队邀请历史
     * */
    @GET(BASE_URL + "driver/captain/selectCaptainAskByDriverHistoryList")
    fun selectCaptainAskByDriverHistoryList(): Observable<CommonResponseBean<MutableList<InviteRecord>>>

    /**
     * 司机同意/拒绝加入车队
     * @param upCaptain UpCaptain
     * @return Observable<CommonResponseBean<String>>
     */
    @POST(BASE_URL + "driver/driver/responseToCaptain")
    fun responseToCaptain(@Body upCaptain: UpCaptain): Observable<CommonResponseBean<Any>>

    /**
     * 司机退出车队
     * @param upCaptain UpCaptain
     * @return Observable<CommonResponseBean<String>>
     */
    @POST(BASE_URL + "driver/captain/unbindDriver")
    fun unbindDriver(@Body upCaptain: UpCaptain): Observable<CommonResponseBean<Any>>


    /**
     * 查询车队所属的司机列表（包含车辆）
     * @return Observable<CommonResponseBean<MutableList<DriverBean>>>
     */
    @GET(BASE_URL + "driver/captain/selectDriversInCaptain")
    fun selectDriversInCaptain(@Query("captainId") captainId: String): Observable<CommonResponseBean<MutableList<DriverBean>>>

    /**
     * 根据ID查询车队车辆列表-根据司机分页
     * @return Observable<CommonResponseBean<MutableList<DriverBean>>>
     */
    @GET(BASE_URL + "driver/captain/selectDriverIdsForCarPage")
    fun selectDriverIdsForCarPage(@Query("captainId") captainId: String): Observable<CommonResponseBean<MutableList<CarBean>>>

    /**
     * 根据ID查询车队信息
     * @param captainId String
     * @return Observable<CommonResponseBean<MutableList<DriverBean>>>
     */
    @GET(BASE_URL + "driver/captain/getCaptainById")
    fun getCaptainById(@Query("captainId") captainId: String): Observable<CommonResponseBean<CaptainBean>>


    /**
     * 查询运单评价信息列表
     * opinionsType 评价类型(0=司机评价，1=货主评价)
     * @return Observable<CommonResponseBean<CaptainBean>>
     */
    @GET(BASE_URL + "driver/opinions/list")
    fun waybillRate(@Query("opinionsType") opinionsType : String): Observable<CommonResponseBean<MutableList<RateBean>>>

    /**
     * 查询司机总评价信息
     * @return Observable<CommonResponseBean<CaptainBean>>
     */
    @GET(BASE_URL + "driver/opinions/getDriverOpinionsStatInfo")
    fun driverRate(): Observable<CommonResponseBean<RateBean>>


    /**
     * 查看单据
     * @param orderId String
     * @return Observable<CommonResponseBean<RateBean>>
     */
    @GET(BASE_URL + "driver/order/orderPhoto")
    fun orderPhoto(@Query("orderId") orderId :String): Observable<CommonResponseBean<MutableList<OrderChild>>>


    companion object {
        //    String BASE_URL = "https://tmstest.dahehuoyun.com/";
        const val BASE_URL = BuildConfig.BASE_URL

        //获取版本
        const val VERSION = BASE_URL + "app/version"
    }
}