Commit 0917b70f authored by Java—红包—徐 然's avatar Java—红包—徐 然

Merge branch 'feature/apollo' of http://git.quantgroup.cn/head_group/xyqb-user2 into feature/apollo

# Conflicts:
#	src/main/java/cn/quantgroup/xyqb/service/sms/impl/SmsServiceImpl.java
parents ea79011a 5f0f7ec6
......@@ -5,6 +5,9 @@ import cn.quantgroup.sms.SmsSender;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.service.sms.ISmsService;
import lombok.Synchronized;
import java.util.Collections;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -14,19 +17,19 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Collections;
/**
* @author mengfan.feng
* @time 2015-07-25 18:47
*/
@Service
@Slf4j
public class SmsServiceImpl implements ISmsService {
private static final Logger LOGGER = LoggerFactory.getLogger(SmsServiceImpl.class);
private static final int SMS_VERIFICATION_MAXLEN = 4;
private static final String SMS_VERIFY_PREFIX = "sms:verify:";
private static SmsSender smsSender =null;
@Value("${sms.is.debug}")
private Boolean isDebug;
......@@ -43,13 +46,16 @@ public class SmsServiceImpl implements ISmsService {
return smsSender;
}
@Override
public void sendAfterRegister(String phoneNo) {
try {
MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", "24", Collections.emptyList());
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);
log.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -61,9 +67,10 @@ public class SmsServiceImpl implements ISmsService {
if (StringUtils.isBlank(contentId)) {
contentId = "24";
}
MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", contentId, Collections.emptyList());
MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", contentId,
Collections.emptyList());
smsSender.sendMsg(msgParams);
LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo);
log.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -71,13 +78,10 @@ public class SmsServiceImpl implements ISmsService {
/**
* 检查验证码是否正确
*
* @param phoneNo
* @param smsVerificationCode
* @return
*/
@Override
public boolean validRegisterOrResetPasswdVerificationCode(String phoneNo, String smsVerificationCode) {
public boolean validRegisterOrResetPasswdVerificationCode(String phoneNo,
String smsVerificationCode) {
//if (StringUtils.isEmpty(smsVerificationCode) || smsVerificationCode.length() != SMS_VERIFICATION_MAXLEN) {
// return false;
//}
......@@ -87,9 +91,9 @@ public class SmsServiceImpl implements ISmsService {
return false;
}
String[] arr = randomCode.split(":");
String unqiueId = arr[0];
String uniqueId = arr[0];
String code = arr[1];
return confirmSms(smsVerificationCode, unqiueId, code);
return confirmSms(smsVerificationCode, uniqueId, code);
}
@Override
......@@ -108,7 +112,6 @@ public class SmsServiceImpl implements ISmsService {
return confirmSms(verificationCode, uniqueId, code);
}
private boolean confirmSms(String smsVerificationCode, String unqiueId, String code) {
try {
MsgParams message = new MsgParams(Collections.singletonList(2), unqiueId);
......@@ -116,14 +119,10 @@ public class SmsServiceImpl implements ISmsService {
getSmsSender().confirmMsg(message);
//getSmsSender().confirmMsg(messageVoice);
//smsSender.confirmSmsResult("1", unqiueId);
LOGGER.info("confirmMsg send success, uniqueId={}", unqiueId);
log.info("confirmMsg send success, uniqueId={}", unqiueId);
} catch (Exception e) {
LOGGER.info("短信验证向短信中心确认失效");
log.info("短信验证向短信中心确认失效");
}
if (StringUtils.equals(code, smsVerificationCode)) {
return true;
return StringUtils.equals(code, smsVerificationCode);
}
return false;
}
}
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