|
@@ -99,7 +99,7 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
return R.error("501","未获取到手机号,请联系系统管理员");
|
|
return R.error("501","未获取到手机号,请联系系统管理员");
|
|
}
|
|
}
|
|
String redisKeyName = loginType + phone;
|
|
String redisKeyName = loginType + phone;
|
|
- String redisLabelName = loginType + account;
|
|
|
|
|
|
+ String redisLabelName = CxConstants.LOGIN_SEND_CODE_PREFIX+loginType + account;
|
|
return sendSmsCode(null, redisKeyName, phone, redisLabelName);
|
|
return sendSmsCode(null, redisKeyName, phone, redisLabelName);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -185,16 +185,18 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
private R sendSmsCode(String templateId, String redisKeyName, String mobile, String redisLabelName) {
|
|
private R sendSmsCode(String templateId, String redisKeyName, String mobile, String redisLabelName) {
|
|
boolean exists = redisService.hasKey(redisKeyName);
|
|
boolean exists = redisService.hasKey(redisKeyName);
|
|
String sendCodeTimeObj = (String) redisService.getRedisCatchObj(redisKeyName);
|
|
String sendCodeTimeObj = (String) redisService.getRedisCatchObj(redisKeyName);
|
|
- if (StringUtils.isBlank(sendCodeTimeObj)) {
|
|
|
|
- sendCodeTimeObj = "0";
|
|
|
|
- }
|
|
|
|
- int sendCodeTime = Integer.parseInt(sendCodeTimeObj);
|
|
|
|
|
|
+ int sendCodeTime = StringUtils.isBlank(sendCodeTimeObj) ? 0 : Integer.parseInt(sendCodeTimeObj);
|
|
if( exists && sendCodeTime >= 20 ){
|
|
if( exists && sendCodeTime >= 20 ){
|
|
- sendCodeTime += 1;
|
|
|
|
- redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
|
|
|
|
+ //sendCodeTime += 1;
|
|
|
|
+ //redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
return R.error("验证发送次数频繁,请过5分钟后再尝试");
|
|
return R.error("验证发送次数频繁,请过5分钟后再尝试");
|
|
}
|
|
}
|
|
- String code = SmsCodeGenerateUtils.getInstance().generateVerificationCode();
|
|
|
|
|
|
+ String code = null;
|
|
|
|
+ try {
|
|
|
|
+ code = SmsCodeGenerateUtils.generateVerificationCode(6);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.info("生成短信验证码失败"+e);
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
JSONObject jsonObject = HwSmsUtil.sendSms(templateId,null, code, mobile);
|
|
JSONObject jsonObject = HwSmsUtil.sendSms(templateId,null, code, mobile);
|
|
String returnCode = jsonObject.getString("code");
|
|
String returnCode = jsonObject.getString("code");
|
|
@@ -204,13 +206,14 @@ public class ZhcxApiServiceImpl implements ZhcxApiService {
|
|
}
|
|
}
|
|
sendCodeTime += 1;
|
|
sendCodeTime += 1;
|
|
redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
redisService.redisCatchInit(redisKeyName,String.valueOf(sendCodeTime),CxConstants.SEND_CODE_INTERVAL);
|
|
- redisService.redisCatchInit(redisLabelName,code.toString(),CxConstants.VERIFICATION_CODE_EXPIRATION);
|
|
|
|
|
|
+ redisService.redisCatchInit(redisLabelName,code,CxConstants.VERIFICATION_CODE_EXPIRATION);
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
json.put("phone",mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"));
|
|
json.put("phone",mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"));
|
|
return R.ok("发送成功").putData(json);
|
|
return R.ok("发送成功").putData(json);
|
|
}
|
|
}
|
|
|
|
+ log.info("华为云短信接口调用返回:"+jsonObject);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.info("发送短信失败"+e);
|
|
}
|
|
}
|
|
return R.error("获取账号信息失败, 请联系管理员!");
|
|
return R.error("获取账号信息失败, 请联系管理员!");
|
|
}
|
|
}
|