package com.trade.service.contract.util.esign.entity;

import java.io.Serializable;

import com.trade.service.contract.dto.ContractSigner;
import com.trade.service.contract.util.esign.ESignConfig;
import org.apache.commons.lang3.StringUtils;



/**
 * 个人账户实体类
 */
public class ESignPersonAccount implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * required 用户唯一标识，可传入第三方平台的个人用户id、证件号、手机号、邮箱等，如果设置则作为账号唯一性字段， <br>
     * 相同信息不可重复创建。（个人用户与机构的唯一标识不可重复）
     */
    private String thirdPartyUserId;
    /** 姓名 required */
    private String name;
    /**
     * 证件类型：默认CRED_PSN_CH_IDCARD （大陆身份证）
     **/
    private String idType = "CRED_PSN_CH_IDCARD";
    /**
     * 证件号，默认为空，发起签署前需确保补齐证件号
     */
    private String idNumber;
    /**
     * 手机号码，默认空，手机号为空时无法使用短信意愿认证
     */
    private String mobile;
    /**
     * 邮箱地址，默认空
     */
    private String email;

    public ESignPersonAccount(){
    }

    public ESignPersonAccount(ContractSigner signerInfo){
        if (null != signerInfo) {
            this.thirdPartyUserId = ESignConfig.getPersonThirdPartyUserId(signerInfo.getSignerIdNo());
            this.name = signerInfo.getSigner();
            this.idNumber = signerInfo.getSignerIdNo();
            this.idType = signerInfo.getSignerIdType();
            if (StringUtils.isNotBlank(signerInfo.getMobile())) {
                this.mobile = signerInfo.getMobile();
            }
            if (StringUtils.isNotBlank(signerInfo.getEmail())) {
                this.email = signerInfo.getEmail();
            }
        }
    }

    public ESignPersonAccount(String signerIdNumber, String signerName, String signerIdType, String signerMobile) {
        this.thirdPartyUserId = ESignConfig.getPersonThirdPartyUserId(signerIdNumber);
        this.name = signerName;
        this.idNumber = signerIdNumber;
        this.idType = signerIdType;
        this.mobile = signerMobile;
    }


    public String getThirdPartyUserId() {
        return thirdPartyUserId;
    }

    public void setThirdPartyUserId(String thirdPartyUserId) {
        this.thirdPartyUserId = thirdPartyUserId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIdType() {
        return idType;
    }

    public void setIdType(String idType) {
        this.idType = idType;
    }

    public String getIdNumber() {
        return idNumber;
    }

    public void setIdNumber(String idNumber) {
        this.idNumber = idNumber;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}
