package com.pan_american.android

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import com.pan_american.android.data.model.common.entity.Selector
import com.pan_american.android.data.model.common.entity.SiftListItem
import com.pan_american.android.data.model.customer_resource.market_sales_revenue.entity.YearQuarterlyData
import com.pan_american.android.data.model.group_hotel.hotel_predetermine.entity.UpdateHotelPredetermine
import com.pan_american.android.data.model.group_management.entry_and_exit_fee_detail.network.EntryAndExitDetailResponse
import com.pan_american.android.data.model.group_management.group_info.entity.GroupCustomerInfo
import com.pan_american.android.data.model.group_management.group_info.network.GroupOperationRequest
import com.pan_american.android.data.model.login.entity.Authority
import com.pan_american.android.data.model.login.entity.UserInfo
import com.pan_american.android.data.model.personnel_module.materials_operate.entity.MaterialTypeData

class OASystem : Application() {

    companion object {
        @SuppressLint("StaticFieldLeak")
        // 上下文
        lateinit var context: Context

        //user Token
        var token = ""

        // 用户信息
        lateinit var userInfo: UserInfo

        // 权限列表
        lateinit var authData: ArrayList<Authority>

        //未读消息数
        var unReadCount = 0

        //公告未读条数
        var announcementUnReadCount = 0

        //日付申请，名称筛选列表
        lateinit var dailyPaymentUserName: ArrayList<Selector>

        //日付申请，类型筛选列表
        lateinit var paymentType: ArrayList<Selector>

        //日付申请，子类型筛选列表
        lateinit var paymentSubType: ArrayList<Selector>

        //市场客户资源，客户级别
        lateinit var customerLevel: ArrayList<Selector>

        //市场客户资源，客户类别
        lateinit var customerClass: ArrayList<Selector>

        //市场客户资源，负责人列表
        lateinit var customerManager: ArrayList<SiftListItem>

        //市场客户资源，业务归属
        lateinit var serviceClass: ArrayList<SiftListItem>

        //市场客户资源，省域
        lateinit var province: ArrayList<SiftListItem>

        //接团信息，团组类型
        var groupInfoGroupType = ArrayList<Selector>()

        //接团信息，客户级别
        var groupInfoCustomerLevel = ArrayList<Selector>()

        //接团信息，成单人
        var groupInfoTradeDirector = ArrayList<Selector>()

        //接团信息，接团客户名单
        var groupInfoGroupCustomerList = ArrayList<GroupCustomerInfo>()

        //接团信息，OP提成等级
        var groupInfoOpPercentageLevel = ArrayList<Selector>()

        //接团信息，舱位类型
        var groupInfoBerthType = ArrayList<Selector>()

        //接团信息，团组操作(增改)request
        lateinit var groupOperationRequest: GroupOperationRequest

        //地接费用录入，单位list
        var groundConveyUnitList = ArrayList<Selector>()

        //酒店费用录入，客户类型
        var hotelPredetermineCustomerType = ArrayList<Selector>()

        //酒店费用录入，支付方式
        var hotelPredeterminePaymentWay = ArrayList<Selector>()

        //酒店费用录入，团组汇率
        var hotelPredeterminePaymentCurrency = ArrayList<Selector>()

        //酒店费用录入，银行卡
        var hotelPredetermineBankCard = ArrayList<Selector>()

        //酒店费用录入，预订网站
        var hotelPredetermineHotelWebSite = ArrayList<Selector>()

        //酒店费用录入，入住类型
        var hotelPredetermineCheckInType = ArrayList<Selector>()

        //酒店费用录入，客人名单
        var hotelPredetermineCustomerList = ArrayList<Selector>()

        //酒店费用录入，国家 / 城市
        var hotelPredetermineCountries = ArrayList<Selector>()

        //酒店费用录入，费用操作(增改)request
        lateinit var hotelPredetermineRequest: UpdateHotelPredetermine

        var marketSalesRevenueCompanyList = ArrayList<Selector>()

        var marketSalesRevenueUserList = ArrayList<Selector>()

        var marketSalesRevenueDateList = ArrayList<YearQuarterlyData>()

        //物资进销存，基础数据源
        var materialBaseData = ArrayList<MaterialTypeData>()

        //导游地接资料，导游地接类型
        val guideResourceGuideType = listOf(Selector().apply {
            id = 0
            name = "公司"
        }, Selector().apply {
            id = 1
            name = "个人"
        })

        // 评分选择
        val score = listOf("5", "4", "3", "2", "1", "0")

        // 星级选择
        val level = listOf("★★★★★", "★★★★", "★★★", "★★", "★", "无")

        // 权重选择
        val weight = listOf(Selector().apply {
            id = 393
            name = "A"
        }, Selector().apply {
            id = 392
            name = "B"
        }, Selector().apply {
            id = 391
            name = "C"
        })

        //商邀费用 费用标识
        val paymentMark = listOf(Selector().apply {
            id = 0
            name = "公转"
        }, Selector().apply {
            id = 1
            name = "私转"
        })

        //团组对应币种单位
        var currency = ArrayList<Selector>()

        //接团信息，团组状态
        val groupStatus = listOf(Selector().apply {
            id = -1
            name = "全部"
        }, Selector().apply {
            id = 0
            name = "未完成"
        }, Selector().apply {
            id = 1
            name = "已完成"
        })

        //收款账单，增加方式
        val addMode = listOf(Selector().apply {
            id = 0
            name = "账单模块"
        }, Selector().apply {
            id = 1
            name = "成本预算模块"
        }, Selector().apply {
            id = 2
            name = "实际报价"
        }, Selector().apply {
            id = 3
            name = "超支费用"
        })

        //查看权限
        const val VIEW = 1

        // 删除权限
        const val DELETE = 2

        // 编辑权限
        const val EDIT = 3

        //下载权限
        const val DOWNLOAD = 4

        // 添加权限
        const val ADD = 11

        //审核权限
        const val PROCESS = 12

        // 通讯录模块
        const val ADDRESS_BOOK = 16

        // 日程安排模块
        const val ITINERARY = 17

        // 酒店信息
        const val HOTEL_RESOURCE = 23

        // 导游地接信息
        const val GUIDE_RESOURCE = 24

        // 邀请资料
        const val INVITE_DATA = 25

        // 接团信息
//        const val GROUP_INFORMATION = 26

        //团组操作
        const val GROUP_INFORMATION = 27

        //酒店预定
        const val HOTEL_PREDETERMINE = 28

        //邀请公务费用
        const val INVITE_OFFICIAL_PAYMENT = 29

        //地接费用录入
        const val GROUND_CONVEY_PAYMENT_INSERT = 30

        //签证费用录入
        const val VISA_PAYMENT_INSERT = 31

        //保险费用录入
        const val INSURANCE_PAYMENT_INSERT = 32

        // 日付申请模块
        const val DAILY_PAYMENT = 42

        // 团组费用审批模块
        const val EXPENSE_APPROVAL = 47

        //应收报表
        const val ACCOUNT_RECEIVABLE_REPORT = 53

        //收款退还
        const val PAYMENT_REFUND = 69

        // 市场客户资源
        const val MARKET_CUSTOMER = 89

        //团组经理主管，接团客户名单
        const val GROUP_CLIENT_LIST = 104

        //团组经理主管，倒推表
        const val REVERSE_TABLE = 106

        // 车辆公司信息
        const val CAR_RESOURCE = 111

        //团组经理主管，出入境费用明细
        const val ENTRY_AND_EXIT_FEE_DETAIL = 118

        // 机场三字码
        const val THREE_CODE_RESOURCE = 120

        //OP行程单
        const val OP_TRAVEL_ITINERARY = 122

        //机票费用录入
        const val AIRPLANE_PAYMENT_INSERT = 161

        //公务出访
        const val OFFICIAL_VISITS = 166

        //收款账单
        const val COLLECTION_BILL = 171

        //市场部营业额
        const val MARKET_SALES_REVENUE = 180

        //查看关联邀请方
        const val RELATED_INVITEE = 184

        //票据管理
        const val BILL_MANAGEMENT = 185

        //提成确认
        const val COMMISSION_CONFIRM = 188

        //物资进销存(物资领用)
        const val MATERIAL_APPLICATION = 191

        //CTableId
        //酒店预定
        const val C_TABLE_HOTEL_PREDETERMINE = 76

        //地接费用
        const val C_TABLE_GROUND_CONVEY = 79

        //签证费用
        const val C_TABLE_VISA = 80

        //商邀费用
        const val C_TABLE_INVITE_OFFICIAL = 81

        //保险费用
        const val C_TABLE_INSURANCE = 82

        //机票费用
        const val C_TABLE_AIRPLANE_TICKET = 85

        //收款退还
        const val C_TABLE_PAYMENT_REFUND = 98

        //文档下载
        const val C_TABLE_DOCUMENT_DOWNLOAD = 1081

        //支付方式-保险 ID
        const val PAYMENT_WAY_INSURANCE_ID = 1057

        // 权限判别
        fun authorization(pageId: Int, operation: Int): Boolean {
            authData.forEach {
                if (it.pageId == pageId) {
                    if (it.opList.contains(operation)) {
                        return true
                    }
                }
            }
            return false
        }

        //判断userInfo是否被初始化
        fun isUserInfoInit(): Boolean {
            return this::userInfo.isInitialized
        }

        //拍照权限code
        const val CAMERA_REQUEST_CODE = 1001

        //通知权限code
        const val NOTIFICATION_REQUEST_CODE = 1002

        //相册权限code
        const val GALLERY_REQUEST_CODE = 1003

        //刷新主页消息和公告
        const val REFRESH_NAVIGATION = 2001

        //通知条数
        var notificationCount = 0

        //activity / fragment是否需要刷新
        var needRefresh = false

        //三公费用 返回体
        var entryAndExitDetailResponse = EntryAndExitDetailResponse()
    }

    override fun onCreate() {
        super.onCreate()
        context = applicationContext
    }

}