|
@@ -11,7 +11,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.llisoft.sms.config.MtaException;
|
|
|
import com.llisoft.sms.util.CodeUtil;
|
|
|
+import com.llisoft.sms.util.JsonUtil;
|
|
|
import com.llisoft.sms.util.RedisUtil;
|
|
|
+import com.llisoft.sms.vo.SendCodeRequestVo;
|
|
|
|
|
|
/**
|
|
|
* 短信服务
|
|
@@ -35,18 +37,18 @@ public class SmsService {
|
|
|
* @param phone
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public boolean sendCode(String phone, String appkey, String scene, String token,
|
|
|
- String sessionId, String sig, String ip, int type) throws Exception {
|
|
|
+ public boolean sendCode(SendCodeRequestVo requestVo, String ip) throws Exception {
|
|
|
// 检查人机验证码
|
|
|
- logger.info("人机验证: appkey={}, scene={}, token={}, sessionId={}, sig={}, ip={}", appkey, scene, token, sessionId, sig, ip);
|
|
|
+ logger.info("人机验证: ", JsonUtil.toJson(requestVo));
|
|
|
if (debug) {
|
|
|
logger.warn("开发模式:人机验证已跳过");
|
|
|
}
|
|
|
- if (!debug && !aliyunService.afs(appkey, scene, token, sessionId, sig, ip)) {
|
|
|
- logger.warn("人机验证失败:{}", token);
|
|
|
+ if (!debug && !aliyunService.afs(requestVo.getAppkey(), requestVo.getScene(), requestVo.getToken(), requestVo.getSessionid(), requestVo.getSig(), ip)) {
|
|
|
+ logger.warn("人机验证失败:{}", requestVo.getToken());
|
|
|
throw new MtaException("人机验证失败,请刷新页面后重试");
|
|
|
}
|
|
|
// 检查号码
|
|
|
+ String phone = requestVo.getPhone();
|
|
|
logger.info("检查手机号: {}", phone);
|
|
|
if(!this.checkSend(phone)) {
|
|
|
logger.warn("手机号被限制发送:{}", phone);
|
|
@@ -56,7 +58,7 @@ public class SmsService {
|
|
|
String code = String.valueOf(CodeUtil.ints(4));
|
|
|
RedisUtil.set(phone + "_" + code, "", 10, TimeUnit.MINUTES); // 有效期10分钟
|
|
|
logger.info("发送验证码: {}", code);
|
|
|
- aliyunService.sms(phone, code, type); // 第三方发送短信(异步)
|
|
|
+ aliyunService.sms(requestVo.getSign(), phone, code); // 第三方发送短信(异步)
|
|
|
return true;
|
|
|
}
|
|
|
|