package com.lukouguoji.module_base.bean

import androidx.databinding.BaseObservable
import androidx.databinding.ObservableBoolean
import com.alibaba.fastjson.annotation.JSONField
import com.lukouguoji.module_base.interfaces.ICheck

class GjjTallyBean(
    // 代理人
    var agent: String? = "",
    // 业务类型
    var businessType: String? = "",
    // 目的港
    var dest: String? = "",
    // 航班日期
    var fdate: String? = "",
    // 航班流水号
    var fid: String? = "",
    // 航班号
    var fno: String? = "",
    // 货物品名
    var goods: String? = "",
    // 舱单流水号
    var mfId: String? = "",
    // 主提运单号
    var no: String? = "",
    // 始发港
    var origin: String? = "",
    // 件数
    var pc: String? = "",
    // 主键
    var pcID: String? = "",
    // 主提运单前缀(承运人运单三字码)
    var prefix: String? = "",
    // 舱单发放标识(0:未理货;1:已理货)
    var ref: String? = "",
    // 特种货物代码
    var spCode: String? = "",
    // 运单号
    var wbNo: String? = "",
    // 重量
    var weight: String? = "",
) : BaseObservable(), ICheck {

    // 是否选中
    @JSONField(serialize = false)
    val checked = ObservableBoolean(false)

    @JSONField(serialize = false)
    override fun getCheckObservable() = checked

    // 获取运单号
    fun getWaybillNo() = "$prefix$no"

    // 是否可以理货
    fun canTally() = ref == "0"

    /**
     * 获取理货状态
     */
    fun getTallyStatus(): String {
        return when (ref) {
            "0" -> "未理货"
            "1" -> "已理货"
            else -> ""
        }
    }

    /**
     * 获取日期+航班号
     */
    fun getDateFlightNo(): String {
        return "$fdate/$fno"
    }
}