记得上下班打卡 | git大法好,push需谨慎

Commit 36559923 authored by zhoujianping's avatar zhoujianping

小家伙实名认证流量限制

parent 0d9a78eb
......@@ -164,6 +164,16 @@ public class SmileUserController {
String userId = CurrentUtil.getCurrentUid();
/* String status=smileRedisUtils.getValidate(smileUserVO.getName(), smileUserVO.getIdCard());*/
log.info("小家伙增加或者删除第二步实名认证开始userId={},ip={}",userId,CurrentUtil.getCliIpAddr());
//实名认证限制 每天10次
int userValidateLimitNo = smileRedisUtils.getUserValidateLimitNo(userId);
if(userValidateLimitNo>=10){
return ResponseDto.failure("小家伙今日操作已达上限!");
}
if (userValidateLimitNo == -1) {
smileRedisUtils.setUserValidateLimitNo(userId);
} else {
smileRedisUtils.incrValidateLimitNo(userId);
}
if(utils.validate(smileUserVO.getName(),smileUserVO.getIdCard())){
smileUserVO.setUid(userId);
SmileUserVO smileUserVORedis=smileRedisUtils.getSmileUserVo(userId);
......
......@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
......@@ -47,6 +49,24 @@ public class SmileRedisUtils {
redisUtil.set(SmileRedisConst.SMILE_USER_VALIDATE.concat(realName + cardNo), type);
}
/* - - - - - - - - - - - - -小家伙实名认证限制 - - - - - - - - - - - - - | */
public boolean setUserValidateLimitNo(String uid) {
LocalDateTime now = LocalDateTime.now();
return redisUtil.set(SmileRedisConst.SMILE_USER_VALIDATE_LIMIT.concat(uid), 1,
ChronoUnit.SECONDS.between(now, LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 23, 59, 59)));
}
public long incrValidateLimitNo(String uid) {
return redisUtil.incr(SmileRedisConst.SMILE_USER_VALIDATE_LIMIT.concat(uid), 1);
}
public int getUserValidateLimitNo(String uid) {
Object o = redisUtil.get(SmileRedisConst.SMILE_USER_VALIDATE_LIMIT.concat(uid));
return null == o ? -1 : (int) o;
}
/* ---------------------------------------- 销售数据 ---------------------------------------- */
public SmileSellDataVO getSellDataVo(String userId, String performanceId) {
return (SmileSellDataVO) redisUtil.get(SmileRedisConst.SELL_DATA.concat(userId).concat(performanceId));
......
......@@ -7,6 +7,7 @@ import com.liquidnet.service.base.ErrorMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Slf4j
@Component
......@@ -30,9 +31,11 @@ public class Utils {
String respStr = IdentityUtils.aliThird(realName, cardNo), respErrorCode = null;
JsonNode respJNode = JsonUtils.fromJson(respStr, JsonNode.class);
if (null == respJNode || !"0".equals(respErrorCode = String.valueOf(respJNode.get("error_code")))) {
log.debug("###实名认证失败[{}]", respJNode);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
smileRedisUtils.setValidate(realName, cardNo, "1");
log.info("###实名认证失败[{}]", respJNode);
if (!StringUtils.isEmpty(respErrorCode) && org.apache.commons.lang3.StringUtils.indexOf("3000290033", respErrorCode) < 0) {
// 认证服务商'30002'、'90033'为运营商导致的失败,这里不做缓存标记
smileRedisUtils.setValidate(realName, cardNo, "1");
}
return false;
}
smileRedisUtils.setValidate(realName, cardNo, "2");
......
......@@ -6,7 +6,7 @@ liquidnet:
username: user
password: user123
eureka:
host: 172.17.207.177:7001
host: 127.0.0.1:7001
# end-test-这里是配置信息基本值
spring:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment