package cn.pluss.platform.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.UUID;

@Data
@NoArgsConstructor
public class Notice {

    /**
     * 系统通知 - 身份证认证
     */
    public static final int TYPE_ID_CARD_AUTH = 0;

    /**
     * 系统通知 - 商户认证
     */
    public static final int TYPE_MERCHANT_AUTH = 1;

    /**
     * 系统通知 - 员工退款申请
     */
    public static final int TYPE_STAFF_REFUND = 2;

    /**
     * 系统通知 - 银行卡认证
     */
    public static final int TYPE_BANK_AUTH = 5;

    /**
     * 系统通知 - 商户资料修改
     */
    public static final int TYPE_MER_DATA_CHANGE = 8;

    /**
     * 系统通知 - 结算卡修改
     */
    public static final int TYPE_MER_BANK_CHANGE = 9;

    /**
     * 系统通知 - 商户违规
     */
    public static final int TYPE_MER_OUT_LINE = 10;

    /**
     * 系统通知 - 商户异常
     */
    public static final int TYPE_MER_EXCEPTION = 11;

    /**
     * 系统通知 - 商户冻结
     */
    public static final int TYPE_MER_FREEZE = 12;

    /**
     * 分润通知 - 商户分润
     */
    public static final int TYPE_MER_PROFIT = 6;

    /**
     * 分润通知 - 商户升级分润
     */
    public static final int TYPE_MER_UPDATE_PROFIT = 7;

    @TableId
    private Integer id;

    @TableField(value = "userId")
    private String userId;
    private String userName;

    /**
     * 0 分润通知; 1 系统通知; 2到账通知
     */
    private Integer typeFirst;

    /**
     * -1 自定义
     * 0身份证认证    1商家认证  2店员退款通知   4邀请注册通知  5银行卡认证  6 商户分润通知 98到账通知  99 其他    7升级收益通知
     */
    private Integer typeSecond;
    private String conrtent;

    @TableField(value = "createDt", fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDt;
    private String noticeCode;
    private String orderNumber;
    private Integer isDeal;
    private Integer isApply;

    private String title;

    @TableField(value = "`desc`")
    private String desc;

    /**
     * 内容外链url
     */
    private String url;

    /**
     * 唯一标识
     */
    private String uniqueKey;

    @TableField(exist = false)
    private String createUserId;

    /**
     * 已读标识，1为已读
     */
    @TableField(exist = false)
    private Integer readStatus;

    /**
     * 推送表示，0，不推送，1，推送， 2，推送并推送上级
     */
    @TableField(exist = false)
    private String pushFlag;

    /**
     * @description:指定推送的ids
     * @date: 2021/8/27 14:51
     */
    @TableField(exist = false)
    private String userIds;

    @TableField(exist = false)
    private String aliass;

    @TableField(exist = false)
    private String parentIds;

    @TableField(exist = false)
    private String parentName;

    @TableField(exist = false)
    private String scheduleFlag;

    public Notice(Integer firstType, Integer secondType, UserApp userApp) {
        this.setUserId(userApp.getUserId().toString());
        this.setNoticeCode(UUID.randomUUID().toString().replace("-", ""));
        this.setCreateDt(new Date());
        this.setUserName(userApp.getUserName());
        this.setTypeFirst(firstType);
        this.setTypeSecond(secondType);
        this.setIsDeal(0);
    }

    public Notice(Integer firstType, Integer secondType, String userId) {
        this.setUserId(userId);
        this.setNoticeCode(UUID.randomUUID().toString().replace("-", ""));
        this.setCreateDt(new Date());
        this.setTypeFirst(firstType);
        this.setTypeSecond(secondType);
        this.setIsDeal(0);
    }

    public Notice(Integer firstType, Integer secondType, String userId, String userName) {
        this.setUserId(userId);
        this.setNoticeCode(UUID.randomUUID().toString().replace("-", ""));
        this.setCreateDt(new Date());
        this.setUserName(userName);
        this.setTypeFirst(firstType);
        this.setTypeSecond(secondType);
        this.setIsDeal(0);
    }
}