...
|
...
|
@@ -32,8 +32,11 @@ import com.yohoufo.user.cache.CacheService; |
|
|
import com.yohoufo.user.common.AlipayConfigInfo;
|
|
|
import com.yohoufo.user.component.CertPhotoSwitchComponent;
|
|
|
import com.yohoufo.user.helper.HideDataUtil;
|
|
|
import com.yohoufo.user.requestVO.PhotoCheckResultVO;
|
|
|
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
|
|
|
import com.yohoufo.user.service.IRealNameAuthorizeService;
|
|
|
import lombok.Data;
|
|
|
import lombok.ToString;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -368,13 +371,9 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String,Object> zhiMaCertPhotoCheck(RealNameAuthorizeReqVO reqVO){
|
|
|
public PhotoCheckResultVO zhiMaCertPhotoCheck(RealNameAuthorizeReqVO reqVO){
|
|
|
//每天:记录一个累加的次数 ,超过一定的数量不允许继续调
|
|
|
String dayStr = getStringDate("yyyyMMdd");
|
|
|
if(isPhotoCheckExceedLimit(dayStr,reqVO.getUid())){
|
|
|
throw new UfoServiceException(400, "今日的认证次数已经用完!");
|
|
|
}
|
|
|
|
|
|
ImageBO frontUploadModel=new ImageBO();
|
|
|
frontUploadModel.setImageSide("front");
|
|
|
frontUploadModel.setImageUrl(reqVO.getFrontImageUrl());
|
...
|
...
|
@@ -382,15 +381,61 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
backUploadModel.setImageSide("back");
|
|
|
backUploadModel.setImageUrl(reqVO.getBackImageUrl());
|
|
|
//调用接口,ocr验证
|
|
|
CertPhotoEnum certPhotoCheckResult = checkCertPhoto(dayStr,Lists.newArrayList(frontUploadModel ,backUploadModel) ,reqVO);
|
|
|
PhotoCheckResultVO certPhotoCheckResult = checkCertPhoto(dayStr,Lists.newArrayList(frontUploadModel ,backUploadModel) ,reqVO);
|
|
|
return certPhotoCheckResult;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 调用通用的图片验证ocr
|
|
|
* @param imageBOList
|
|
|
* @param reqVO
|
|
|
* @return
|
|
|
*/
|
|
|
private PhotoCheckResultVO checkCertPhoto(String dayStr,List<ImageBO> imageBOList,RealNameAuthorizeReqVO reqVO){
|
|
|
if(isPhotoCheckExceedLimit(dayStr,reqVO.getUid())){
|
|
|
throw new UfoServiceException(400, "今日的认证次数已经用完!");
|
|
|
}
|
|
|
PhotoCheckResultVO result=new PhotoCheckResultVO();
|
|
|
result.setPass(false);
|
|
|
|
|
|
try{
|
|
|
ImageReviewedReq req=new ImageReviewedReq();
|
|
|
req.setUid(reqVO.getUid());
|
|
|
req.setImageBOList(imageBOList);
|
|
|
req.setBusinessLine("ufo");
|
|
|
req.setSceneName("SELLER_IDCARD_RECOGNIZE");
|
|
|
req.setContext(contextPath);
|
|
|
|
|
|
//调用校验,然后直接返回
|
|
|
logger.info("checkCertPhoto call begin reqVO {} ,req {}",reqVO, JSON.toJSONString(req));
|
|
|
|
|
|
//如果图像认证开关关闭,直接返回成功
|
|
|
boolean open = certPhotoSwitchComponent.getCertPhotoSwitch();
|
|
|
if(!open){
|
|
|
logger.info("zhiMaCertPhotoCheck switch is {},reqVO {} ",open,reqVO);
|
|
|
result.setPass(CertPhotoEnum.valid_but_uncheck.isCheckPass());
|
|
|
result.setPhotoValidStatus(CertPhotoEnum.valid_but_uncheck.getStatus());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//次数加1
|
|
|
long num = cacheService.incrementPhotoCheckCount(dayStr,reqVO.getUid());
|
|
|
logger.info("checkCertPhoto call begin reqVO {} ,call redis count {}",reqVO, num);
|
|
|
|
|
|
ImageReviewResp resp =null;
|
|
|
logger.info("checkCertPhoto call end reqVO {} ,req {} ,resp {} ",reqVO,JSON.toJSONString(req),JSON.toJSONString(resp));
|
|
|
//比较信息
|
|
|
|
|
|
}catch (Exception e){
|
|
|
logger.warn("checkCertPhoto error reqVO {}",reqVO,e);
|
|
|
throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
|
|
|
}
|
|
|
|
|
|
Map<String,Object> map= Maps.newHashMap();
|
|
|
map.put("pass",certPhotoCheckResult.isCheckPass());
|
|
|
map.put("photoValidStatus",certPhotoCheckResult.getStatus());
|
|
|
return map;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
@Deprecated
|
|
|
@Override
|
...
|
...
|
@@ -436,47 +481,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
}
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* 调用通用的图片验证ocr
|
|
|
* @param imageBOList
|
|
|
* @param reqVO
|
|
|
* @return
|
|
|
*/
|
|
|
private CertPhotoEnum checkCertPhoto(String dayStr,List<ImageBO> imageBOList,RealNameAuthorizeReqVO reqVO){
|
|
|
try{
|
|
|
ImageReviewedReq req=new ImageReviewedReq();
|
|
|
req.setUid(reqVO.getUid());
|
|
|
req.setImageBOList(imageBOList);
|
|
|
req.setBusinessLine("ufo");
|
|
|
req.setSceneName("SELLER_IDCARD_RECOGNIZE");
|
|
|
req.setContext(contextPath);
|
|
|
|
|
|
//调用校验,然后直接返回
|
|
|
logger.info("checkCertPhoto call begin reqVO {} ,req {}",reqVO, JSON.toJSONString(req));
|
|
|
|
|
|
//如果图像认证开关关闭,直接返回成功
|
|
|
boolean open = certPhotoSwitchComponent.getCertPhotoSwitch();
|
|
|
if(!open){
|
|
|
logger.info("zhiMaCertPhotoCheck switch is {},reqVO {} ",open,reqVO);
|
|
|
return CertPhotoEnum.valid_but_uncheck;
|
|
|
}
|
|
|
|
|
|
//次数加1
|
|
|
long num = cacheService.incrementPhotoCheckCount(dayStr,reqVO.getUid());
|
|
|
logger.info("checkCertPhoto call begin reqVO {} ,call redis count {}",reqVO, num);
|
|
|
|
|
|
ImageReviewResp resp =null;
|
|
|
logger.info("checkCertPhoto call end reqVO {} ,req {} ,resp {} ",reqVO,JSON.toJSONString(req),JSON.toJSONString(resp));
|
|
|
//比较信息
|
|
|
|
|
|
}catch (Exception e){
|
|
|
logger.warn("checkCertPhoto error reqVO {}",reqVO,e);
|
|
|
throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
|
|
|
}
|
|
|
|
|
|
return CertPhotoEnum.valid;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
public ImageBO getUploadImagePath(MultipartFile multipartFile, String bucket, String uid, Integer limitType) throws Exception {
|
|
|
//文件为空
|
...
|
...
|
@@ -555,7 +559,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
|
|
|
|
|
|
@Override
|
|
|
public AuthorizeResultRespVO zhiMaCertWithPhotoInit(RealNameAuthorizeReqVO reqVO){
|
|
|
public AuthorizeResultRespVO zhiMaCertWithPhotoInit(RealNameAuthorizeReqVO reqVO,boolean ocrPhotoCheck){
|
|
|
logger.info("real name zhiMaCertWithPhotoInit reqVO {}", reqVO);
|
|
|
boolean justCheckPhoto = false;
|
|
|
int uid = reqVO.getUid();
|
...
|
...
|
@@ -577,6 +581,17 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
|
|
|
logger.info("real name zhiMaCertWithPhotoInit reqVO {} ,justCheckPhoto {}", reqVO,justCheckPhoto);
|
|
|
|
|
|
if(ocrPhotoCheck){
|
|
|
//验证图片
|
|
|
PhotoCheckResultVO photoCheckResultVO = this.zhiMaCertPhotoCheck(reqVO);
|
|
|
if(photoCheckResultVO.isPass()){
|
|
|
//根据校验结果,重设photo_valid_status
|
|
|
reqVO.setPhotoValidStatus(photoCheckResultVO.getPhotoValidStatus());
|
|
|
}else{
|
|
|
throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String imgUrl = reqVO.getFrontImageUrl()+","+reqVO.getBackImageUrl();
|
|
|
|
|
|
if(justCheckPhoto){
|
...
|
...
|
|