package com.bocloud.ims.entity.common;

import com.alibaba.fastjson.JSONArray;
import com.bocloud.common.utils.DateDeserializer;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.bocloud.ims.entity.resource.ResourceQuota;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 租户类
 *
 * @author weiwei
 * @version 1.0
 * @since 2016.08.04
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table("tenant")
public class Tenant extends GenericEntity {
    // ID
    @PK(value = PKStrategy.AUTO)
    private Long id;
    // 租户邮箱
    @Column("email")
    private String email;
    // 租户邮箱
    @Column("display_name")
    private String displayName;
    // 编码
    @Column("group_code")
    private String groupCode;
    // 登录账号
    @Column("account")
    private String account;
    // 密码
    @Column("password")
    private String password;
    // 登录状态
    @Column("login_status")
    private Boolean loginStatus;
    // sessionId
    @Column("session_id")
    private String sessionId;

    /**
     * 租户类型
     */
    @Column("origin")
    private String origin;
    // 城市
    @Column("city")
    private String city;
    // 区县
    @Column("town")
    private String town;
    @IgnoreAll
    private String cityName;
    @IgnoreAll
    private String townName;
    // 计费号
    @Column("payment_code")
    private String paymentCode;
    // 客户联系人姓名
    @Column("contact_name")
    private String contactName;
    // 头像
    @Column("portrait")
    private String portrait;
    // 客户联系人邮箱
    @Column("contact_email")
    private String contactEmail;
    // 客户联系人电话
    @Column("contact_phone")
    private String contactPhone;
    // 父租户id
    @Column("parent_id")
    private Long parentId;
    // 父租户id
    @Column("parent_resource_id")
    private String parentResourceId;
    // 合同开始时间
    @Column("contract_begin")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date contractBegin;
    // 合同到期时间
    @Column("contract_finish")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date contractFinish;
    // 账号到期时间
    @Column("expired_date")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date expiredDate;
    // 账户折扣费率
    @Column("discount")
    private BigDecimal discount;
    // 客户经理ID
    @Column("manager_id")
    private Long managerId;
    @Column("code")
    private String code;//编码
    // 配额
    @IgnoreAll
    private JSONArray quotas;
    // 优惠券数量
    @IgnoreAll
    private Integer coupons;
    // CPU使用率
    @IgnoreAll
    private BigDecimal cpuRate;
    // 内存使用率
    @IgnoreAll
    private BigDecimal memoryRate;
    // 存储使用率
    @IgnoreAll
    private BigDecimal diskRate;
    // 租户配额
    @IgnoreAll
    private List<ResourceQuota> resourceQuotas;
    // 授权的服务id
    @IgnoreAll
    private List<ServiceBean> services;
    // 最后一次密码修改时间
    @Column("last_pwd_modify_date")
    @JsonSerialize(using = DateSerializer.class)
    @JsonDeserialize(using = DateDeserializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastPwdModifyDate;
    // 最后一次登录时间
    @Column("last_login_date")
    @JsonSerialize(using = DateSerializer.class)
    @JsonDeserialize(using = DateDeserializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastLoginDate;
    // 客户经理工号
    @IgnoreAll
    private String managerCode;
    // 客户经理姓名
    @IgnoreAll
    private String managerName;
    // 客户经理邮箱
    @IgnoreAll
    private String managerEmail;
    // 客户经理电话
    @IgnoreAll
    private String managerPhone;
    @IgnoreAll
    private String managerMobile;
    // 验证码
    @IgnoreAll
    private String captcha;
    // 运营平台订单数量
    @Column("cmp_orders")
    private Long cmpOrders;
    // esop订单数量
    @Column("esop_orders")
    private Long esopOrders;
    // 稽核状态
    @Column("audit_status")
    private String auditStatus;
    //最大快照数
    @Column("max_snapshot_count")
    private Integer maxSnapshotCount;
    //组织机构类型
    @Column("type")
    private String type;
    @IgnoreAll
    private List<Tenant> children;
    //授信额度
    @Column("money")
    private BigDecimal money;
    //是否试用
    @Column("on_trial")
    private Boolean onTrial;
    @Column("recycle_after_arrears")
    private Boolean recycleAfterArrears;
}
