Authored by qinchao

身份证验证加个计数

... ... @@ -20,6 +20,9 @@ public enum CacheKeyEnum {
ZHI_MA_CERT_KEY("ufo:user:zhiMaCert:","芝麻认证信息", 2, TimeUnit.HOURS),
//身份证上传验证,一天只允许一定的次数
PHOTO_CHECK_COUNT_KEY("ufo:user:photoCheckCount:","芝麻认证信息", 24, TimeUnit.HOURS),
STORED_SELLER_KEY("ufo:user:storedSeller:","商家入驻信息", 2, TimeUnit.HOURS),
USER_PRODUCT_FAVORITE_ZSET_KEY("ufo:user:product:favorite:","用户商品收藏集合", 180, TimeUnit.DAYS),
... ...
... ... @@ -51,6 +51,10 @@ public class CacheService {
return RedisKeyBuilder.newInstance().appendFixed(CacheKeyEnum.ZHI_MA_CERT_KEY.getCacheKey()).appendVar(uid);
}
private static RedisKeyBuilder getPhotoCheckRedisKeyBuilder(String dayStr,Integer uid){
return RedisKeyBuilder.newInstance().appendFixed(CacheKeyEnum.PHOTO_CHECK_COUNT_KEY.getCacheKey()).appendVarWithMH(dayStr).appendVar(uid);
}
/**************************************************************************
* 商品收藏相关
*************************************************************************/
... ... @@ -198,6 +202,17 @@ public class CacheService {
yhRedisTemplate.delete(getZhiMaCertRedisKeyBuilder(uid));
}
public Long getPhotoCheckCount(String dayStr,Integer uid){
RedisKeyBuilder cacheKey = getPhotoCheckRedisKeyBuilder(dayStr,uid);
Long count = get(cacheKey,Long.class);
return count;
}
public Long incrementPhotoCheckCount(String dayStr,Integer uid) {
RedisKeyBuilder cacheKey = getPhotoCheckRedisKeyBuilder(dayStr,uid);
return this.incrementWithExpire(cacheKey, 1L , CacheKeyEnum.PHOTO_CHECK_COUNT_KEY.getDefaultExpireTime(), CacheKeyEnum.PHOTO_CHECK_COUNT_KEY.getTimeUnit()) ;
}
/**************************************************************************
* 通用
... ...
... ... @@ -11,6 +11,7 @@ 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.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.reviewed.request.ImageBO;
import com.yoho.service.model.reviewed.request.ImageReviewedReq;
... ... @@ -74,36 +75,22 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
@Autowired
private HttpClient httpClient;
@Value("${file.saveDir}")
private String saveDir;
@Value("${web.context}")
private String contextPath;
@Autowired
private IQNUploadService iqnUploadService;
@Value("${zhimacert.switch:true}")
private boolean zhiMaCertSwitch;
/* @Autowired
private GraphVerifyService graphVerifyService;*/
/* @Resource(name="authorizeBankRestTemplate")
private RestTemplate restTemplate;*/
/* @Resource(name = "core-config-reader")
private ConfigReader configReader;*/
// 需要放到zk上
private Integer maxPhotoCheckCount = 10;
/* @Autowired
private IUserAuthorizeHistoryDao userAuthorizeHistoryDao;*/
//private final static DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
//@Value("${file.saveDir}")
private String saveDir="D:/pic";
//请求实名认证银联接口url 测试环境
//private final String requestUrl="http://58.247.0.18:29015/v1/datacenter/smartverification/bankcard/verify";
//请求实名认证银联接口url 生产环境
//private final String requestUrl="https://api-mop.chinaums.com/v1/datacenter/smartverification/bankcard/verify";
//@Autowired
private IQNUploadService iqnUploadService;
//ExecutorService executeService = Executors.newFixedThreadPool(10);
public UserAuthorizeInfo getValidAuthorizeInfo(int uid){
... ... @@ -387,6 +374,19 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
throw new GatewayException(400, "请上传身份证正反面!");
}
//每天:记录一个累加的次数 ,超过一定的数量不允许继续调
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){
throw new GatewayException(400, "超过当日最大调用次数!");
}
//次数加1
cacheService.incrementPhotoCheckCount(dayStr,reqVO.getUid());
//循环获取file数组中得文件
ImageBO frontUploadModel=null;
ImageBO backUploadModel=null;
... ...