|
@@ -24,19 +24,22 @@ public class SckwSmsHandlerService {
|
|
|
private final KwmSmsService kwmSmsService;
|
|
private final KwmSmsService kwmSmsService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @param sckwSms
|
|
|
|
|
+ * @return void
|
|
|
* @desc: 短信处理
|
|
* @desc: 短信处理
|
|
|
* @author: yzc
|
|
* @author: yzc
|
|
|
* @date: 2023-06-13 13:44
|
|
* @date: 2023-06-13 13:44
|
|
|
- * @param sckwSms
|
|
|
|
|
- * @return void
|
|
|
|
|
*/
|
|
*/
|
|
|
public void handler(SckwSms sckwSms) {
|
|
public void handler(SckwSms sckwSms) {
|
|
|
log.info("接收到发送短信消息:{},开始处理", JSON.toJSONString(sckwSms));
|
|
log.info("接收到发送短信消息:{},开始处理", JSON.toJSONString(sckwSms));
|
|
|
- String key = getMessageSmsVerifyCodeKey(sckwSms.getTelephone());
|
|
|
|
|
- if (Boolean.FALSE.equals(RedissonUtils.tryLock(key, 10L, RedisConstant.SMS_VERIFY_CODE_VALID_TIME))) {
|
|
|
|
|
|
|
+ String requestKey = getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_REQUEST_KEY, sckwSms.getTelephone());
|
|
|
|
|
+ if (Boolean.FALSE.equals(RedissonUtils.tryLock(requestKey, 10L, RedisConstant.SMS_VERIFY_CODE_VALID_TIME))) {
|
|
|
log.info("重复发送短信消息,不处理");
|
|
log.info("重复发送短信消息,不处理");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ String valueKey = getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, sckwSms.getTelephone());
|
|
|
|
|
+ //发送短信
|
|
|
|
|
+ RedissonUtils.putString(valueKey, String.valueOf(sckwSms.getParams().get("code")), RedisConstant.SMS_VERIFY_CODE_VALID_TIME);
|
|
|
//发送短信
|
|
//发送短信
|
|
|
SmsUtil.sendSms(sckwSms.getTelephone(), sckwSms.getSignName(), sckwSms.getTemplateCode().getName(), JSON.toJSONString(sckwSms.getParams()));
|
|
SmsUtil.sendSms(sckwSms.getTelephone(), sckwSms.getSignName(), sckwSms.getTemplateCode().getName(), JSON.toJSONString(sckwSms.getParams()));
|
|
|
//数据入库
|
|
//数据入库
|
|
@@ -47,7 +50,7 @@ public class SckwSmsHandlerService {
|
|
|
kwmSmsService.add(kwmSms);
|
|
kwmSmsService.add(kwmSms);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private String getMessageSmsVerifyCodeKey(String phone) {
|
|
|
|
|
- return String.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_KEY, phone);
|
|
|
|
|
|
|
+ private String getKey(String prefix, String args) {
|
|
|
|
|
+ return String.format(prefix, args);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|