|
@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.rongwei.bscommon.sys.dao.ZhcxApiDao;
|
|
|
import com.rongwei.bscommon.sys.service.ZhcxApiService;
|
|
|
+import com.rongwei.bscommon.sys.utils.CxConstants;
|
|
|
import com.rongwei.bscommon.sys.utils.HwSmsUtil;
|
|
|
+import com.rongwei.bscommon.sys.utils.SmsCodeGenerateUtils;
|
|
|
import com.rongwei.bsentity.vo.ZhcxOutsideInspectionVo;
|
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
|
import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
@@ -65,35 +67,31 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
|
or().eq(SysUserDo::getMobile, account).
|
|
|
or().eq(SysUserDo::getEmail, account));
|
|
|
SysUserDo sysUserDo = sysUserService.getOne(queryWrapper);
|
|
|
- boolean exists = redisService.hasKey("getCode_"+account);
|
|
|
- String sendCodeTimeObj = (String) redisService.getRedisCatchObj("getCode_"+account);
|
|
|
- if (StringUtils.isBlank(sendCodeTimeObj)) {
|
|
|
- sendCodeTimeObj = "0";
|
|
|
- }
|
|
|
- int sendCodeTime = Integer.parseInt(sendCodeTimeObj);
|
|
|
-
|
|
|
+ boolean exists = redisService.hasKey(CxConstants.LOGIN_SEND_CODE_PREFIX+account);
|
|
|
+ String sendCodeTimeObj = (String) redisService.getRedisCatchObj(CxConstants.LOGIN_SEND_CODE_PREFIX+account);
|
|
|
+ int sendCodeTime = StringUtils.isBlank(sendCodeTimeObj) ? 0 : Integer.parseInt(sendCodeTimeObj);
|
|
|
if (sysUserDo == null || StringUtils.isEmpty(sysUserDo.getId())) {
|
|
|
sendCodeTime += 1;
|
|
|
- if(sendCodeTime <= 10){
|
|
|
- redisService.redisCatchInit("getCode_"+account,String.valueOf(sendCodeTime),300);
|
|
|
+ if(sendCodeTime <= 20){
|
|
|
+ redisService.redisCatchInit(CxConstants.LOGIN_SEND_CODE_PREFIX+account,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
|
}
|
|
|
- if (sendCodeTime < 10) {
|
|
|
+ if (sendCodeTime < 20) {
|
|
|
return R.error("501","用户名密码不正确");
|
|
|
}
|
|
|
}
|
|
|
String secPas = SecurityUtil.getSaltMd5AndSha(password, sysUserDo.getId());
|
|
|
if (!secPas.equals(sysUserDo.getPassword())) {
|
|
|
sendCodeTime += 1;
|
|
|
- if(sendCodeTime <= 10){
|
|
|
- redisService.redisCatchInit("getCode_"+account,String.valueOf(sendCodeTime),300);
|
|
|
+ if(sendCodeTime <= 20){
|
|
|
+ redisService.redisCatchInit(CxConstants.LOGIN_SEND_CODE_PREFIX+account,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
|
}
|
|
|
- if (sendCodeTime < 10) {
|
|
|
+ if (sendCodeTime < 20) {
|
|
|
return R.error("501","用户名密码不正确");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- if( exists && sendCodeTime >= 10 ){
|
|
|
+ if( exists && sendCodeTime >= 20 ){
|
|
|
return R.error("501","当前账号被锁定,请过5分钟后再尝试");
|
|
|
}
|
|
|
String phone = sysUserDo.getMobile();
|
|
@@ -191,29 +189,22 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
|
sendCodeTimeObj = "0";
|
|
|
}
|
|
|
int sendCodeTime = Integer.parseInt(sendCodeTimeObj);
|
|
|
- if( exists && sendCodeTime >= 3 ){
|
|
|
+ if( exists && sendCodeTime >= 20 ){
|
|
|
sendCodeTime += 1;
|
|
|
- redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),300);
|
|
|
+ redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
|
return R.error("验证发送次数频繁,请过5分钟后再尝试");
|
|
|
}
|
|
|
- StringBuilder code = new StringBuilder();
|
|
|
- for (int i = 0; i < 6; i++) {
|
|
|
- if(i == 0){
|
|
|
- code.append(new Random().nextInt(9)+1);
|
|
|
- }else{
|
|
|
- code.append(new Random().nextInt(10));
|
|
|
- }
|
|
|
- }
|
|
|
+ String code = SmsCodeGenerateUtils.getInstance().generateVerificationCode();
|
|
|
try {
|
|
|
- JSONObject jsonObject = HwSmsUtil.sendSms(templateId,null, code.toString(), mobile);
|
|
|
+ JSONObject jsonObject = HwSmsUtil.sendSms(templateId,null, code, mobile);
|
|
|
String returnCode = jsonObject.getString("code");
|
|
|
if("000000".equals(returnCode)){
|
|
|
if(!exists){
|
|
|
- redisService.redisCatchInit(redisKeyName,0,300);
|
|
|
+ redisService.redisCatchInit(redisKeyName,0,CxConstants.SEND_CODE_INTERVAL);
|
|
|
}
|
|
|
sendCodeTime += 1;
|
|
|
- redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),300);
|
|
|
- redisService.redisCatchInit(redisLabelName,code.toString(),120);
|
|
|
+ redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
|
+ redisService.redisCatchInit(redisLabelName,code.toString(),CxConstants.VERIFICATION_CODE_EXPIRATION);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("phone",mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"));
|
|
|
return R.ok("发送成功").putData(json);
|