/*CopyRright (c)2014: <www.usoftchina.com>
 */
package com.uas.platform.b2b.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.uas.platform.core.model.Constant;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 企业信息
 * 
 * @author yingp
 */
@Entity
@Table(name = "sec$enterprises")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "com.uas.platform.b2b.model.Enterprise")
public class Enterprise implements Serializable {

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "en_uu")
	private Long uu;

	/**
	 * 公司名称
	 */
	@NotNull
	@Column(name = "en_name")
	private String enName;

	/**
	 * 简称
	 */
	@Column(name = "en_shortname")
	private String enShortname;

	/**
	 * 公司类型
	 */
	@Column(name = "en_type")
	private String enType;

	/**
	 * 企业注册地区
	 */
	@Column(name = "en_area")
	private String enArea;

	/**
	 * 状态
	 */
	@Column(name = "en_status")
	private Short enStatus;

	/**
	 * 传输到管理平台的状态
	 */
	@Column(name = "en_sendstatus")
	private Short enSendStatus;

	/**
	 * 注册地址
	 */
	@Column(name = "en_address")
	private String enAddress;

	/**
	 * 默认送货地址
	 */
	@Column(name = "en_deliveraddr")
	private String enDeliverAddr;

	/**
	 * 公司电话
	 */
	@Column(name = "en_tel")
	private String enTel;

	/**
	 * 传真
	 */
	@Column(name = "en_fax")
	private String enFax;

	/**
	 * 公司邮箱
	 */
	@Column(name = "en_email")
	private String enEmail;

	/**
	 * 员工人数
	 */
	@Column(name = "en_emcount")
	private Integer emcount;

	/**
	 * 开户银行
	 */
	@Column(name = "en_enbank")
	private String enbank;

	/**
	 * 公司法人
	 */
	@Column(name = "en_corporation")
	private String enCorporation;

	/**
	 * 商业登记证号
	 */
	@Column(name = "en_businesscode")
	private String enBussinessCode;

	/**
	 * 营业执照号服务器路径，账户中心同步时同步过来
	 */
	@Column(name = "en_businesscodeimg")
	private String businesscodeimg;

	/**
	 * 营业执照图片路径id
	 */
	@OneToOne(cascade = { CascadeType.ALL })
	@JoinColumn(name = "en_bussinesscodeattach")
	private Attach enBussinessCodeAttach;

	/**
	 * 纳税人识别号
	 */
	@Column(name = "en_taxcode")
	private String enTaxcode;

	/**
	 * 注册资本
	 */
	@Column(name = "en_registercapital")
	private String enRegistercapital;

	/**
	 * 公司主页地址
	 */
	@Column(name = "en_url")
	private String enUrl;

	/**
	 * 注册时间
	 */
	@Column(name = "en_time")
	private Date enDate;

	/**
	 * 管理员UU号
	 */
	@Column(name = "en_adminuu")
	private Long enAdminuu;

	/**
	 * 所属行业
	 */
	@Column(name = "en_industry")
	private String enIndustry;

	/**
	 * 优企云服域名
	 */
	@Column(name = "en_saasurl")
	private String enSaasUrl;

	/**
	 * 优企云服状态
	 */
	@Column(name = "en_saasstatus")
	private Short enSaasStatus;

	/**
	 * 优企云服传输状态
	 */
	@Column(name = "en_saassendstatus")
	private Short enSaasSendStatus;

	/**
	 * enIsErp
	 */
	@Column(name = "en_iserp")
	private Short enIsErp;

	/**
	 * log路径
	 */
	@Column(name = "en_logurl")
	private String logUrl;

	public Short getEnIsErp() {
		return enIsErp;
	}

	/**
	 * en_management 经营模式
	 */
	@Column(name = "en_management")
	private String enManagement;

	/**
	 * en_brands 主营品牌（多个用逗号分隔）
	 */
	@Column(name = "en_brands")
	private String enBrands;

	/**
	 * en_products 主营产品
	 */
	@Column(name = "en_products")
	private String enProducts;

	/**
	 * 记录产品的销售状态<br>
	 * 1. 开启<br>
	 * 0. 关闭
	 */
	@Column(name = "en_prodsale")
	private Short prodsale;

	/**
	 * 记录物料的采购状态<br>
	 * 1. 开启<br>
	 * 0. 关闭
	 * 
	 * @return
	 */
	@Column(name = "en_prodpurc")
	private Short prodpurc;

	/**
	 * 行业
	 */
	@Column(name = "en_profession")
	private String profession;

	/**
	 * 主营业务
	 */
	@Column(name = "en_tags")
	private String tags;

	/**
	 * 联系人
	 */
	@Column(name = "en_contactman")
	private String contactMan;

	/**
	 * 联系人电话
	 */
	@Column(name = "en_contacttel")
	private String contactTel;

	/**
	 * 联系人邮箱
	 */
	@Column(name = "en_contactemail")
	private String contactEmail;

	/**
	 * 企业权重 （用于供应商资源库排序） -- 2018年3月29日 17:59:00
	 */
	@Column(name = "en_weight")
	private Integer weight;

    /**
     * 邀请企业UU
     */
	@Column(name = "en_inviteuu")
    private Long inviteUU;

    /**
     * 邀请用户UU
     */
	@Column(name = "en_inviteuseruu")
    private Long inviteUserUU;

    /**
     * 邀请时间
     */
	@Column(name = "en_invitetime")
    private Long inviteTime;

    /**
     * 邀请来源
     */
	@Column(name = "en_invitesource")
    private String inviteSource;

	public String getEnManagement() {
		return enManagement;
	}

	public void setEnManagement(String enManagement) {
		this.enManagement = enManagement;
	}

	public String getEnProducts() {
		return enProducts;
	}

	public void setEnProducts(String enProducts) {
		this.enProducts = enProducts;
	}

	public String getEnInfo() {
		return enInfo;
	}

	public void setEnInfo(String enInfo) {
		this.enInfo = enInfo;
	}

	/**
	 * en_info 公司简介
	 */
	@Column(name = "en_info")
	private String enInfo;

	public void setEnIsErp(Short enIsErp) {
		this.enIsErp = enIsErp;
	}

	/**
	 * 管理员密码
	 */
	@Column(name = "en_adminpassword")
	private String enAdminPassword;

	@Transient
	private User admin;// 管理员（前台页面显示）

	@Transient
	private Long enBussinesscodeImg;// 营业执照号附件id（转化传到管理平台）

	@Transient
	private String enAdminName;// 管理员名字(转化传到管理平台)

	@Transient
	private String enAdminTel;// 管理员手机号(转化传到管理平台)

	@Transient
	private String enAdminEmail;// 管理员邮箱(转化传到管理平台)

	@Transient
	private String enAuditRemark;// 审核(从管理平台传过来)

	/**
	 * 私钥
	 */
	@Column(name = "en_accesssecret")
	private String accessSecret;

	/**
	 * en_masterId 企业对应管理系统ID
	 */
	@Column(name = "en_masterid")
	private Long enMasterId;

	public Long getEnMasterId() {
		return enMasterId;
	}

	public void setEnMasterId(Long enMasterId) {
		this.enMasterId = enMasterId;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	public String getEnAuditRemark() {
		return enAuditRemark;
	}

	public void setEnAuditRemark(String enAuditRemark) {
		this.enAuditRemark = enAuditRemark;
	}

	public Long getEnAdminuu() {
		return enAdminuu;
	}

	public void setEnAdminuu(Long enAdminuu) {
		this.enAdminuu = enAdminuu;
	}

	private Short enable;

	public Long getUu() {
		return uu;
	}

	public void setUu(Long uu) {
		this.uu = uu;
	}

	public String getEnName() {
		return enName;
	}

	public void setEnName(String enName) {
		this.enName = enName;
	}

	public String getEnShortname() {
		return enShortname;
	}

	public void setEnShortname(String enShortname) {
		this.enShortname = enShortname;
	}

	public String getEnType() {
		return enType;
	}

	public void setEnType(String enType) {
		this.enType = enType;
	}

	public Short getEnStatus() {
		return enStatus;
	}

	public void setEnStatus(Short enStatus) {
		this.enStatus = enStatus;
	}

	public String getEnAddress() {
		return enAddress;
	}

	public void setEnAddress(String enAddress) {
		this.enAddress = enAddress;
	}

	public String getEnDeliverAddr() {
		return enDeliverAddr;
	}

	public void setEnDeliverAddr(String enDeliverAddr) {
		this.enDeliverAddr = enDeliverAddr;
	}

	public String getEnTel() {
		return enTel;
	}

	public void setEnTel(String enTel) {
		this.enTel = enTel;
	}

	public String getEnFax() {
		return enFax;
	}

	public void setEnFax(String enFax) {
		this.enFax = enFax;
	}

	public String getEnCorporation() {
		return enCorporation;
	}

	public void setEnCorporation(String enCorporation) {
		this.enCorporation = enCorporation;
	}

	public String getEnBussinessCode() {
		return enBussinessCode;
	}

	public void setEnBussinessCode(String enBussinessCode) {
		this.enBussinessCode = enBussinessCode;
	}

	public String getEnBrands() {
		return enBrands;
	}

	public void setEnBrands(String enBrands) {
		this.enBrands = enBrands;
	}

	public String getEnTaxcode() {
		return enTaxcode;
	}

	public void setEnTaxcode(String enTaxcode) {
		this.enTaxcode = enTaxcode;
	}

	public String getEnRegistercapital() {
		return enRegistercapital;
	}

	public void setEnRegistercapital(String enRegistercapital) {
		this.enRegistercapital = enRegistercapital;
	}

	public String getEnUrl() {
		return enUrl;
	}

	public void setEnUrl(String enUrl) {
		this.enUrl = enUrl;
	}

	public Date getEnDate() {
		return enDate;
	}

	public void setEnDate(Date enDate) {
		this.enDate = enDate;
	}

	public Short getEnable() {
		return enable;
	}

	public void setEnable(Short enable) {
		this.enable = enable;
	}

	public String getEnEmail() {
		return enEmail;
	}

	public void setEnEmail(String enEmail) {
		this.enEmail = enEmail;
	}

	public Attach getEnBussinessCodeAttach() {
		return enBussinessCodeAttach;
	}

	public void setEnBussinessCodeAttach(Attach enBussinessCodeAttach) {
		this.enBussinessCodeAttach = enBussinessCodeAttach;
	}

	public String getEnAdminTel() {
		return enAdminTel;
	}

	public void setEnAdminTel(String enAdminTel) {
		this.enAdminTel = enAdminTel;
	}

	public String getEnAdminEmail() {
		return enAdminEmail;
	}

	public void setEnAdminEmail(String enAdminEmail) {
		this.enAdminEmail = enAdminEmail;
	}

	public Long getEnBussinesscodeImg() {
		return enBussinesscodeImg;
	}

	public void setEnBussinesscodeImg(Long enBussinesscodeImg) {
		this.enBussinesscodeImg = enBussinesscodeImg;
	}

	public Short getEnSendStatus() {
		return enSendStatus;
	}

	public void setEnSendStatus(Short enSendStatus) {
		this.enSendStatus = enSendStatus;
	}

	public String getEnArea() {
		return enArea;
	}

	public void setEnArea(String enArea) {
		this.enArea = enArea;
	}

	public User getAdmin() {
		return admin;
	}

	public void setAdmin(User admin) {
		this.admin = admin;
	}

	public String getEnAdminName() {
		return enAdminName;
	}

	public void setEnAdminName(String enAdminName) {
		this.enAdminName = enAdminName;
	}

	public String getEnIndustry() {
		return enIndustry;
	}

	public void setEnIndustry(String enIndustry) {
		this.enIndustry = enIndustry;
	}

	public String getEnSaasUrl() {
		return enSaasUrl;
	}

	public void setEnSaasUrl(String enSaasUrl) {
		this.enSaasUrl = enSaasUrl;
	}

	public Short getEnSaasStatus() {
		return enSaasStatus;
	}

	public void setEnSaasStatus(Short enSaasStatus) {
		this.enSaasStatus = enSaasStatus;
	}

	public Short getEnSaasSendStatus() {
		return enSaasSendStatus;
	}

	public void setEnSaasSendStatus(Short enSaasSendStatus) {
		this.enSaasSendStatus = enSaasSendStatus;
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public String getEnAdminPassword() {
		return enAdminPassword;
	}

	public void setEnAdminPassword(String enAdminPassword) {
		this.enAdminPassword = enAdminPassword;
	}

	public String getAccessSecret() {
		return accessSecret;
	}

	public void setAccessSecret(String accessSecret) {
		this.accessSecret = accessSecret;
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public boolean isEnabled() {
		return this.getEnable() != null && this.getEnable() == Constant.YES;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((uu == null) ? 0 : uu.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
            return true;
        }
		if (obj == null) {
            return false;
        }
		if (getClass() != obj.getClass()) {
            return false;
        }
		Enterprise other = (Enterprise) obj;
		if (uu == null) {
			if (other.uu != null) {
                return false;
            }
		} else if (!uu.equals(other.uu)) {
            return false;
        }
		return true;
	}

	public String getLogUrl() {
		return logUrl;
	}

	public void setLogUrl(String logUrl) {
		this.logUrl = logUrl;
	}

	public Integer getEmcount() {
		return emcount;
	}

	public void setEmcount(Integer emcount) {
		this.emcount = emcount;
	}

	public String getEnbank() {
		return enbank;
	}

	public void setEnbank(String enbank) {
		this.enbank = enbank;
	}

	public Short getProdsale() {
		return prodsale;
	}

	public void setProdsale(Short prodsale) {
		this.prodsale = prodsale;
	}

	public Short getProdpurc() {
		return prodpurc;
	}

	public void setProdpurc(Short prodpurc) {
		this.prodpurc = prodpurc;
	}

	public String getBusinesscodeimg() {
		return businesscodeimg;
	}

	public void setBusinesscodeimg(String businesscodeimg) {
		this.businesscodeimg = businesscodeimg;
	}

	public String getProfession() {
		return profession;
	}

	public void setProfession(String profession) {
		this.profession = profession;
	}

	public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}

	public String getContactMan() {
		return contactMan;
	}

	public void setContactMan(String contactMan) {
		this.contactMan = contactMan;
	}

	public String getContactTel() {
		return contactTel;
	}

	public void setContactTel(String contactTel) {
		this.contactTel = contactTel;
	}

	public String getContactEmail() {
		return contactEmail;
	}

	public void setContactEmail(String contactEmail) {
		this.contactEmail = contactEmail;
	}

	public Integer getWeight() {
		return weight;
	}

	public void setWeight(Integer weight) {
		this.weight = weight;
	}

    public Long getInviteUU() {
        return inviteUU;
    }

    public void setInviteUU(Long inviteUU) {
        this.inviteUU = inviteUU;
    }

    public Long getInviteUserUU() {
        return inviteUserUU;
    }

    public void setInviteUserUU(Long inviteUserUU) {
        this.inviteUserUU = inviteUserUU;
    }

    public Long getInviteTime() {
        return inviteTime;
    }

    public void setInviteTime(Long inviteTime) {
        this.inviteTime = inviteTime;
    }

    public String getInviteSource() {
        return inviteSource;
    }

    public void setInviteSource(String inviteSource) {
        this.inviteSource = inviteSource;
    }
}
