package cn.pluss.platform.entity;

import cn.pluss.platform.config.mybatis.SqlConditionExtra;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 用户结算信息关联表
 * </p>
 *
 * @author Djh
 * @since 2020-10-17
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@AllArgsConstructor
@TableName("tb_pluss_account")
public class Account implements Serializable {

    public static final String CHANNEL_TYPE_D1 = "D1";
    public static final String CHANNEL_TYPE_D0 = "D0";

    /** 小微 */
    public static final String SETTLE_TYPE_MICRO_STORE = "00";
    /** 对私法人结算 */
    public static final String SETTLE_TYPE_PRIVATE_LEGAL = "01";
    /** 我是法人 */
    public static final String IS_SELF_LEGAL = "1";
    /** 我不是法人 */
    public static final String NOT_SELF_LEGAL = "2";
    /** 对私非法人结算 */
    public static final String SETTLE_TYPE_PRIVATE_ILLEGAL = "02";
    /** 对公结算 */
    public static final String SETTLE_TYPE_CORPORATE = "03";

    /** 对私法人-我是法人 */
    public static final String LEGAL_PRIVATE_LEGAL = SETTLE_TYPE_PRIVATE_LEGAL + IS_SELF_LEGAL;
    /** 对私法人-我不是法人*/
    public static final String ILLEGAL_PRIVATE_LEGAL = SETTLE_TYPE_PRIVATE_LEGAL + NOT_SELF_LEGAL;
    /** 对私非法人-我是法人*/
    public static final String LEGAL_PRIVATE_ILLEGAL = SETTLE_TYPE_PRIVATE_ILLEGAL + IS_SELF_LEGAL;
    /** 对私非法人-我不是法人*/
    public static final String ILLEGAL_PRIVATE_ILLEGAL = SETTLE_TYPE_PRIVATE_ILLEGAL + NOT_SELF_LEGAL;

    private static final long serialVersionUID = 1L;

    public Account(String userId, String settleType, String idCardId, String bankCardId, String certificateUrl, String channelType) {
        this.userId = userId;
        this.settleType = settleType;
        this.idCardId = idCardId;
        this.bankCardId = bankCardId;
        this.certificateUrl = certificateUrl;
        this.channelType = channelType;
    }

    public Account() {
        this.channelType = Account.CHANNEL_TYPE_D1;
    }

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;


    /**
     * 用户id
     */
    @NotNull(message = "缺少用户id")
    @TableField("userId")
    private String userId;

    /**
     * 非法人授权书
     */
    @TableField("certificateUrl")
    private String certificateUrl;

    /**
     * 结算类型，01：对私法人；02：对私非法人；03：对公。
     * 返回给前端显示的则有, 00 小微商户, 011法人对私法人，012非法人对私法人, 021法人对私非法人，022非法人对私非法人，03：对公
     */
    @TableField("settleType")
    private String settleType;


    /**
     * 身份证id
     */
    @TableField("idCardId")
    private String idCardId;


    /**
     * 银行卡id
     */
    @TableField("bankCardId")
    private String bankCardId;

    /**
     * D0、D1
     * 默认值D1
     */
    @TableField(value = "channelType", fill = FieldFill.INSERT)
    private String channelType;

    /**
     * 创建时间
     */
    @TableField(value = "createTime", fill = FieldFill.INSERT, whereStrategy = FieldStrategy.NEVER)
    private Date createTime;

    /**
     * 创建时间 开始时间
     */
    @TableField(select = false, value = "createTime", condition = SqlConditionExtra.GT)
    private Date createTimeStart;

    /**
     * 创建时间 截止时间
     */
    @TableField(select = false, value = "createTime", condition = SqlConditionExtra.LT)
    private Date createTimeEnd;

    /**
     * 更新时间
     */
    @TableField(value = "updateTime", fill = FieldFill.INSERT_UPDATE, whereStrategy = FieldStrategy.NEVER)
    private Date updateTime;

    /**
     * 更新时间 开始时间
     */
    @TableField(select = false, value = "updateTime", condition = SqlConditionExtra.GT)
    private Date updateTimeStart;

    /**
     * 更新时间 截止时间
     */
    @TableField(select = false, value = "updateTime", condition = SqlConditionExtra.LT)
    private Date updateTimeEnd;

    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private JSONObject bak;
}