Commit e06f4648 authored by xuxin's avatar xuxin

Merge remote-tracking branch 'origin/staging' into staging

parents 284e3a45 f3e3e47d
...@@ -17,14 +17,15 @@ public class SmsUtils { ...@@ -17,14 +17,15 @@ public class SmsUtils {
private static final Logger log = LoggerFactory.getLogger(SmsUtils.class); private static final Logger log = LoggerFactory.getLogger(SmsUtils.class);
private static final int TIME_OUT=10*60; //10minues private static final int TIME_OUT = 10 * 60; //10minues
/** /**
* Generate and send the SMS one time password to user's phone with SMS. * Generate and send the SMS one time password to user's phone with SMS.
*
* @param phone * @param phone
*/ */
public static String sendSmsOTP(String phone) { public static String sendSmsOTP(String phone) {
String randomCode = createRandom(true,6); String randomCode = createRandom(true, 6);
DefaultProfile profile = DefaultProfile.getProfile("default", "LTAIODPWRh6stFca", "0SBDR59HsquSDEj9CFXNt9njTs2cCv"); DefaultProfile profile = DefaultProfile.getProfile("default", "LTAIODPWRh6stFca", "0SBDR59HsquSDEj9CFXNt9njTs2cCv");
IAcsClient client = new DefaultAcsClient(profile); IAcsClient client = new DefaultAcsClient(profile);
...@@ -37,19 +38,20 @@ public class SmsUtils { ...@@ -37,19 +38,20 @@ public class SmsUtils {
request.putQueryParameter("SignName", "防关联浏览器"); request.putQueryParameter("SignName", "防关联浏览器");
request.putQueryParameter("PhoneNumbers", phone); request.putQueryParameter("PhoneNumbers", phone);
request.putQueryParameter("TemplateCode", "SMS_185841618"); request.putQueryParameter("TemplateCode", "SMS_185841618");
request.putQueryParameter("TemplateParam", "{\"code\":\""+randomCode+"\"}"); request.putQueryParameter("TemplateParam", "{\"code\":\"" + randomCode + "\"}");
try { try {
CommonResponse response = client.getCommonResponse(request); CommonResponse response = client.getCommonResponse(request);
if (response.getHttpStatus() == 200 && response.getData().contains("OK")) { if (response.getHttpStatus() == 200 && response.getData().contains("OK")) {
return randomCode; return randomCode;
} else { } else {
log.error("fail to send sms {}", response.getData());
throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason()); throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason());
} }
} catch (ServerException e) { } catch (ServerException e) {
log.error("Sms sends failure",e); log.error("Sms sends failure", e);
throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason()); throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason());
} catch (ClientException e) { } catch (ClientException e) {
log.error("Sms sends failure",e); log.error("Sms sends failure", e);
throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason()); throw new ClientRequestException(AccountErrorCode.OTPSENDFAILS, AccountErrorCode.OTPSENDFAILS.getReason());
} }
......
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