|
|
@@ -18,6 +18,7 @@ import com.yingyangfly.common.utils.DateUtils;
|
|
|
import com.yingyangfly.core.api.ImApi;
|
|
|
import com.yingyangfly.core.domain.*;
|
|
|
import com.yingyangfly.core.dto.*;
|
|
|
+import com.yingyangfly.core.enums.MsgTemplateEnums;
|
|
|
import com.yingyangfly.core.enums.RedisStatusEnums;
|
|
|
import com.yingyangfly.core.enums.StatusEnums;
|
|
|
import com.yingyangfly.core.mapper.*;
|
|
|
@@ -26,6 +27,7 @@ import com.yingyangfly.core.security.util.TokenUtil;
|
|
|
import com.yingyangfly.core.service.*;
|
|
|
import com.yingyangfly.core.util.AmountUtils;
|
|
|
import com.yingyangfly.core.util.Sm4Util;
|
|
|
+import com.yingyangfly.core.util.SmgUtil;
|
|
|
import com.yingyangfly.redis.client.RedisClient;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.assertj.core.util.Sets;
|
|
|
@@ -486,7 +488,20 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
if (StringUtils.isEmpty(checkCodeRedis)) {
|
|
|
return ResultResponse.fail("验证码已经过期");
|
|
|
}
|
|
|
+ String errorNumKey = "app:error:num:"+mobile;
|
|
|
+ String errorNumRedis = redisClient.get(errorNumKey, "");
|
|
|
+ if (ObjectUtils.isNotNull(errorNumRedis)){
|
|
|
+ if (Integer.parseInt(errorNumRedis) >= 3){
|
|
|
+ return ResultResponse.fail("验证码错误了3次,账户锁定10分钟");
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!checkCodeRedis.equals(checkCode)) {
|
|
|
+ Integer errorNum = 0;
|
|
|
+ if (ObjectUtils.isNotNull(errorNumRedis)){
|
|
|
+ errorNum = Integer.parseInt(errorNumRedis);
|
|
|
+ }
|
|
|
+ errorNum++;
|
|
|
+ redisClient.set(errorNumKey,String.valueOf(errorNum),600);
|
|
|
return ResultResponse.fail("验证码输入错误");
|
|
|
}
|
|
|
String encrypt = Sm4Util.encrypt(mobile);
|
|
|
@@ -522,6 +537,11 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
}
|
|
|
|
|
|
public ResultResponse getCheckCode(String mobile) {
|
|
|
+ String redisKey = "hcp:sms:mobile:" + mobile;
|
|
|
+ String checkCodeRedis = redisClient.get(redisKey, "");
|
|
|
+ if (!StringUtils.isEmpty(checkCodeRedis)) {
|
|
|
+ return ResultResponse.fail("请不要频繁发送验证码");
|
|
|
+ }
|
|
|
String encrypt = Sm4Util.encrypt(mobile);
|
|
|
AppUser appUser = this.selectByMobile(encrypt,"0");
|
|
|
if (appUser == null) {
|
|
|
@@ -529,10 +549,12 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
}
|
|
|
Random rand = new Random();
|
|
|
int randomNumber = rand.nextInt(1000000);
|
|
|
- String random = "123456";//String.format("%06d", randomNumber);
|
|
|
+ String random = String.format("%06d", randomNumber);
|
|
|
//6位随机数
|
|
|
- Boolean isSuccess = true;//SmgUtil.sendCheckCode(mobile, MsgTemplateEnums.GET_CHECK_CODE.getTempalteCode(), random);
|
|
|
+ Boolean isSuccess = SmgUtil.sendCheckCode(mobile, MsgTemplateEnums.GET_CHECK_CODE.getTempalteCode(), random);
|
|
|
if (isSuccess) {
|
|
|
+ // 防机器
|
|
|
+ redisClient.set("hcp:sms:mobile:"+mobile,random,60);
|
|
|
//存入redis
|
|
|
redisClient.set("hcp:mobile:" + mobile, random, 120);
|
|
|
return ResultResponse.success();
|