|
@@ -48,11 +48,11 @@ public class SmsServiceImpl implements SmsService {
|
|
String phone = sms.getPhone();
|
|
String phone = sms.getPhone();
|
|
Integer phoneAreaCode = sms.getPhone_area_code();
|
|
Integer phoneAreaCode = sms.getPhone_area_code();
|
|
|
|
|
|
- // 生成一个6位的随机整数 (验证码) (5分钟失效)
|
|
|
|
Integer smsExpire = 5;
|
|
Integer smsExpire = 5;
|
|
- Integer smsCode = RandomUtil.randomInt(100000, 999999);
|
|
|
|
|
|
+ Integer smsCode = RandomUtil.randomInt(100000, 999999); // 生成一个6位的随机整数 (验证码) (5分钟失效)
|
|
sms.setSms_code(smsCode);
|
|
sms.setSms_code(smsCode);
|
|
|
|
|
|
|
|
+ // -- 腾讯云短信 ------------------------------------------------
|
|
// 模板参数 {1} 验证码, {2} 过期时间(分钟)
|
|
// 模板参数 {1} 验证码, {2} 过期时间(分钟)
|
|
// 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空
|
|
// 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空
|
|
String[] templateParamSet = {String.valueOf(smsCode), String.valueOf(smsExpire)};
|
|
String[] templateParamSet = {String.valueOf(smsCode), String.valueOf(smsExpire)};
|
|
@@ -60,7 +60,6 @@ public class SmsServiceImpl implements SmsService {
|
|
// 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号
|
|
// 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号
|
|
String[] phoneNumberSet = {"+" + phoneAreaCode + phone};
|
|
String[] phoneNumberSet = {"+" + phoneAreaCode + phone};
|
|
SendSmsResponse sendSmsResponse = tencentSmsService.send(TEMPLATE_ID_COMMON, templateParamSet, phoneNumberSet);
|
|
SendSmsResponse sendSmsResponse = tencentSmsService.send(TEMPLATE_ID_COMMON, templateParamSet, phoneNumberSet);
|
|
-
|
|
|
|
if (sendSmsResponse != null) {
|
|
if (sendSmsResponse != null) {
|
|
SendStatus[] sendStatuses = sendSmsResponse.getSendStatusSet();
|
|
SendStatus[] sendStatuses = sendSmsResponse.getSendStatusSet();
|
|
if (sendStatuses.length > 0) {
|
|
if (sendStatuses.length > 0) {
|
|
@@ -72,6 +71,8 @@ public class SmsServiceImpl implements SmsService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // ------------------------------------------------------------
|
|
|
|
+
|
|
// -- 发送成功 --------------------------------------------------
|
|
// -- 发送成功 --------------------------------------------------
|
|
// [Redis] 将 来源+手机号码 为标识,将验证码存入缓存
|
|
// [Redis] 将 来源+手机号码 为标识,将验证码存入缓存
|
|
String redisKey = "sms-" + origin + "-" + phone;
|
|
String redisKey = "sms-" + origin + "-" + phone;
|