package cn.pluss.platform.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
@Accessors(chain = true)
public class UserInfo {

    /**
     * 删除状态
     */
    public static final int STATUS_DEL = -1;

    /**
     * 有效状态
     */
    public static final int STATUS_VALID = 1;

    /**
     * 关闭推广权限
     */
    public static final int STATUS_NO_SPREAD = -2;

    @TableId
    private Long id;
    private String loginName;
    private String trueName;
    private String provinceCode;
    private String cityCode;
    private String sex;
    private String phone;
    private String email;
    private Integer status;
    private String password;
    private String creator;
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    private String updator;
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    private String version;
    private Integer parentId;
    private Integer areaId;
    private String areaCode;
    private String source;
    private String merchantCode;
    private String storeId;

    /**
     * 老的支付密码
     */
    @TableField(exist = false)
    private String oldPayPassword;

    /**
     * 提现退款密码
     */
    private String payPassword;

    /**
     * 人脸认证标识，1为已通过人脸识别
     */
    private String faceCert;

    private String faceCompare;

    /**
     * @description:openid 用户发送订单通知
     * @date: 2021/9/23 14:52
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String openId;

    /** 渠道编码 */
    private String channelCode;

    @TableField(exist = false)
    private String checkCode;
    @TableField(exist = false)
    private String oldPassword;
    @TableField(exist = false)
    private String inviteCode;
    @TableField(exist = false)
    private String oldPhone;
    @TableField(exist = false)
    private String roleIds;

    /**
     * 生成一个新的用户对象
     * @return
     */
    public static UserInfo newInstance() {
        UserInfo userInfo = new UserInfo();
        Date date = new Date();
        userInfo.setCreateTime(date);
        userInfo.setUpdateTime(date);
        userInfo.setStatus(1);

        return userInfo;
    }
}

