package com.fs.store.domain;

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

/**
 * 用户对象 fs_user
 *
 * @author fs
 * @date 2022-03-15
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class FsUser extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户id */
    private Long userId;
    @Excel(name = "帐号")
    private String username;
    /** 用户密码（跟pwd） */
    private String password;

    /** 真实姓名 */
    private String realName;

    /** 生日 */
    private Long birthday;

    /** 身份证号码 */
    private String idCard;

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

    /** 用户昵称 */
    @Excel(name = "用户昵称")
    private String nickname;

    /** 用户备注 */
    @Excel(name = "用户备注")
    private String remark;


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

    /** 最后一次登录ip */
    @Excel(name = "最后一次登录ip")
    private String lastIp;

    /** 用户余额 */
    @Excel(name = "用户余额")
    private BigDecimal nowMoney;

    /** 佣金金额 */
    @Excel(name = "佣金金额")
    private BigDecimal brokeragePrice;

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

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

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

    /** 等级 */
    private Integer level;

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

    /** 推广员关联时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date spreadTime;

    /** 用户类型 */
    private String userType;

    /** 是否为推广员 */
    private Integer isPromoter;

    /** 用户购买次数 */
    private Long payCount;

    /** 下级人数 */
    private Long spreadCount;

    /** 详细地址 */
    private String addres;


    private String maOpenId;

    private String mpOpenId;

    private String unionId;

    private Integer isDel;

    private Integer isWeixinAuth;

    private Long companyId;

    private Long companyUserId;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "推线日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date registerDate;
    @Excel(name = "推线编码")
    private String registerCode;
    @Excel(name = "渠道")
    private String source;

    private String userCode;


    /**
     * 剩余理赔额度
     */
    private BigDecimal remainingClaimLimit;

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

    public String getNickname()
    {
        if(StringUtils.isNotEmpty(nickname)){
            return EmojiParser.parseToUnicode(nickname);
        }
        else{
            return nickname;
        }
    }

}
