...
|
...
|
@@ -11,6 +11,8 @@ import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
|
|
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
|
|
import com.alipay.api.response.ZhimaCustomerCertificationQueryResponse;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.core.cache.LocalCache;
|
|
|
import com.yoho.core.config.ConfigReader;
|
|
|
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.service.model.reviewed.request.ImageBO;
|
...
|
...
|
@@ -42,6 +44,7 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.imageio.ImageIO;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
...
|
...
|
@@ -54,6 +57,7 @@ import java.time.ZoneOffset; |
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -82,8 +86,8 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
@Value("${zhimacert.switch:true}")
|
|
|
private boolean zhiMaCertSwitch;
|
|
|
|
|
|
// 需要放到zk上
|
|
|
private Integer maxPhotoCheckCount = 10;
|
|
|
@Autowired
|
|
|
private ConfigReader configReader;
|
|
|
|
|
|
//@Value("${file.saveDir}")
|
|
|
private String saveDir="D:/pic";
|
...
|
...
|
@@ -93,6 +97,26 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
|
|
|
|
|
|
|
|
|
//缓存
|
|
|
private LocalCache localCache_switch = new LocalCache();
|
|
|
private static final String CACHE_KEY = "photoCheckExceedLimitCacheKey";
|
|
|
|
|
|
@PostConstruct
|
|
|
private void init() {
|
|
|
localCache_switch.init(CACHE_KEY, 5, TimeUnit.MINUTES, (String s, Object o) -> {
|
|
|
logger.info("realNameAuthorizeServiceImpl init photoCheckExceedLimitCacheKey s = {}, o = {}", s, o);
|
|
|
return configReader.getInt("ufo.user.photoCheckLimit",10);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private int getPhotoCheckLimit(){
|
|
|
Object value=localCache_switch.get(CACHE_KEY);
|
|
|
if(null == value) {
|
|
|
return 10;
|
|
|
}
|
|
|
return (Integer) value;
|
|
|
}
|
|
|
|
|
|
public UserAuthorizeInfo getValidAuthorizeInfo(int uid){
|
|
|
logger.info("RealNameAuthorizeServiceImpl getValidAuthorizeInfo uid is {} ",uid);
|
|
|
// 从redis缓存中获取
|
...
|
...
|
@@ -353,15 +377,25 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
39 *
|
|
|
40 * @return返回字符串格式 yyyy-MM-dd HH:mm:ss
|
|
|
41 */
|
|
|
public static String getStringDate() {
|
|
|
Date currentTime = new Date();
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
String dateString = formatter.format(currentTime);
|
|
|
return dateString;
|
|
|
public static String getStringDate(String fmt) {
|
|
|
Date currentTime = new Date();
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat(fmt);
|
|
|
String dateString = formatter.format(currentTime);
|
|
|
return dateString;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean isPhotoCheckExceedLimit(Integer uid){
|
|
|
return isPhotoCheckExceedLimit(getStringDate("yyyyMMdd") ,uid);
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
System.out.println(getStringDate());
|
|
|
private boolean isPhotoCheckExceedLimit(String dayStr ,Integer uid){
|
|
|
Long count = cacheService.getPhotoCheckCount(dayStr,uid);
|
|
|
logger.info("zhiMaCertUploadPhotoAndCheck getPhotoCheckCount count {},uid {} ",count,uid);
|
|
|
if(count!=null&&count>=getPhotoCheckLimit()){
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -374,12 +408,8 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
}
|
|
|
|
|
|
//每天:记录一个累加的次数 ,超过一定的数量不允许继续调
|
|
|
Date currentTime = new Date();
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
|
|
String dayStr = formatter.format(currentTime);
|
|
|
Long count = cacheService.getPhotoCheckCount(dayStr,reqVO.getUid());
|
|
|
logger.info("zhiMaCertUploadPhotoAndCheck getPhotoCheckCount count {},reqVO {} ",count,reqVO);
|
|
|
if(count!=null&&count>=maxPhotoCheckCount){
|
|
|
String dayStr = getStringDate("yyyyMMdd");
|
|
|
if(isPhotoCheckExceedLimit(dayStr,reqVO.getUid())){
|
|
|
throw new GatewayException(400, "超过当日最大调用次数!");
|
|
|
}
|
|
|
|
...
|
...
|
@@ -605,7 +635,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
}
|
|
|
|
|
|
//7+14+
|
|
|
String transactionId="ufoCert"+getStringDate()+zhiMaCert.getId();
|
|
|
String transactionId="ufoCert"+getStringDate("yyyyMMddHHmmss")+zhiMaCert.getId();
|
|
|
|
|
|
String bizNo=ZhiMaCallUtil.zhiMaCertInit(transactionId,reqVO.getCertName(),reqVO.getCertNo());
|
|
|
|
...
|
...
|
|