package com.fs.his.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fs.common.annotation.Excel;
import com.fs.common.core.domain.BaseEntity;
import org.apache.commons.lang3.StringUtils;
import com.vdurmont.emoji.EmojiParser;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 用户对象 fs_user
 *
 * @author fs
 * @date 2023-06-07
 */
@Data
public class FsUser extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户id */
    @Excel(name = "ID", sort = 0)
    private Long userId;
    private String username;
    private String password;
    private String realName;
    private Long birthday;
    /** 用户昵称 */
    private String idCard;

    /** 用户昵称 */
    @Excel(name = "会员昵称", sort = 1)
    private String nickName;

    /** 用户头像 */
//    @Excel(name = "用户头像")
    private String avatar;
    private String remark;

    /** 手机号码 */
    @Excel(name = "手机号码")
    private String phone;
    private BigDecimal nowMoney;
    private BigDecimal brokeragePrice;

    /** 用户积分 */
    @Excel(name = "用户积分")
    private Long integral;

    /** 1为正常，0为禁止 */
    @Excel(name = "1为正常，0为禁止")
    private Integer status;

    /** 推广上级用户ID */
    @Excel(name = "推广上级用户ID")
    private String tuiUserId;
    private Date spreadTime;

    /** 推广员关联时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "推广员关联时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date tuiTime;
    private String userType;
    private Integer isPromoter;
    private Long payCount;
    private Long spreadCount;
    private String addres;

    /** 下级人数 */
    @Excel(name = "下级人数")
    private Long tuiUserCount;

    /** 微信小程序OPENID */
//    @Excel(name = "微信小程序OPENID")
    private String maOpenId;

    /** 微信公众号OPENID */
//    @Excel(name = "微信公众号OPENID")
    private String mpOpenId;

    /** 关联ID */
    @Excel(name = "关联ID")
    private String unionId;

    /** $column.columnComment */
    @Excel(name = "关联ID")
    private Integer isDel;

    /** 邀请码 */
    @Excel(name = "邀请码")
    private String userCode;

    private Long companyId;
    private Long companyUserId;
    private String companyUserName;

    /** 公司用户ID，逗号拼接*/
    @TableField(exist = false)
    private String companyUserIdMulti;

    /** 公司用户ID，用于查询*/
    @TableField(exist = false)
    private String[] companyUserIds;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "推线日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date registerDate;
    @Excel(name = "推线编码")
    private String registerCode;
    /** 最后一次登录ip */
    @Excel(name = "最后一次登录ip")
    private String lastIp;

    /** 余额 */
    @Excel(name = "余额")
    private BigDecimal balance;

    /** 连续签到天数 */
    @Excel(name = "连续签到天数")
    private Long signNum;

    private Integer integralStatus;

    private Integer isBuy;

    private String jpushId;
    private Integer isVip;
    private Date  vipStartDate;
    private Date  vipEndDate;
    private Integer vipLevel;

    /**
     * 会员等级
     */
    private Integer level;
    private Integer vipStatus;

    private Integer sex;
    private String storeOpenId;

    //是否关注公众号
    private Integer isOfficialAccountAuth;
    private Integer isPush; //是否消息通知

    private Integer isIndividuationPush;//是否个性化推送

    private Integer isWeixinAuth;

    private String loginDevice;//当前登录设备

    private String source;//app来源

    private Integer isAddQw;//是否添加企微客服
    private Integer isShow;//是否展示购买以及订单状态

    private Long parentId; //邀请人id

    private String courseMaOpenId; //看课小程序openid

    private Long qwExtId;

    /** 下单次数 */
    private Long orderCount;

    /** 累计成交总额 */
    @Excel(name = "累计成交总额")
    private BigDecimal totalAmount;

    /**
     * 企微销售ID
     * **/
    private Long qwUserId;


    /** 推广上级用户ID */
    private Long spreadUserId;

    public void setNickName(String nickname)
    {
        if(StringUtils.isNotEmpty(nickname)){
            this.nickName= EmojiParser.parseToHtmlDecimal(nickname);
        }
        else{
            this.nickName= nickname;
        }
        this.nickname = this.nickName;
    }

    public String getNickName()
    {
        if(StringUtils.isNotEmpty(nickName)){
            return EmojiParser.parseToUnicode(nickName);
        }
        else{
            return nickName;
        }
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(exist = false)
    private Date startCreateTime;

    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endCreateTime;

    /**
     * 项目ID
     */
    private Long projectId;

    /**
     * 昵称
     * **/
    @TableField(exist = false)
    private String nickname;

    /**
     * 昵称-精确查询
     * **/
    @TableField(exist = false)
    private String nicknameExact;

    public String getNickname() {
        return nickname;
    }

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