|
@@ -19,12 +19,15 @@ import com.tencentcloudapi.ocr.v20181119.OcrClient;
|
|
|
import com.tencentcloudapi.ocr.v20181119.models.*;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.modules.alioss.bo.OssRequest;
|
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.base.bo.UserProfileFit;
|
|
|
import com.zhongzheng.modules.base.bo.UserProfileQueryBo;
|
|
|
import com.zhongzheng.modules.base.service.IUserProfileService;
|
|
|
import com.zhongzheng.modules.base.vo.UserProfileVo;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
+import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
|
|
|
import com.zhongzheng.modules.tencentcloud.bo.InvoiceQueryBo;
|
|
|
import com.zhongzheng.modules.tencentcloud.service.IFaceOcrService;
|
|
@@ -72,6 +75,9 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
@Autowired
|
|
|
private IUserProfileService iUserProfileService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysTenantService iSysTenantService;
|
|
|
+
|
|
|
private static Logger log = LoggerFactory.getLogger(FaceOcrServiceImpl.class);
|
|
|
/**
|
|
|
* 学习拍照比对
|
|
@@ -107,7 +113,12 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
// String oneInchPhotos = JSONObject.parseObject(String.valueOf(maps.get("recent_photos")), UserProfileFit.class).getValue(); //审核资料一寸照片
|
|
|
if(DetectFace(bo)){
|
|
|
//活体检测
|
|
|
- detectLiveFaceCheck(bo);
|
|
|
+ String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
+ SysTenant tenant = iSysTenantService.getById(Long.valueOf(tenantId));
|
|
|
+ if (ObjectUtils.isNotNull(tenant) && tenant.getDetectLiveSign() == 1){
|
|
|
+ //机构开启活体检测
|
|
|
+ detectLiveFaceCheck(bo);
|
|
|
+ }
|
|
|
String oneInchPhotos =ossHost+"/"+userVo.getOneInchPhotos();
|
|
|
Credential cred = new Credential(SecretId, SecretKey);
|
|
|
ClientProfile clientProfile = new ClientProfile();
|
|
@@ -148,8 +159,8 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
}
|
|
|
try {
|
|
|
DetectLiveFaceResponse response = iaiClient.DetectLiveFace(faceRequest);
|
|
|
- if (response.getScore().intValue() < 87){
|
|
|
- addUserPhotoRecord(bo.getUserId(),bo.getUrlA(),bo.getOrderGoodsId(),3,bo.getDeviceName());
|
|
|
+ if (response.getIsLiveness()){
|
|
|
+ addUserPhotoRecord(bo.getUserId(),bo.getUrlA(),bo.getOrderGoodsId(),3,bo.getDeviceName()+",活体检测分数:"+response.getScore());
|
|
|
throw new CustomException("活体检测不通过,请重新拍照!",606);
|
|
|
}
|
|
|
}catch (TencentCloudSDKException e){
|
|
@@ -158,6 +169,26 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public Integer detectLiveFaceCheckTwo(String url) {
|
|
|
+ Credential cred = new Credential(SecretId, SecretKey);
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
+ clientProfile.setSignMethod(clientProfile.SIGN_TC3_256);
|
|
|
+ IaiClient iaiClient = new IaiClient(cred,"ap-guangzhou");
|
|
|
+ DetectLiveFaceRequest faceRequest = new DetectLiveFaceRequest();
|
|
|
+ faceRequest.setUrl(url);
|
|
|
+ try {
|
|
|
+ DetectLiveFaceResponse response = iaiClient.DetectLiveFace(faceRequest);
|
|
|
+ if (response.getScore().intValue() < 87){
|
|
|
+ throw new CustomException("活体检测不通过,请重新拍照!活体检测分数:"+response.getScore().intValue(),606);
|
|
|
+ }
|
|
|
+ return response.getScore().intValue();
|
|
|
+ }catch (TencentCloudSDKException e){
|
|
|
+ throw new CustomException(e.getMessage(),606);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//保存学员拍照错误记录
|
|
|
private void addUserPhotoRecord(Long userId,String photo,Long orderGoodsId,Integer type,String deviceName){
|
|
|
UserPhotoDevice add = new UserPhotoDevice();
|
|
@@ -175,8 +206,9 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
private void deviceCheck(FaceQueryBo bo) {
|
|
|
//校验白黑名单
|
|
|
UserDeviceWhite deviceWhite = iUserDeviceWhiteService.getOne(new LambdaQueryWrapper<UserDeviceWhite>()
|
|
|
- .eq(UserDeviceWhite::getUserId, bo.getUserId())
|
|
|
- .eq(UserDeviceWhite::getDeviceName, bo.getDeviceName()));
|
|
|
+// .eq(UserDeviceWhite::getUserId, bo.getUserId())
|
|
|
+ .eq(UserDeviceWhite::getDeviceName, bo.getDeviceName())
|
|
|
+ .last("limit 1"));
|
|
|
if (ObjectUtils.isNotNull(deviceWhite)){
|
|
|
if (deviceWhite.getStatus() == 1){
|
|
|
//白名单
|