package cn.pluss.platform.dto;

import java.util.List;

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

/**
 * @author yuchen
 *
 * @Description 
 * 支付宝进件dto
 */
@Data
public class AliMerchantAuditDTO {
	
	@ApiModelProperty(value="当前用户的userId")
	private Integer userId;
	
	public Result<MerchantBaseInfo> convertMerchantBaseInfo(MerchantBaseInfo merchantBaseInfo) {
		if(StringUtil.isEmpty(merchantBaseInfo.getAliAccount())) {
			return ResultGenerator.genFailResult("支付宝账号不能为空");
		}
		if(StringUtil.isEmpty(merchantBaseInfo.getContactName())||StringUtil.isEmpty(merchantBaseInfo.getContactMobile())||StringUtil.isEmpty(merchantBaseInfo.getEmail())||StringUtil.isEmpty(merchantBaseInfo.getAliMcc())) {
			return ResultGenerator.genFailResult("请先完善商户基本资料");
		}
		if(StringUtil.isEmpty(merchantBaseInfo.getBussAuthNum())){
			return ResultGenerator.genFailResult("请先上传营业执照");
		}
		return ResultGenerator.genSuccessResult(merchantBaseInfo);
	}
	
	public Result<BatchInfoDTO> convertBatchInfoDTO(List<MerchantImage> list, MerchantBaseInfo merchantBaseInfo) {
		BatchInfoDTO batch = new BatchInfoDTO();
		batch.setMccCode(merchantBaseInfo.getAliMcc());
		batch.setBusinessLicenseNo(merchantBaseInfo.getBussAuthNum());
		for (MerchantImage merchantImage : list) {
			if("03".equals(merchantImage.getPhotoType())) {
				batch.setBusinessLicensePic(merchantImage.getPicUrl());
			}
			if("06".equals(merchantImage.getPhotoType())) {
				batch.setShopSignBoardPic(merchantImage.getPicUrl());
			}
		}
		if(StringUtil.isEmpty(batch.getBusinessLicensePic())) {
			return ResultGenerator.genFailResult("营业执照不能为空不能为空");
		}
		if(StringUtil.isEmpty(batch.getShopSignBoardPic())) {
			return ResultGenerator.genFailResult("门头照不能为空");
		}
		return ResultGenerator.genSuccessResult(batch);
	}

}

