package cn.pluss.platform.dto;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.entity.MerchantBankCard;
import cn.pluss.platform.entity.MerchantBaseInfo;
import cn.pluss.platform.entity.MerchantImage;
import cn.pluss.platform.util.StringUtil;
import io.swagger.annotations.ApiModelProperty;

public class WechatMerchantAuditDTO {
	
	@ApiModelProperty(value="当前用户userId")
	private String userId;
	
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}


	public Result<Map<String, Object>> convertMap(MerchantBankCard merchantBankCard, MerchantBaseInfo merchantBaseInfo, List<MerchantImage> list){
		if(StringUtil.isEmpty(merchantBaseInfo.getProductDesc())) {
			return ResultGenerator.genFailResult("请选择售卖商品/提供服务描述");
		}
		if(StringUtil.isEmpty(merchantBaseInfo.getContactMobile())) {
			return ResultGenerator.genFailResult("联系人号码不能为空");
		}
		if(StringUtil.isEmpty(merchantBaseInfo.getAlias())) {
			return ResultGenerator.genFailResult("商户简称不能为空");
		}
		if(StringUtil.isEmpty(merchantBaseInfo.getAddressNo())) {
			return ResultGenerator.genFailResult("商户地址不能为空");
		}
		if(StringUtil.isEmpty(merchantBaseInfo.getAddress())) {
			return ResultGenerator.genFailResult("详细地址不能为空");
		}
		if(StringUtil.isEmpty(merchantBankCard.getBankName())) {
			return ResultGenerator.genFailResult("开户银行名称不能为空");
		}
		if(StringUtil.isEmpty(merchantBankCard.getBankCertName())) {
			return ResultGenerator.genFailResult("开户名称（与银行卡身份证一致）不能为空");
		}
		if(StringUtil.isEmpty(merchantBankCard.getBankCardNo())) {
			return ResultGenerator.genFailResult("银行卡号不能为空");
		}
		if(StringUtil.isEmpty(merchantBankCard.getBankAddressNo())) {
			return ResultGenerator.genFailResult("银行所在地区编码不能为空");
		}
		Map<String, Object> result=new HashMap<String, Object>(16);
		boolean isOne=true;boolean isTwo=true;boolean isSix=true;boolean isNine=true;
		for (MerchantImage merchantImage : list) {
			if("01".equals(merchantImage.getPhotoType())) {//身份证正面
				isOne=false;
				result.put("01", merchantImage.getPicUrl());
			}
			if("02".equals(merchantImage.getPhotoType())) {//身份证反面
				isTwo=false;
				result.put("02", merchantImage.getPicUrl());
			}
			if("06".equals(merchantImage.getPhotoType())) {//门头照
				isSix=false;
				result.put("06", merchantImage.getPicUrl());
			}
			if("09".equals(merchantImage.getPhotoType())) {//门店内景照片
				isNine=false;
				result.put("09", merchantImage.getPicUrl());
			}
		}
		if(isOne) {
			return ResultGenerator.genFailResult("请上传身份证正面照");
		}
		if(isTwo) {
			return ResultGenerator.genFailResult("请上传身份证反面");
		}
		if(isSix) {
			return ResultGenerator.genFailResult("请上传门头照");
		}
		if(isNine) {
			return ResultGenerator.genFailResult("请上传门店内景照片");
		}
		return ResultGenerator.genSuccessResult(result);
	}
	
	
	

}
