package com.mogo.cloud.tanlu.bean;

import android.text.TextUtils;

import java.io.Serializable;
import java.util.Calendar;

/**
 * @author lixiaopeng
 * @description
 * @since 2021/1/20
 */
public class MarkerUserInfoCloud implements Serializable {
    private String sn;
    private long userId;
    private String userName;//用户昵称
    private String userHead;//用户头像
    private String gender;//gender": "男｜女｜无（也可以0｜1｜2根据实际库存返回即可）
    private Integer age;// 年龄段，可以为空，与车聊聊一致

    // TODO V2X临时字段，接口出好后进行修改
    private String lastActiveweekAvgscore;//末次活跃周驾驶行为平均得分
    private String safeLabel;//车辆安全标签
    private int safeLabelType;//1老司机 2安全驾驶 3危险驾驶

    public void setAge(Integer age) {
        this.age = age;
    }

    public int getAgeNumber() {
        if (age != null) {
            return age;
        }
        return -1;
    }

    public String getAge() {
        try {
            if (getAgeNumber() >= 0) {

                Calendar cal = Calendar.getInstance();
                int year = cal.get(Calendar.YEAR);

                //2020-30=1990
                double ageDiffer = year - getAgeNumber();
                String ageStr = "" + ageDiffer;
                char[] ageChars = ageStr.toCharArray();

                //1990
                char ageChar = ageChars[2];

                String ageString = "未设置";

                switch (ageChar) {
                    case '0':
                        ageString = "00后";
                        break;
                    case '1':
                        ageString = "10后";
                        break;
                    case '2':
                        ageString = "20后";
                        break;
                    case '3':
                        ageString = "30后";
                        break;
                    case '4':
                        ageString = "40后";
                        break;
                    case '5':
                        ageString = "50后";
                        break;
                    case '6':
                        ageString = "60后";
                        break;
                    case '7':
                        ageString = "70后";
                        break;
                    case '8':
                        ageString = "80后";
                        break;
                    case '9':
                        ageString = "90后";
                        break;
                }

                return ageString;
            } else {
                return "";
            }
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public int getGenderValue() {
        if (!TextUtils.isEmpty(gender)) {
            if ("男".equals(gender)) {
                return 0;
            }
            return 1;
        } else {
            return 0;
        }
    }

    public String getGender() {
        if (TextUtils.isEmpty(gender)) {
            return "未设置";
        }
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public void setGender(int gender) {
        if (gender == 0) {
            this.gender = "男";
        } else {
            this.gender = "女";
        }
    }

    public String getSn() {
        if (TextUtils.isEmpty(sn)) {
            return "";
        }
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public String getUserHead() {
        if (TextUtils.isEmpty(userHead)) {
            return "";
        }
        return userHead;
    }

    public void setUserHead(String userHead) {
        this.userHead = userHead;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        if (TextUtils.isEmpty(userName)) {
            return "用户未设置昵称";
        }
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public String getLastActiveweekAvgscore() {
        return lastActiveweekAvgscore;
    }

    public void setLastActiveweekAvgscore(String lastActiveweekAvgscore) {
        this.lastActiveweekAvgscore = lastActiveweekAvgscore;
    }

    public String getSafeLabel() {
        return safeLabel;
    }

    public void setSafeLabel(String safeLabel) {
        this.safeLabel = safeLabel;
    }

    public int getSafeLabelType() {
        return safeLabelType;
    }

    public void setSafeLabelType(int safeLabelType) {
        this.safeLabelType = safeLabelType;
    }

    @Override
    public String toString() {
        return "MarkerUserInfo{" +
                "sn='" + sn + '\'' +
                ", userId=" + userId +
                ", userName='" + userName + '\'' +
                ", userHead='" + userHead + '\'' +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                ", lastActiveweekAvgscore='" + lastActiveweekAvgscore + '\'' +
                ", safeLabel='" + safeLabel + '\'' +
                ", safeLabelType=" + safeLabelType +
                '}';
    }
}
