|
@@ -32,8 +32,11 @@ import com.yohoufo.user.cache.CacheService; |
|
@@ -32,8 +32,11 @@ import com.yohoufo.user.cache.CacheService; |
32
|
import com.yohoufo.user.common.AlipayConfigInfo;
|
32
|
import com.yohoufo.user.common.AlipayConfigInfo;
|
33
|
import com.yohoufo.user.component.CertPhotoSwitchComponent;
|
33
|
import com.yohoufo.user.component.CertPhotoSwitchComponent;
|
34
|
import com.yohoufo.user.helper.HideDataUtil;
|
34
|
import com.yohoufo.user.helper.HideDataUtil;
|
|
|
35
|
+import com.yohoufo.user.requestVO.PhotoCheckResultVO;
|
35
|
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
|
36
|
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
|
36
|
import com.yohoufo.user.service.IRealNameAuthorizeService;
|
37
|
import com.yohoufo.user.service.IRealNameAuthorizeService;
|
|
|
38
|
+import lombok.Data;
|
|
|
39
|
+import lombok.ToString;
|
37
|
import org.apache.commons.lang.StringUtils;
|
40
|
import org.apache.commons.lang.StringUtils;
|
38
|
import org.slf4j.Logger;
|
41
|
import org.slf4j.Logger;
|
39
|
import org.slf4j.LoggerFactory;
|
42
|
import org.slf4j.LoggerFactory;
|
|
@@ -368,13 +371,9 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -368,13 +371,9 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
368
|
}
|
371
|
}
|
369
|
|
372
|
|
370
|
@Override
|
373
|
@Override
|
371
|
- public Map<String,Object> zhiMaCertPhotoCheck(RealNameAuthorizeReqVO reqVO){
|
374
|
+ public PhotoCheckResultVO zhiMaCertPhotoCheck(RealNameAuthorizeReqVO reqVO){
|
372
|
//每天:记录一个累加的次数 ,超过一定的数量不允许继续调
|
375
|
//每天:记录一个累加的次数 ,超过一定的数量不允许继续调
|
373
|
String dayStr = getStringDate("yyyyMMdd");
|
376
|
String dayStr = getStringDate("yyyyMMdd");
|
374
|
- if(isPhotoCheckExceedLimit(dayStr,reqVO.getUid())){
|
|
|
375
|
- throw new UfoServiceException(400, "今日的认证次数已经用完!");
|
|
|
376
|
- }
|
|
|
377
|
-
|
|
|
378
|
ImageBO frontUploadModel=new ImageBO();
|
377
|
ImageBO frontUploadModel=new ImageBO();
|
379
|
frontUploadModel.setImageSide("front");
|
378
|
frontUploadModel.setImageSide("front");
|
380
|
frontUploadModel.setImageUrl(reqVO.getFrontImageUrl());
|
379
|
frontUploadModel.setImageUrl(reqVO.getFrontImageUrl());
|
|
@@ -382,15 +381,61 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -382,15 +381,61 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
382
|
backUploadModel.setImageSide("back");
|
381
|
backUploadModel.setImageSide("back");
|
383
|
backUploadModel.setImageUrl(reqVO.getBackImageUrl());
|
382
|
backUploadModel.setImageUrl(reqVO.getBackImageUrl());
|
384
|
//调用接口,ocr验证
|
383
|
//调用接口,ocr验证
|
385
|
- CertPhotoEnum certPhotoCheckResult = checkCertPhoto(dayStr,Lists.newArrayList(frontUploadModel ,backUploadModel) ,reqVO);
|
384
|
+ PhotoCheckResultVO certPhotoCheckResult = checkCertPhoto(dayStr,Lists.newArrayList(frontUploadModel ,backUploadModel) ,reqVO);
|
|
|
385
|
+ return certPhotoCheckResult;
|
|
|
386
|
+ }
|
|
|
387
|
+
|
|
|
388
|
+ /**
|
|
|
389
|
+ * 调用通用的图片验证ocr
|
|
|
390
|
+ * @param imageBOList
|
|
|
391
|
+ * @param reqVO
|
|
|
392
|
+ * @return
|
|
|
393
|
+ */
|
|
|
394
|
+ private PhotoCheckResultVO checkCertPhoto(String dayStr,List<ImageBO> imageBOList,RealNameAuthorizeReqVO reqVO){
|
|
|
395
|
+ if(isPhotoCheckExceedLimit(dayStr,reqVO.getUid())){
|
|
|
396
|
+ throw new UfoServiceException(400, "今日的认证次数已经用完!");
|
|
|
397
|
+ }
|
|
|
398
|
+ PhotoCheckResultVO result=new PhotoCheckResultVO();
|
|
|
399
|
+ result.setPass(false);
|
|
|
400
|
+
|
|
|
401
|
+ try{
|
|
|
402
|
+ ImageReviewedReq req=new ImageReviewedReq();
|
|
|
403
|
+ req.setUid(reqVO.getUid());
|
|
|
404
|
+ req.setImageBOList(imageBOList);
|
|
|
405
|
+ req.setBusinessLine("ufo");
|
|
|
406
|
+ req.setSceneName("SELLER_IDCARD_RECOGNIZE");
|
|
|
407
|
+ req.setContext(contextPath);
|
|
|
408
|
+
|
|
|
409
|
+ //调用校验,然后直接返回
|
|
|
410
|
+ logger.info("checkCertPhoto call begin reqVO {} ,req {}",reqVO, JSON.toJSONString(req));
|
|
|
411
|
+
|
|
|
412
|
+ //如果图像认证开关关闭,直接返回成功
|
|
|
413
|
+ boolean open = certPhotoSwitchComponent.getCertPhotoSwitch();
|
|
|
414
|
+ if(!open){
|
|
|
415
|
+ logger.info("zhiMaCertPhotoCheck switch is {},reqVO {} ",open,reqVO);
|
|
|
416
|
+ result.setPass(CertPhotoEnum.valid_but_uncheck.isCheckPass());
|
|
|
417
|
+ result.setPhotoValidStatus(CertPhotoEnum.valid_but_uncheck.getStatus());
|
|
|
418
|
+ return result;
|
|
|
419
|
+ }
|
|
|
420
|
+
|
|
|
421
|
+ //次数加1
|
|
|
422
|
+ long num = cacheService.incrementPhotoCheckCount(dayStr,reqVO.getUid());
|
|
|
423
|
+ logger.info("checkCertPhoto call begin reqVO {} ,call redis count {}",reqVO, num);
|
|
|
424
|
+
|
|
|
425
|
+ ImageReviewResp resp =null;
|
|
|
426
|
+ logger.info("checkCertPhoto call end reqVO {} ,req {} ,resp {} ",reqVO,JSON.toJSONString(req),JSON.toJSONString(resp));
|
|
|
427
|
+ //比较信息
|
|
|
428
|
+
|
|
|
429
|
+ }catch (Exception e){
|
|
|
430
|
+ logger.warn("checkCertPhoto error reqVO {}",reqVO,e);
|
|
|
431
|
+ throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
|
|
|
432
|
+ }
|
386
|
|
433
|
|
387
|
- Map<String,Object> map= Maps.newHashMap();
|
|
|
388
|
- map.put("pass",certPhotoCheckResult.isCheckPass());
|
|
|
389
|
- map.put("photoValidStatus",certPhotoCheckResult.getStatus());
|
|
|
390
|
- return map;
|
434
|
+ return result;
|
391
|
}
|
435
|
}
|
392
|
|
436
|
|
393
|
|
437
|
|
|
|
438
|
+
|
394
|
/*
|
439
|
/*
|
395
|
@Deprecated
|
440
|
@Deprecated
|
396
|
@Override
|
441
|
@Override
|
|
@@ -436,47 +481,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -436,47 +481,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
436
|
}
|
481
|
}
|
437
|
*/
|
482
|
*/
|
438
|
|
483
|
|
439
|
- /**
|
|
|
440
|
- * 调用通用的图片验证ocr
|
|
|
441
|
- * @param imageBOList
|
|
|
442
|
- * @param reqVO
|
|
|
443
|
- * @return
|
|
|
444
|
- */
|
|
|
445
|
- private CertPhotoEnum checkCertPhoto(String dayStr,List<ImageBO> imageBOList,RealNameAuthorizeReqVO reqVO){
|
|
|
446
|
- try{
|
|
|
447
|
- ImageReviewedReq req=new ImageReviewedReq();
|
|
|
448
|
- req.setUid(reqVO.getUid());
|
|
|
449
|
- req.setImageBOList(imageBOList);
|
|
|
450
|
- req.setBusinessLine("ufo");
|
|
|
451
|
- req.setSceneName("SELLER_IDCARD_RECOGNIZE");
|
|
|
452
|
- req.setContext(contextPath);
|
|
|
453
|
-
|
|
|
454
|
- //调用校验,然后直接返回
|
|
|
455
|
- logger.info("checkCertPhoto call begin reqVO {} ,req {}",reqVO, JSON.toJSONString(req));
|
|
|
456
|
-
|
|
|
457
|
- //如果图像认证开关关闭,直接返回成功
|
|
|
458
|
- boolean open = certPhotoSwitchComponent.getCertPhotoSwitch();
|
|
|
459
|
- if(!open){
|
|
|
460
|
- logger.info("zhiMaCertPhotoCheck switch is {},reqVO {} ",open,reqVO);
|
|
|
461
|
- return CertPhotoEnum.valid_but_uncheck;
|
|
|
462
|
- }
|
|
|
463
|
-
|
|
|
464
|
- //次数加1
|
|
|
465
|
- long num = cacheService.incrementPhotoCheckCount(dayStr,reqVO.getUid());
|
|
|
466
|
- logger.info("checkCertPhoto call begin reqVO {} ,call redis count {}",reqVO, num);
|
|
|
467
|
-
|
|
|
468
|
- ImageReviewResp resp =null;
|
|
|
469
|
- logger.info("checkCertPhoto call end reqVO {} ,req {} ,resp {} ",reqVO,JSON.toJSONString(req),JSON.toJSONString(resp));
|
|
|
470
|
- //比较信息
|
|
|
471
|
-
|
|
|
472
|
- }catch (Exception e){
|
|
|
473
|
- logger.warn("checkCertPhoto error reqVO {}",reqVO,e);
|
|
|
474
|
- throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
|
|
|
475
|
- }
|
|
|
476
|
-
|
|
|
477
|
- return CertPhotoEnum.valid;
|
|
|
478
|
- }
|
|
|
479
|
-
|
|
|
480
|
/*
|
484
|
/*
|
481
|
public ImageBO getUploadImagePath(MultipartFile multipartFile, String bucket, String uid, Integer limitType) throws Exception {
|
485
|
public ImageBO getUploadImagePath(MultipartFile multipartFile, String bucket, String uid, Integer limitType) throws Exception {
|
482
|
//文件为空
|
486
|
//文件为空
|
|
@@ -555,7 +559,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -555,7 +559,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
555
|
|
559
|
|
556
|
|
560
|
|
557
|
@Override
|
561
|
@Override
|
558
|
- public AuthorizeResultRespVO zhiMaCertWithPhotoInit(RealNameAuthorizeReqVO reqVO){
|
562
|
+ public AuthorizeResultRespVO zhiMaCertWithPhotoInit(RealNameAuthorizeReqVO reqVO,boolean ocrPhotoCheck){
|
559
|
logger.info("real name zhiMaCertWithPhotoInit reqVO {}", reqVO);
|
563
|
logger.info("real name zhiMaCertWithPhotoInit reqVO {}", reqVO);
|
560
|
boolean justCheckPhoto = false;
|
564
|
boolean justCheckPhoto = false;
|
561
|
int uid = reqVO.getUid();
|
565
|
int uid = reqVO.getUid();
|
|
@@ -577,6 +581,17 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
@@ -577,6 +581,17 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
577
|
|
581
|
|
578
|
logger.info("real name zhiMaCertWithPhotoInit reqVO {} ,justCheckPhoto {}", reqVO,justCheckPhoto);
|
582
|
logger.info("real name zhiMaCertWithPhotoInit reqVO {} ,justCheckPhoto {}", reqVO,justCheckPhoto);
|
579
|
|
583
|
|
|
|
584
|
+ if(ocrPhotoCheck){
|
|
|
585
|
+ //验证图片
|
|
|
586
|
+ PhotoCheckResultVO photoCheckResultVO = this.zhiMaCertPhotoCheck(reqVO);
|
|
|
587
|
+ if(photoCheckResultVO.isPass()){
|
|
|
588
|
+ //根据校验结果,重设photo_valid_status
|
|
|
589
|
+ reqVO.setPhotoValidStatus(photoCheckResultVO.getPhotoValidStatus());
|
|
|
590
|
+ }else{
|
|
|
591
|
+ throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
|
|
|
592
|
+ }
|
|
|
593
|
+ }
|
|
|
594
|
+
|
580
|
String imgUrl = reqVO.getFrontImageUrl()+","+reqVO.getBackImageUrl();
|
595
|
String imgUrl = reqVO.getFrontImageUrl()+","+reqVO.getBackImageUrl();
|
581
|
|
596
|
|
582
|
if(justCheckPhoto){
|
597
|
if(justCheckPhoto){
|