...
|
...
|
@@ -11,7 +11,6 @@ import com.alipay.api.request.AlipayUserInfoShareRequest; |
|
|
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
|
|
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
|
|
import com.alipay.api.response.ZhimaCustomerCertificationQueryResponse;
|
|
|
import com.qiniu.util.Auth;
|
|
|
import com.yoho.core.cache.LocalCache;
|
|
|
import com.yoho.core.config.ConfigReader;
|
|
|
import com.yoho.error.exception.ServiceException;
|
...
|
...
|
@@ -79,12 +78,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
@Autowired
|
|
|
private ConfigReader configReader;
|
|
|
|
|
|
//@Value("${file.saveDir}")
|
|
|
//private String saveDir="D:/pic";
|
|
|
|
|
|
//@Autowired
|
|
|
//private IQNUploadService iqnUploadService;
|
|
|
|
|
|
@Autowired
|
|
|
private OcrCertPhotoService ocrCertPhotoService;
|
|
|
|
...
|
...
|
@@ -354,10 +347,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
return dateString;
|
|
|
}
|
|
|
|
|
|
/*@Override
|
|
|
public boolean isPhotoCheckExceedLimit(Integer uid){
|
|
|
return isPhotoCheckExceedLimit(getStringDate("yyyyMMdd") ,uid);
|
|
|
}*/
|
|
|
|
|
|
private boolean isPhotoCheckExceedLimit(String dayStr ,Integer uid){
|
|
|
Long count = cacheService.getPhotoCheckCount(dayStr,uid);
|
...
|
...
|
@@ -478,130 +467,6 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
@Deprecated
|
|
|
@Override
|
|
|
public List<String> zhiMaCertUploadPhotoAndCheck(MultipartFile[] multipartFiles, String bucket, Integer limitType, RealNameAuthorizeReqVO reqVO) throws Exception{
|
|
|
List<String> imgUrls = new ArrayList<>();
|
|
|
//判断file数组不能为空并且长度大于0
|
|
|
if(multipartFiles==null||multipartFiles.length!=2){
|
|
|
throw new UfoServiceException(400, "请上传身份证正反面!");
|
|
|
}
|
|
|
|
|
|
//每天:记录一个累加的次数 ,超过一定的数量不允许继续调
|
|
|
String dayStr = getStringDate("yyyyMMdd");
|
|
|
if(isPhotoCheckExceedLimit(dayStr,reqVO.getUid())){
|
|
|
throw new UfoServiceException(400, "今日的认证次数已经用完!");
|
|
|
}
|
|
|
|
|
|
//次数加1
|
|
|
cacheService.incrementPhotoCheckCount(dayStr,reqVO.getUid());
|
|
|
|
|
|
//循环获取file数组中得文件
|
|
|
ImageBO frontUploadModel=null;
|
|
|
ImageBO backUploadModel=null;
|
|
|
for (int i = 0; i < multipartFiles.length; i++) {
|
|
|
MultipartFile multipartFile = multipartFiles[i];
|
|
|
//保存文件
|
|
|
ImageBO tmpBO = getUploadImagePath(multipartFile, bucket, String.valueOf(reqVO.getUid()), limitType);
|
|
|
imgUrls.add(tmpBO.getImageUrl());
|
|
|
if(i==0){
|
|
|
tmpBO.setImageSide("front");
|
|
|
frontUploadModel = tmpBO;
|
|
|
}else{
|
|
|
tmpBO.setImageSide("back");
|
|
|
backUploadModel = tmpBO;
|
|
|
}
|
|
|
}
|
|
|
//调用接口,ocr验证
|
|
|
boolean pass = checkCertPhoto(Lists.newArrayList(frontUploadModel ,backUploadModel) ,reqVO);
|
|
|
if(!pass){
|
|
|
throw new UfoServiceException(400, "您上传的证件照片信息不正确,请重新上传!");
|
|
|
}
|
|
|
|
|
|
return imgUrls;
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
/*
|
|
|
public ImageBO getUploadImagePath(MultipartFile multipartFile, String bucket, String uid, Integer limitType) throws Exception {
|
|
|
//文件为空
|
|
|
if (multipartFile.isEmpty()) {
|
|
|
logger.warn("upload file is empty");
|
|
|
throw new FileNotFoundException("上传文件为空");
|
|
|
}
|
|
|
|
|
|
// bucket必须为系统已定义常量
|
|
|
if (!"yohocard".equals(bucket)) {
|
|
|
logger.warn("can't find upload bucket {}", bucket);
|
|
|
throw new Exception("上传Bucket:" + bucket + "无效");
|
|
|
}
|
|
|
|
|
|
String imageFileName = multipartFile.getOriginalFilename();
|
|
|
long imageFileSize = multipartFile.getSize();
|
|
|
//产品需求:百度云要求图片大小4M
|
|
|
boolean flag = StringUtils.contains(imageFileName, ".jpeg") ||
|
|
|
StringUtils.contains(imageFileName, ".jpg") || StringUtils.contains(imageFileName, ".png");
|
|
|
if(!flag){
|
|
|
logger.warn("upload file type not correct {}",imageFileName);
|
|
|
throw new FileNotFoundException("上传文件为空");
|
|
|
}
|
|
|
if (imageFileSize >= 4*1024*1024) {
|
|
|
logger.warn("upload images exceeded imageSize {}", imageFileSize);
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
throw new Exception("上传图片实际大小:" + decimalFormat.format(imageFileSize / 1024.0) + "KB,超过了图片默认值" );
|
|
|
}
|
|
|
|
|
|
String fileMode = "01";
|
|
|
logger.info("upload image bucket is {}, fileMode is {}", bucket, fileMode);
|
|
|
|
|
|
String saveName = new SimpleDateFormat("/yyyy/MM/dd/HH/").format(new Date());
|
|
|
String fileName = fileMode
|
|
|
+ DigestUtils.md5Hex(uid + "_" + System.currentTimeMillis() + multipartFile.getOriginalFilename())
|
|
|
+ multipartFile.getOriginalFilename().substring(multipartFile.getOriginalFilename().indexOf("."));
|
|
|
// 文件保存路径
|
|
|
String filePath = saveDir + File.separator + fileName;
|
|
|
File uploadFile = new File(filePath);
|
|
|
multipartFile.transferTo(uploadFile);
|
|
|
|
|
|
checkFilePixels(uploadFile, limitType);
|
|
|
|
|
|
String imgUrl = iqnUploadService.upload(uploadFile, bucket, saveName + fileName);
|
|
|
|
|
|
ImageBO imageBO = new ImageBO();
|
|
|
imageBO.setFileByte(FileUtils.readFileToByteArray(uploadFile));
|
|
|
imageBO.setImageUrl(imgUrl);
|
|
|
//删除文件
|
|
|
uploadFile.delete();
|
|
|
return imageBO;
|
|
|
}
|
|
|
|
|
|
|
|
|
//根据配置,校验每种场景的图片是否符合规范
|
|
|
private void checkFilePixels(File uploadFile, Integer limitType) throws Exception {
|
|
|
if (null == limitType) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
logger.info("method checkFilePixels exceute.");
|
|
|
|
|
|
BufferedImage sourceImg = null;
|
|
|
|
|
|
try {
|
|
|
sourceImg = ImageIO.read(java.nio.file.Files.newInputStream(uploadFile.toPath()));
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
logger.warn("ImageIO read find wrong uploadFile {}",uploadFile , e);
|
|
|
throw new GatewayException( 400,"上传文件失败");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public AuthorizeResultRespVO zhiMaCertWithPhotoInit(RealNameAuthorizeReqVO reqVO,boolean ocrPhotoCheck){
|
|
|
logger.info("real name zhiMaCertWithPhotoInit reqVO {}", reqVO);
|
...
|
...
|
|