Commit 69f20bc5 authored by lee_mingzhu's avatar lee_mingzhu

修改短信SDK

parent 3348837f
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
<dependency> <dependency>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId> <artifactId>quantgroup-sms-sdk</artifactId>
<version>1.0.5-SNAPSHOT</version> <version>2.0.0.3-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
package cn.quantgroup.xyqb.controller.internal.sms; package cn.quantgroup.xyqb.controller.internal.sms;
import cn.quantgroup.sms.ConfirmableMsg; import cn.quantgroup.sms.MsgParams;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.captcha.CaptchaValidator; import cn.quantgroup.xyqb.aspect.captcha.CaptchaValidator;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
...@@ -16,10 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -16,10 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
...@@ -105,11 +102,13 @@ public class SmsController { ...@@ -105,11 +102,13 @@ public class SmsController {
String uniqueId = phoneNo + UUID.randomUUID().toString().replaceAll("-", ""); String uniqueId = phoneNo + UUID.randomUUID().toString().replaceAll("-", "");
List<String> newList = new ArrayList<>(); List<String> newList = new ArrayList<>();
newList.add(randomCode); newList.add(randomCode);
ConfirmableMsg confirmableMsg = new ConfirmableMsg( /*ConfirmableMsg confirmableMsg = new ConfirmableMsg(
uniqueId, newList, "1", "1", phoneNo uniqueId, newList, "1", "1", phoneNo
); );*/
MsgParams message = new MsgParams(Collections.singletonList(2), phoneNo, "1", "1", Collections.singletonList(randomCode), uniqueId);
try { try {
smsService.getSmsSender().sendConfirmableMessage(confirmableMsg); //smsService.getSmsSender().sendConfirmableMessage(confirmableMsg);
smsService.getSmsSender().sendMsg(message);
redisTemplate.opsForValue().set(key, uniqueId + ":" + randomCode, EXPIRE_MINUTES, TimeUnit.MINUTES); redisTemplate.opsForValue().set(key, uniqueId + ":" + randomCode, EXPIRE_MINUTES, TimeUnit.MINUTES);
return JsonResult.buildSuccessResult("发送成功", uniqueId); return JsonResult.buildSuccessResult("发送成功", uniqueId);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -238,10 +238,10 @@ public class UserController implements IBaseController { ...@@ -238,10 +238,10 @@ public class UserController implements IBaseController {
LOGGER.info("用户注册失败,该手机号已经被注册, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户注册失败,该手机号已经被注册, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("该手机号已经被注册", null); return JsonResult.buildErrorStateResult("该手机号已经被注册", null);
} }
/*if (!smsService.validRegisterOrResetPasswdVerificationCode(phoneNo, verificationCode)) { if (!smsService.validRegisterOrResetPasswdVerificationCode(phoneNo, verificationCode)) {
LOGGER.info("用户注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode); LOGGER.info("用户注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode);
return JsonResult.buildErrorStateResult("短信验证码错误", null); return JsonResult.buildErrorStateResult("短信验证码错误", null);
}*/ }
if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId)) { if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId)) {
LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null); return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null);
......
package cn.quantgroup.xyqb.service.sms.impl; package cn.quantgroup.xyqb.service.sms.impl;
import cn.quantgroup.sms.MsgParams;
import cn.quantgroup.sms.SendAndForgetMsg; import cn.quantgroup.sms.SendAndForgetMsg;
import cn.quantgroup.sms.SmsSender; import cn.quantgroup.sms.SmsSender;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
...@@ -47,7 +48,9 @@ public class SmsServiceImpl implements ISmsService { ...@@ -47,7 +48,9 @@ public class SmsServiceImpl implements ISmsService {
@Override @Override
public void sendAfterRegister(String phoneNo) { public void sendAfterRegister(String phoneNo) {
try { try {
smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo)); MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", "24", Collections.emptyList());
smsSender.sendMsg(msgParams);
//smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo));
LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo); LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -97,7 +100,12 @@ public class SmsServiceImpl implements ISmsService { ...@@ -97,7 +100,12 @@ public class SmsServiceImpl implements ISmsService {
private boolean confirmSms(String smsVerificationCode, String unqiueId, String code) { private boolean confirmSms(String smsVerificationCode, String unqiueId, String code) {
if (StringUtils.equals(code, smsVerificationCode)) { if (StringUtils.equals(code, smsVerificationCode)) {
try { try {
smsSender.confirmSmsResult("1", unqiueId); //smsSender.confirmSmsResult("1", unqiueId);
MsgParams message = new MsgParams(Collections.singletonList(2), unqiueId);
MsgParams messageVoice = new MsgParams(Collections.singletonList(4), unqiueId);
getSmsSender().confirmMsg(message);
getSmsSender().confirmMsg(messageVoice);
LOGGER.info("confirmMsg send success, uniqueId={}", unqiueId);
} catch (Exception e) { } catch (Exception e) {
LOGGER.info("短信验证像短信中心确认失效"); LOGGER.info("短信验证像短信中心确认失效");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment