package cn.pluss.platform.entity;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import java.util.Date;

/**
 * @author DJH
 */
@Data
@Accessors(chain = true)
@TableName("tb_pluss_jft_bank_card")
public class JftBankCard {

    public interface Common {}

    public static final String STATUS_NORMAL = "1";

    public static final String STATUS_IN_CHANGE = "2";

    @TableId
    @JSONField(serialize = false)
    private Long id;


    private Long userId;

    private String bankHolder;

    @NotEmpty(message = "银行卡号不能为空", groups = {JftBankCard.Common.class})
    private String bankCardNo;

    @NotEmpty(message = "银行名称不能为空", groups = {JftBankCard.Common.class})
    private String bankName;

    @NotEmpty(message = "支行名称不能为空", groups = {JftBankCard.Common.class})
    private String branchName;

    @NotEmpty(message = "支行联行号不能为空", groups = {JftBankCard.Common.class})
    private String contactLine;

    @NotEmpty(message = "银行所属省不能为空", groups = {JftBankCard.Common.class})
    private String branchProvince;

    @NotEmpty(message = "银行所属市不能为空", groups = {JftBankCard.Common.class})
    private String branchCity;

    @NotEmpty(message = "银行所属区不能为空", groups = {JftBankCard.Common.class})
    private String branchArea;

    @NotEmpty(message = "银行卡预留手机号不能为空", groups = {JftBankCard.Common.class})
    private String phone;

    @NotEmpty(message = "银行卡卡面图片不能为空", groups = {JftBankCard.Common.class})
    private String imgUrl;

    /**
     * 1：正常；2：变更中
     */
    private String status;

    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        if (status == null) {
            return null;
        }

        switch (status) {
            case "1":
                statusDesc = "生效中";
                break;
            case "2":
                statusDesc = "结算卡变更中";
                break;
            default:
                break;
        }
        return statusDesc;
    }

    private JSONObject bak;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "createTime", fill = FieldFill.INSERT)
    private Date createTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
}
