Authored by qinchao

认证

... ... @@ -7,6 +7,7 @@ import com.yoho.service.model.reviewed.request.ImageBO;
import com.yoho.service.model.reviewed.request.ImageReviewedReq;
import com.yoho.service.model.reviewed.response.ImageReviewResp;
import com.yoho.service.model.sms.response.CommonRspBO;
import com.yoho.tools.common.beans.Response;
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -14,6 +15,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
... ... @@ -36,8 +41,8 @@ public class OcrCertPhotoService {
@Value("${yoho.reviewed.controller.url}")
private String messageUrl;
public ImageReviewResp ocrCheck(RealNameAuthorizeReqVO reqVO , List<ImageBO> imageBOList) {
ImageReviewResp respVo = null;
public Response<ImageReviewResp> ocrCheck(RealNameAuthorizeReqVO reqVO , List<ImageBO> imageBOList) {
Response<ImageReviewResp> respVo = null;
try{
int uid= reqVO.getUid();
ImageReviewedReq req=new ImageReviewedReq();
... ... @@ -52,7 +57,14 @@ public class OcrCertPhotoService {
String url = messageUrl + "/imageAudit/imageAudit";
logger.info("sendMessage url is {}", url);
respVo=restTemplate.postForObject(url, req, ImageReviewResp.class);
//respVo=restTemplate.postForObject(url, req, Response.class);
ParameterizedTypeReference<Response<ImageReviewResp>> typeRef = new ParameterizedTypeReference<Response<ImageReviewResp>>() {};
HttpEntity httpEntity = new HttpEntity(req);
ResponseEntity<Response<ImageReviewResp>> responseEntity = restTemplate.exchange(url, HttpMethod.POST,httpEntity, typeRef);
respVo = responseEntity.getBody();
}catch (Exception e){
logger.warn("OcrCertPhotoService ocrCheck error ",e);
}
... ...
... ... @@ -21,6 +21,7 @@ import com.yoho.service.model.reviewed.request.ImageReviewedReq;
import com.yoho.service.model.reviewed.response.IdCardRspBO;
import com.yoho.service.model.reviewed.response.ImageReviewResp;
import com.yoho.tools.common.beans.ApiResponse;
import com.yoho.tools.common.beans.Response;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.constant.CertPhotoEnum;
import com.yohoufo.common.exception.GatewayException;
... ... @@ -417,17 +418,22 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
long num = cacheService.incrementPhotoCheckCount(dayStr,reqVO.getUid());
logger.info("checkCertPhoto call begin reqVO {} ,call redis count {}",reqVO, num);
ImageReviewResp resp =ocrCertPhotoService.ocrCheck(reqVO,imageBOList);
logger.info("checkCertPhoto call end reqVO {} ,resp {} ",reqVO,JSON.toJSONString(resp));
Response<ImageReviewResp> imageReviewRespResponse =ocrCertPhotoService.ocrCheck(reqVO,imageBOList);
logger.info("checkCertPhoto call end reqVO {} ,resp {} ",reqVO,JSON.toJSONString(imageReviewRespResponse));
if(resp==null||!"success".equals(resp.getResultCode())){
result.setMessage("验证失败,您上传的证件照片信息不正确");
if(imageReviewRespResponse==null||imageReviewRespResponse.getCode()!=200){
result.setMessage("验证图片异常,请重试!");
}else{
ImageReviewResp reviewResp = imageReviewRespResponse.getData();
if(reviewResp==null||!"success".equals(reviewResp.getResultCode())){
throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
}
//比较信息
JSONObject jo = JSON.parseObject(resp.getResultDatas());
JSONObject jo = JSON.parseObject(reviewResp.getResultDatas());
if(jo!=null&&jo.containsKey("front")&&jo.containsKey("back")){
IdCardRspBO front = jo.getObject("front",IdCardRspBO.class);
IdCardRspBO back = jo.getObject("back",IdCardRspBO.class);
IdCardRspBO front = JSON.parseObject(jo.getJSONObject("front").getString("resultData"),IdCardRspBO.class);
IdCardRspBO back = JSON.parseObject(jo.getJSONObject("back").getString("resultData"),IdCardRspBO.class);
if(front!=null&&back!=null){
logger.info("checkCertPhoto front {} ,back {}",front,back);
String endData = back.getEndDate();
... ... @@ -435,9 +441,9 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
throw new UfoServiceException(400, "身份证照片有效期不合法!");
}
endData = endData.trim();
if(!"长期".equals(endData)){
if(!endData.contains("长期")){
//转日期
Date end = DateUtil.getDate(endData,"yyyy.MM.dd");
Date end = DateUtil.getDate(endData,"yyyyMMdd");
if(end==null||end.getTime() <= new Date().getTime()){
throw new UfoServiceException(400, "身份证照片不在有效期!");
}
... ... @@ -446,6 +452,10 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
||!reqVO.getCertNo().equals(front.getCode())){
throw new UfoServiceException(400, "名字或者身份证号不匹配!");
}
//验证成功
result.setPass(CertPhotoEnum.valid.isCheckPass());
result.setPhotoValidStatus(CertPhotoEnum.valid.getStatus());
}
}
... ...