1
|
package com.yohoufo.user.service.impl;
|
1
|
package com.yohoufo.user.service.impl;
|
2
|
|
2
|
|
3
|
|
3
|
|
|
|
4
|
+import com.alibaba.fastjson.JSON;
|
4
|
import com.alipay.api.AlipayApiException;
|
5
|
import com.alipay.api.AlipayApiException;
|
5
|
import com.alipay.api.AlipayClient;
|
6
|
import com.alipay.api.AlipayClient;
|
6
|
import com.alipay.api.DefaultAlipayClient;
|
7
|
import com.alipay.api.DefaultAlipayClient;
|
|
@@ -9,8 +10,11 @@ import com.alipay.api.request.AlipayUserInfoShareRequest; |
|
@@ -9,8 +10,11 @@ import com.alipay.api.request.AlipayUserInfoShareRequest; |
9
|
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
10
|
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
10
|
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
11
|
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
11
|
import com.alipay.api.response.ZhimaCustomerCertificationQueryResponse;
|
12
|
import com.alipay.api.response.ZhimaCustomerCertificationQueryResponse;
|
12
|
-import com.yoho.core.common.helpers.ImagesHelper;
|
13
|
+import com.google.common.collect.Lists;
|
13
|
import com.yoho.error.exception.ServiceException;
|
14
|
import com.yoho.error.exception.ServiceException;
|
|
|
15
|
+import com.yoho.service.model.reviewed.request.ImageBO;
|
|
|
16
|
+import com.yoho.service.model.reviewed.request.ImageReviewedReq;
|
|
|
17
|
+import com.yoho.service.model.reviewed.response.ImageReviewResp;
|
14
|
import com.yoho.tools.common.beans.ApiResponse;
|
18
|
import com.yoho.tools.common.beans.ApiResponse;
|
15
|
import com.yoho.tools.common.service.IQNUploadService;
|
19
|
import com.yoho.tools.common.service.IQNUploadService;
|
16
|
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
|
20
|
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
|
|
@@ -27,9 +31,7 @@ import com.yohoufo.user.common.AlipayConfigInfo; |
|
@@ -27,9 +31,7 @@ import com.yohoufo.user.common.AlipayConfigInfo; |
27
|
import com.yohoufo.user.helper.HideDataUtil;
|
31
|
import com.yohoufo.user.helper.HideDataUtil;
|
28
|
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
|
32
|
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
|
29
|
import com.yohoufo.user.service.IRealNameAuthorizeService;
|
33
|
import com.yohoufo.user.service.IRealNameAuthorizeService;
|
30
|
-import lombok.Data;
|
|
|
31
|
import org.apache.commons.codec.digest.DigestUtils;
|
34
|
import org.apache.commons.codec.digest.DigestUtils;
|
32
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
33
|
import org.apache.commons.lang.StringUtils;
|
35
|
import org.apache.commons.lang.StringUtils;
|
34
|
import org.slf4j.Logger;
|
36
|
import org.slf4j.Logger;
|
35
|
import org.slf4j.LoggerFactory;
|
37
|
import org.slf4j.LoggerFactory;
|
|
@@ -43,7 +45,6 @@ import java.awt.image.BufferedImage; |
|
@@ -43,7 +45,6 @@ import java.awt.image.BufferedImage; |
43
|
import java.io.File;
|
45
|
import java.io.File;
|
44
|
import java.io.FileNotFoundException;
|
46
|
import java.io.FileNotFoundException;
|
45
|
import java.io.IOException;
|
47
|
import java.io.IOException;
|
46
|
-import java.io.InputStream;
|
|
|
47
|
import java.text.DecimalFormat;
|
48
|
import java.text.DecimalFormat;
|
48
|
import java.text.SimpleDateFormat;
|
49
|
import java.text.SimpleDateFormat;
|
49
|
import java.time.LocalDateTime;
|
50
|
import java.time.LocalDateTime;
|
|
@@ -383,37 +384,61 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -383,37 +384,61 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
383
|
}
|
384
|
}
|
384
|
|
385
|
|
385
|
//循环获取file数组中得文件
|
386
|
//循环获取file数组中得文件
|
386
|
- UploadModel frontUploadModel=null;
|
|
|
387
|
- UploadModel backUploadModel=null;
|
387
|
+ ImageBO frontUploadModel=null;
|
|
|
388
|
+ ImageBO backUploadModel=null;
|
388
|
for (int i = 0; i < multipartFiles.length; i++) {
|
389
|
for (int i = 0; i < multipartFiles.length; i++) {
|
389
|
MultipartFile multipartFile = multipartFiles[i];
|
390
|
MultipartFile multipartFile = multipartFiles[i];
|
390
|
//保存文件
|
391
|
//保存文件
|
391
|
- UploadModel uploadModel = getUploadImagePath(multipartFile, bucket, String.valueOf(reqVO.getUid()), limitType);
|
|
|
392
|
- imgUrls.add(uploadModel.getImgUrl());
|
392
|
+ ImageBO tmpBO = getUploadImagePath(multipartFile, bucket, String.valueOf(reqVO.getUid()), limitType);
|
|
|
393
|
+ imgUrls.add(tmpBO.getImageUrl());
|
393
|
if(i==0){
|
394
|
if(i==0){
|
394
|
- frontUploadModel = uploadModel;
|
395
|
+ tmpBO.setImageSide("front");
|
|
|
396
|
+ frontUploadModel = tmpBO;
|
395
|
}else{
|
397
|
}else{
|
396
|
- backUploadModel = uploadModel;
|
398
|
+ tmpBO.setImageSide("back");
|
|
|
399
|
+ backUploadModel = tmpBO;
|
397
|
}
|
400
|
}
|
398
|
}
|
401
|
}
|
399
|
//调用接口,ocr验证
|
402
|
//调用接口,ocr验证
|
400
|
- boolean pass = checkCertPhoto(frontUploadModel ,backUploadModel ,reqVO);
|
403
|
+ boolean pass = checkCertPhoto(Lists.newArrayList(frontUploadModel ,backUploadModel) ,reqVO);
|
401
|
if(!pass){
|
404
|
if(!pass){
|
402
|
throw new GatewayException(400, "身份证图片校验不通过!");
|
405
|
throw new GatewayException(400, "身份证图片校验不通过!");
|
403
|
}
|
406
|
}
|
404
|
- //删除图片
|
|
|
405
|
- frontUploadModel.getUploadFile().delete();
|
|
|
406
|
- backUploadModel.getUploadFile().delete();
|
407
|
+
|
407
|
return imgUrls;
|
408
|
return imgUrls;
|
408
|
}
|
409
|
}
|
409
|
|
410
|
|
410
|
- @Data
|
|
|
411
|
- static class UploadModel{
|
|
|
412
|
- File uploadFile ;
|
|
|
413
|
- String imgUrl;
|
411
|
+ /**
|
|
|
412
|
+ * 调用通用的图片验证ocr
|
|
|
413
|
+ * @param imageBOList
|
|
|
414
|
+ * @param reqVO
|
|
|
415
|
+ * @return
|
|
|
416
|
+ */
|
|
|
417
|
+ private boolean checkCertPhoto(List<ImageBO> imageBOList,RealNameAuthorizeReqVO reqVO){
|
|
|
418
|
+ try{
|
|
|
419
|
+ ImageReviewedReq req=new ImageReviewedReq();
|
|
|
420
|
+ req.setUid(reqVO.getUid());
|
|
|
421
|
+ req.setImageBOList(imageBOList);
|
|
|
422
|
+
|
|
|
423
|
+ //调用校验,然后直接返回
|
|
|
424
|
+ logger.info("checkCertPhoto call begin reqVO {} ,req {}",reqVO, JSON.toJSONString(req));
|
|
|
425
|
+
|
|
|
426
|
+ ImageReviewResp resp =null;
|
|
|
427
|
+ logger.info("checkCertPhoto call end reqVO {} ,req {} ,resp {} ",reqVO,JSON.toJSONString(req),JSON.toJSONString(resp));
|
|
|
428
|
+ //比较信息
|
|
|
429
|
+
|
|
|
430
|
+ }catch (Exception e){
|
|
|
431
|
+ logger.warn("checkCertPhoto error reqVO {}",reqVO,e);
|
|
|
432
|
+ throw new UfoServiceException(400,"图片检查异常");
|
|
|
433
|
+ }finally {
|
|
|
434
|
+ //无论成功与否,都删除本地文件
|
|
|
435
|
+ imageBOList.forEach(bo->bo.getFile().delete());
|
|
|
436
|
+ }
|
|
|
437
|
+
|
|
|
438
|
+ return true;
|
414
|
}
|
439
|
}
|
415
|
|
440
|
|
416
|
- public UploadModel getUploadImagePath(MultipartFile multipartFile, String bucket, String uid, Integer limitType) throws Exception {
|
441
|
+ public ImageBO getUploadImagePath(MultipartFile multipartFile, String bucket, String uid, Integer limitType) throws Exception {
|
417
|
//文件为空
|
442
|
//文件为空
|
418
|
if (multipartFile.isEmpty()) {
|
443
|
if (multipartFile.isEmpty()) {
|
419
|
logger.warn("upload file is empty");
|
444
|
logger.warn("upload file is empty");
|
|
@@ -457,9 +482,9 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -457,9 +482,9 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
457
|
|
482
|
|
458
|
String imgUrl = iqnUploadService.upload(uploadFile, bucket, saveName + fileName);
|
483
|
String imgUrl = iqnUploadService.upload(uploadFile, bucket, saveName + fileName);
|
459
|
|
484
|
|
460
|
- UploadModel uploadModel = new UploadModel();
|
|
|
461
|
- uploadModel.setUploadFile(uploadFile);
|
|
|
462
|
- uploadModel.setImgUrl(imgUrl);
|
485
|
+ ImageBO uploadModel = new ImageBO();
|
|
|
486
|
+ uploadModel.setFile(uploadFile);
|
|
|
487
|
+ uploadModel.setImageUrl(imgUrl);
|
463
|
///// uploadFile.delete(); 暂时先不删除,等身份证校验完毕再删
|
488
|
///// uploadFile.delete(); 暂时先不删除,等身份证校验完毕再删
|
464
|
return uploadModel;
|
489
|
return uploadModel;
|
465
|
}
|
490
|
}
|
|
@@ -529,10 +554,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -529,10 +554,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
529
|
return vo;
|
554
|
return vo;
|
530
|
}
|
555
|
}
|
531
|
|
556
|
|
532
|
- private boolean checkCertPhoto(UploadModel frontUploadModel,UploadModel backUploadModel,RealNameAuthorizeReqVO reqVO){
|
|
|
533
|
-
|
|
|
534
|
- return true;
|
|
|
535
|
- }
|
|
|
536
|
|
557
|
|
537
|
@Override
|
558
|
@Override
|
538
|
public AuthorizeResultRespVO zhiMaCertInit(RealNameAuthorizeReqVO reqVO) {
|
559
|
public AuthorizeResultRespVO zhiMaCertInit(RealNameAuthorizeReqVO reqVO) {
|