package cn.pluss.platform.dto;

import cn.pluss.platform.constants.CommonError;
import cn.pluss.platform.exception.MsgException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * @author djh
 *
 */
@Data
public class BankInfoDTO {
	
	@ApiModelProperty(value="当前用户Id")
	private String userId;
	
	@ApiModelProperty(value="开户银行")
	private String bankName;
	
	@ApiModelProperty(value="银行省市区编码")
	private String bankAddressNo;

	private String branchProvince;

	private String branchCity;

	private String branchArea;
	
	@ApiModelProperty(value="开户地区")
	private String bankAddress;
	
	@ApiModelProperty(value="开户支行")
	private String branchName;
	
	@ApiModelProperty(value="联行号")
	private String contactLine;
	
	@ApiModelProperty(value="银行卡号")
	private String  bankCardNo;
	
	@ApiModelProperty(value="银行预留号码")
	private String phone;
	
	@ApiModelProperty(value="银行卡照片")
	private String bankCardFrontPic;

	private String imgUrl;
	
	@ApiModelProperty(value="账户类型。可选值： 1：对私账户（自然人、个体工商户可选）\\r\\n   2：对公账户")
	private String accountType;

	public void paramCheck() {
		MsgException.checkBlank(userId, CommonError.NO_USER_ID);
		//TODO 账户类型先放开
		//MsgException.checkBlank(accountType, "请选择账户类型");

		// 为了维持老接口的稳定性，添加参数转换
		if ("1".equals(accountType)) {
			accountType = "01";
		}
		if ("2".equals(accountType)) {
			accountType = "02";
		}

		MsgException.checkBlank(bankName, "开户银行不能为空");
		MsgException.checkBlank(branchName, "开户支行不能为空");
		MsgException.checkBlank(bankCardNo, "银行卡号不能为空");
		MsgException.checkBlank(phone, "银行预留号码不能为空");
		MsgException.checkBlank(contactLine, "联行号不能为空");
		MsgException.checkBlank(userId, "银行卡照片不能为空");
		MsgException.checkBlank(userId, "缺少userId");
		MsgException.checkBlank(userId, "缺少userId");

		if(StringUtils.isEmpty(bankCardFrontPic) && StringUtils.isEmpty(imgUrl)) {
			throw new MsgException("银行卡照片不能为空");
		}
	}
	
}

