//
//  ResponseModel.swift
//  OrderScheduling
//
//  Created by 中道 on 2023/8/7.
//

import Foundation

class ResponseModel<T:Decodable> : Decodable {
    typealias data = T
    var code : Int
    var msg : String?
    var data : T?
    var time : Int
    var success : Bool
}

class LoginDataModel : Decodable {
    var accessToken : LoginDataAccessTokenModel
    var refreshToken : LoginDataRefreshTokenModel
    var additionalParameters : LoginDataAdditionalModel
    public class LoginDataAccessTokenModel: Decodable {
        var tokenValue : String
        var issuedAt : Double?
        var expiresAt : Double?
    }
    public class LoginDataRefreshTokenModel: Decodable {
        var tokenValue : String
        var issuedAt : Double?
        var expiresAt : Double?
    }
    public class LoginDataAdditionalModel: Decodable {
        var user_info : LoginDataAdditionalUserModel
    }
    public class LoginDataAdditionalUserModel: Decodable {
        var userId : Int
        var phone : String
        var name : String
        var supplierName : String
        var supplierId : Int
        var username : String
        var userType : String
    }
}

class OrderListDataModel: Decodable {
    var brand : String?
    var model : String?
    var vehiclePointAddress : String
    var vehiclePointLongitude : Double
    var vehiclePointLatitude : Double
    var vehiclePointRemark : String?
    var destinationAddress : String?
    var destinationLongitude : Double?
    var destinationLatitude : Double?
    var destinationRemark : String?
    var appointTime : String?
    var contractName : String
    var taskServiceName : String
    var taskOrderStatusString : String?
    var orderCode : String
    var createTime : String
    var driverName : String?
    var drivePhone : String?
    var environmentPic : String?
    var userOrderId : Int
    var taskOrderId : Int
    var userPhone : String
    var auditFailReason : String?
    var isSupplierSettle : SupplierSettleModel?
    var supplierSettleRatio : SupplierSettleRatioModel?
    class SupplierSettleModel : Decodable {
        var code : IsSupplierSettleEnum
        var label : String
    }
    class SupplierSettleRatioModel : Decodable {
        var code : SupplierSettleRatioEnum
        var label : String
    }
    enum IsSupplierSettleEnum : Int,Decodable {
        case NO = 0
        case YES = 1
    }
    enum SupplierSettleRatioEnum : Int, Decodable {
        case NO_SETTLE = 0
        case ALL_SETTLE = 1
        case DROP_SETTLE = 2
        case SERVICE_FAIL_SETTLE = 3
        case TRAIL_CAR_SETTLE = 4
    }
}

enum VehicleStatusCodeEnum : Int, Decodable {
    case offLine = 1
    case onLine = 2
    case lostConnection = 3
    case leisure = 4
    case busy = 6
    case BuyBusy = 5
}

class VehicleStatusModel : Decodable {
    var code : VehicleStatusCodeEnum
    var label : String
}

class OnlineStatusModel : Decodable {
    var code : OnlineStatusCodeEnum
    var label : String
    enum OnlineStatusCodeEnum : Int, Decodable {
        case offLine = 1
        case onLine = 2
        case lostConnection = 3
        case leisure = 4
        case busy = 6
        case BuyBusy = 5
    }
}

class DispatchVehicleListDataModel : Decodable {
    var driverId : Int
    var vehicleId : Int
    var vehicleName : String?
    var driverName : String?
    var driverPhone : String?
    var lon : String?
    var lat : String?
    var vehicleStatus : VehicleStatusModel
    var onlineStatus : OnlineStatusModel
    var distance : Double?
}

class ToDoMessageCountDataModel : Decodable {
    var messageCount : Int
    var toDoCount : Int
}

public class VehicleMonitorListDataModel : Decodable {
    var vehicleMonitorCount : VehicleMonitorListCountModel
    var rosterList : [ItemModel]
    var onLineList : [ItemModel]
    var lostConnectionList : [ItemModel]
    var leisureList : [ItemModel]
    var busyList : [ItemModel]
    var alarmList : [ItemModel]
    
    class VehicleMonitorListCountModel: Decodable {
        var rosterCount : Int
        var onLineCount : Int
        var lostConnectionCount : Int
        var leisureCount : Int
        var busyCount : Int
        var alarmCount : Int
    }
    public class ItemModel : Decodable {
        var vehicleId : Int?
        var vehicleName : String?
        var driverId : Int
        var driverName : String
        var driverPhone : String
        var vehicleType : String?
        var terminalType : TerminalTypeEnum?
        var vehicleStatus : VehicleStatusModel?
        var onlineStatus : OnlineStatusModel?
        var alarmType : AlarmType?
        var rosterStartTime : String?
        var rosterEndTime : String?
        var lat : String?
        var lon : String?
        var orderCode : String?
        var serviceName : String?
        var taskStatusString : String?
        var workingCount : Int?
        var isSelected : Bool? = false
        
        public enum TerminalTypeEnum : String,Decodable {
            case APP = "APP"
            case GPS = "GPS"
        }
        
        public class AlarmType : Decodable {
            var code : AlarmTypeEnum
            var label : String
        }
        public enum AlarmTypeEnum : Int,Decodable {
            case dropped = 1
            case busy = 2
            case empty_shift = 3
        }
        
    }
}

public class OrderPhotoListDataModel : Decodable {
    var taskStatus : Int
    var taskStatusString : String
    var photoList : [PhotoList]
    class PhotoList : Decodable {
        var tag : String
        var imageTitle : String
        var photoUrl : String?
        var uploadImage : Data?
        var taskStatus : Int?
    }
}

public class GeneralInfoDataModel : Decodable {
    var userId : Int
    var icon : String
    var phone : String
    var supplierId : Int
    var supplierName : String
    var vehicleCount : Int
    var driverCount : Int
}
