package com.ruoyi.ibs.grid.domain.excel;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.ibs.enumertion.CustTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

/**
 * @Author 吴凯程
 * @Date 2024/9/23
 **/
@Data
public class VirtualCustUserImportDTO {


    @ApiModelProperty(value = "客户类型", name = "custType", notes = "个人 企业 商户")
    @Excel(name = "客户类型(个人 企业 商户)*", prompt = "必填", combo = "个人,商户,企业")
    private String custType;

    @ApiModelProperty(value = "客户号", name = "custId")
    @Excel(name = "客户号*", prompt = "必填")
    private String custId;

    @ApiModelProperty(value = "客户姓名", name = "custName")
    @Excel(name = "客户姓名")
    private String custName;

    @ApiModelProperty(value = "客户证件类型(身份证 营业执照)", name = "custIdType")
    private String custIdType;

    @ApiModelProperty(value = "客户证件号", name = "custIdn")
    @Excel(name = "客户证件号")
    private String custIdn;

    @ApiModelProperty(value = "客户内码", name = "custIsn")
    @Excel(name = "客户内码")
    private String custIsn;

    @ApiModelProperty(value = "电话号码", name = "phoneNum")
    @Excel(name = "电话号码")
    private String phoneNum;

    @ApiModelProperty(value = "柜员号", name = "userName")
    @Excel(name = "柜员号*", prompt = "必填")
    private String userName;

    public void checkValid() {
        if (Objects.isNull(CustTypeEnum.getByName(custType))) {
            throw new ServiceException("客户类型错误！");
        }
        if (Objects.isNull(custId) || custId.isEmpty()) {
            throw new ServiceException("客户号不能为空！");
        }
        if (Objects.isNull(userName) || userName.isEmpty()) {
            throw new ServiceException("柜员号不能为空");
        }
    }
}
