package com.iformall.domain.po;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.iformall.domain.po.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@TableName(value = "wx_c_user_basic_info")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxCUserBasicInfo extends BaseEntity {

    protected Long id;

	@JsonIgnore
    protected Date scoreDate;


    @Excel(name="姓名",width = 20,orderNum = "1")
	@NotNull
	@io.swagger.annotations.ApiModelProperty(value="用户姓名",name="name")
	private String name;

	@Excel(name="性别",width = 20,replace = { "保密_0", "男_1", "女_2"},orderNum = "2")
	@NotNull
	@io.swagger.annotations.ApiModelProperty(value="性别：0：保密 1.男 2女",name="sex")
	private Integer sex;

	@Excel(name = "手机号*", width = 20, orderNum = "3")
	@io.swagger.annotations.ApiModelProperty(value="微信用户绑定的手机号",name="phone")
	@NotNull
	private String phone;
	@Excel(name="微信昵称",width = 20,orderNum = "4")
	@io.swagger.annotations.ApiModelProperty(value="用户昵称",name="nickName")
	private String nickName;

	@Excel(name="学历",width = 20,orderNum = "5")
	@NotNull
	@io.swagger.annotations.ApiModelProperty(value="学历",name="education")
	private String education;

	@Excel(name="生日",width = 20,format="yyyy-MM-dd",orderNum = "6")
	@NotNull
	@io.swagger.annotations.ApiModelProperty(value="出生日期",name="birthdate")
	private Date birthdate;

	@Excel(name="地址",width = 20,orderNum = "7")
	@TableField(exist = false)
	private String addressStr;

	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
	private Date updateDate;

	@Excel(name="上次活跃时间",width = 20,format="yyyy-MM-dd", orderNum = "8")
	@io.swagger.annotations.ApiModelProperty(value="上次活跃时间",name="activeTime")
	private Date activeTime;

	@Excel(name="注册时间",width = 20,format="yyyy-MM-dd", orderNum = "9")
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
	private Date createDate;

	@Excel(name="成长值",width = 20, orderNum = "11")
	@io.swagger.annotations.ApiModelProperty(value="成长值",name="poins")
	private Integer poins;

	@io.swagger.annotations.ApiModelProperty(value="地址",name="address")
	private String address;

	@io.swagger.annotations.ApiModelProperty(value="邮箱",name="email")
	private String email;

	@io.swagger.annotations.ApiModelProperty(value="用户标签",name="tagId")
	private Long tagId;

	@io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId")
	private String tenantId;

	@io.swagger.annotations.ApiModelProperty(value="会员等级",name="level")
	private String level;

	@Excel(name="积分",width = 20, orderNum = "12")
	@io.swagger.annotations.ApiModelProperty(value="积分",name="credit")
	private Integer credit;

	@io.swagger.annotations.ApiModelProperty(value="活动记录",name="actRecord")
	private Integer actRecord;

	@TableField(exist = false)
	@Excel(name="标签",width = 50,orderNum = "10")
	private String tagNames;


	@TableField(exist = false)
	private String tagIds;

	@TableField(exist = false)
	private List<WxTags> tagsList;

	@TableField(exist = false)
	private List<String> carList;

	@TableField(exist = false)
	private Integer carCount;

	@TableField(exist = false)
	private Date startTime;

	@TableField(exist = false)
	private Date endTime;

	public String  getAddressStr() {
		if (address == null)
			return null;
		JSONObject addressJSON;
		try {
			addressJSON = JSONObject.parseObject(address);
			addressStr = addressJSON.getString("address")+addressJSON.getString("name");
		} catch (Exception e){
			return address;
		}

		return addressStr;
	}
	

	@Override
	public boolean equals(final Object obj) {
		if (obj == null) {
			return false;
		}
		final WxCUserBasicInfo user = (WxCUserBasicInfo) obj;
		if (this == user) {
			return true;
		} else {
			return (this.id.equals(user.id));
		}
	}

	@Override

	public int hashCode() {
		return Objects.hash(this.phone);
	}


	@io.swagger.annotations.ApiModelProperty(value = "状态0正常1锁定", name = "status")
	private Integer status;

}
