package com.sheep.gamegroup.model.entity;

import android.text.TextUtils;

import com.sheep.gamegroup.util.BinaryUtils;
import com.sheep.gamegroup.util.TestUtil;
import com.sheep.gamegroup.util.share.ShareLinkConfig;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;

import java.io.Serializable;

/**
 * Created by ljy on 2018/3/17.
 */
@Table(name = "user")
public class UserEntity implements Serializable {

    @Column(name = "id", isId = true, autoGen = true)
    private int _id;//11,
    @Column(name = "user_id")
    private String id;//11,
    @Column(name = "mobile")
    private String mobile;//13688480841,
    @Column(name = "nickname")
    private String nickname;//test332211,
    @Column(name = "user_name")
    private String user_name;//test332211,
    @Column(name = "set_password")
    private int set_password = 0;//test332211,
    @Column(name = "balance")
    private String balance;//0,
    @Column(name = "invitation_code")
    private String invitation_code;//032033476,
    @Column(name = "parent_code")
    private String parent_code;//,
    @Column(name = "total_asset")
    private String total_asset;//0,
    @Column(name = "last_login_time")
    private String last_login_time;//1521254162,
    @Column(name = "create_time")
    private String create_time;//1521254162,
    @Column(name = "update_time")
    private String update_time;//1521254162,
    @Column(name = "avatar")
    private String avatar;//,
    @Column(name = "access_token")
    private String access_token;//_T6fiXabS5G_pQhLLP1qKA,
    @Column(name = "refresh_token")
    private String refresh_token;//AiO5n79nT-6vjratlulxkg,
    @Column(name = "open_id")
    private String open_id;//2804526,
    @Column(name = "real_name")
    private String real_name;//,
    @Column(name = "id_number")
    private String id_number;//,
    @Column(name = "bank_card")
    private String bank_card;//,
    @Column(name = "bank_card_mobile")
    private String bank_card_mobile;//,
    @Column(name = "total_withdraw")
    private String total_withdraw;//0,
    @Column(name = "wx_openid")
    private String wx_openid;//
    @Column(name = "wx_nickname")
    private String wx_nickname;
    @Column(name = "share_link")
    private String share_link;
    @Column(name = "newbie_task_status")
    private int newbie_task_status;
    @Column(name = "is_new")
    private int is_new;//1新用户 2老用户
    @Column(name = "is_agent")
    private int is_agent;//0不是代理 1是代理
    @Column(name = "certification_count")
    private int certification_count;//实名认证次数
    @Column(name = "must_bind_mobile")
    private int must_bind_mobile;//是否必须绑定手机号 0不是 1是
    @Column(name = "gender")
    private int gender;
    @Column(name = "birthday")
    private String birthday;
    @Column(name = "package_cate")//1官方包  2邀请包
    private int package_cate;
    @Column(name = "create_time_line")
    private int create_time_line;//1:小绵羊3.0之前的用户（注：以后如果再次有这种区分之前用户的需求就陆续加一）
    @Column(name = "bind_flag")
    private int bind_flag;//绑定表示 二进制形式 从低到高 第一位手机号 第二位QQ号 第三位微信

    public int getPackage_cate() {
        return package_cate;
    }

    public void setPackage_cate(int package_cate) {
        this.package_cate = package_cate;
    }

    public int getCreate_time_line() {
        return create_time_line;
    }

    public void setCreate_time_line(int create_time_line) {
        this.create_time_line = create_time_line;
    }

    public int getGender() {
        return gender;
    }

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

    public String getBirthday() {
        return TextUtils.isEmpty(birthday) ? "0" : birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getWx_nickname() {
        return wx_nickname;
    }

    public void setWx_nickname(String wx_nickname) {
        this.wx_nickname = wx_nickname;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getBalance() {
        return balance == null ? "0" : balance;
    }

    public void setBalance(String balance) {
        this.balance = balance;
    }

    public String getInvitation_code() {
        return invitation_code;
    }

    public void setInvitation_code(String invitation_code) {
        this.invitation_code = invitation_code;
    }

    public String getUser_name() {
        return user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }

    public String getParent_code() {
        return parent_code;
    }

    public void setParent_code(String parent_code) {
        this.parent_code = parent_code;
    }

    public String getTotal_asset() {
        return total_asset == null ? "0" : total_asset;
    }

    public void setTotal_asset(String total_asset) {
        this.total_asset = total_asset;
    }

    public String getLast_login_time() {
        return last_login_time;
    }

    public void setLast_login_time(String last_login_time) {
        this.last_login_time = last_login_time;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getAccess_token() {
        return access_token;
    }

    public void setAccess_token(String access_token) {
        this.access_token = access_token;
    }

    public String getRefresh_token() {
        return refresh_token;
    }

    public void setRefresh_token(String refresh_token) {
        this.refresh_token = refresh_token;
    }

    public String getOpen_id() {
        return open_id;
    }

    public void setOpen_id(String open_id) {
        this.open_id = open_id;
    }

    public String getReal_name() {
        return real_name;
    }

    public void setReal_name(String real_name) {
        this.real_name = real_name;
    }

    public String getId_number() {
        return id_number;
    }

    public void setId_number(String id_number) {
        this.id_number = id_number;
    }

    public String getBank_card() {
        return bank_card;
    }

    public void setBank_card(String bank_card) {
        this.bank_card = bank_card;
    }

    public String getTotal_withdraw() {
        return total_withdraw;
    }

    public void setTotal_withdraw(String total_withdraw) {
        this.total_withdraw = total_withdraw;
    }

    public String getWx_openid() {
        return wx_openid;
    }

    public void setWx_openid(String wx_openid) {
        this.wx_openid = wx_openid;
    }

    public String getShare_link() {
        return share_link;
    }

    public void setShare_link(String share_link) {
        this.share_link = share_link;
    }

    public int getNewbie_task_status() {
        return newbie_task_status;
    }

    public void setNewbie_task_status(int newbie_task_status) {
        this.newbie_task_status = newbie_task_status;
    }

    public int getIs_new() {
        return is_new;
    }

    public void setIs_new(int is_new) {
        this.is_new = is_new;
    }

    public int getIs_agent() {
        return is_agent;
    }

    public void setIs_agent(int is_agent) {
        this.is_agent = is_agent;
    }

    public String getBank_card_mobile() {
        return bank_card_mobile;
    }

    public void setBank_card_mobile(String bank_card_mobile) {
        this.bank_card_mobile = bank_card_mobile;
    }

    public int getCertification_count() {
        return certification_count;
    }

    public void setCertification_count(int certification_count) {
        this.certification_count = certification_count;
    }

    public int getMust_bind_mobile() {
        return must_bind_mobile;
    }

    public void setMust_bind_mobile(int must_bind_mobile) {
        this.must_bind_mobile = must_bind_mobile;
    }

    public int getBind_flag() {
        return bind_flag;
    }

    public void setBind_flag(int bind_flag) {
        this.bind_flag = bind_flag;
    }

    public int getSet_password() {
        return set_password;
    }

    public void setSet_password(int set_password) {
        this.set_password = set_password;
    }

    public boolean isNewRegistUser() {//新注册用户
        return TextUtils.equals(create_time, last_login_time);
    }

    //没有实名认证
    public boolean notCertification() {
        return TextUtils.isEmpty(getReal_name()) || TextUtils.isEmpty(getId_number());
    }

    /**
     * 老用户选择绑定手机号
     *
     * @return
     */
    public boolean canBindMobile() {
        return must_bind_mobile == 0 && TextUtils.isEmpty(mobile);
    }

    //测试服用测试分享链接，正式服用正式的
    public String getShareLink(@ShareLinkConfig.SHARE_TYPE String type) {
        return ShareLinkConfig.jointString(getShareLink(), type);
    }

    //测试服用测试分享链接，正式服用正式的
    public String getShareLink() {//测试服对应的下载地址为http://10.8.230.17:7776/newsheep?id=32778005
        return TestUtil.isSheep() ? getShare_link() : "http://10.8.210.230:8902/share.html?invitation_code=" + getInvitation_code();
    }

    /**
     * 是否绑定手机号
     */
    public boolean isBindMobile() {
        return BinaryUtils.is(bind_flag, 1);
    }

    /**
     * 是否绑定QQ号
     */
    public boolean isBindQQ() {
        return BinaryUtils.is(bind_flag, 2);
    }

    /**
     * 是否绑定微信号
     */
    public boolean isBindWx() {
        return BinaryUtils.is(bind_flag, 3);
    }

    /**
     * 是否是官方包注册用户
     *
     * @return
     */
    public boolean isKfzsPackageUser() {
        return !TextUtils.isEmpty(parent_code) || (create_time_line < 2) || (package_cate == 1);
    }
}
