|
@@ -21,7 +21,9 @@ import java.util.Date;
|
|
|
*/
|
|
|
public class ZhuTongSender implements SmsSender {
|
|
|
|
|
|
- public final static String SENDER_SERVER_URL = "http://www.ztsms.cn/sendNSms.do";
|
|
|
+ private final static String SENDER_SERVER_URL = "http://www.ztsms.cn/sendNSms.do";
|
|
|
+
|
|
|
+ private final static String SUCCESS_CODE = "1";
|
|
|
|
|
|
private Logger log = LoggerFactory.getLogger(this.getClass());
|
|
|
private RestTemplate restTemplate = new RestTemplate();
|
|
@@ -42,7 +44,7 @@ public class ZhuTongSender implements SmsSender {
|
|
|
String url = buildURL(mobile, code, content);
|
|
|
|
|
|
String res = restTemplate.getForObject(url, String.class);
|
|
|
- if(log.isDebugEnabled()){
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
log.debug("【SMS】请求结果:{}", res);
|
|
|
}
|
|
|
String[] split = null;
|
|
@@ -52,7 +54,8 @@ public class ZhuTongSender implements SmsSender {
|
|
|
if (split != null && split.length == 2) {
|
|
|
res = split[0];
|
|
|
}
|
|
|
- if(!"1".equals(res)){
|
|
|
+
|
|
|
+ if (!SUCCESS_CODE.equals(res)) {
|
|
|
log.warn("【SMS】发送失败,手机号码:{}, 请求结果:{}", mobile, res);
|
|
|
throw new IFastApiException(EnumErrorCode.apiSmsSendFailed.getCodeStr());
|
|
|
}
|
|
@@ -65,24 +68,17 @@ public class ZhuTongSender implements SmsSender {
|
|
|
password = CodecUtils.md5Hex(CodecUtils.md5Hex(password) + tKey);
|
|
|
|
|
|
content = content.replace("{code}", code);
|
|
|
-// try {
|
|
|
-// content = URLEncoder.encode(content, "UTF-8");
|
|
|
-// } catch (UnsupportedEncodingException e) {
|
|
|
-// log.error("【SMS】编码转换异常");
|
|
|
-// }
|
|
|
+ // try {
|
|
|
+ // content = URLEncoder.encode(content, "UTF-8");
|
|
|
+ // } catch (UnsupportedEncodingException e) {
|
|
|
+ // log.error("【SMS】编码转换异常");
|
|
|
+ // }
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
- sb.append(SENDER_SERVER_URL)
|
|
|
- .append("?username=" + properties.getUname())
|
|
|
- .append("&tkey=" + tKey)
|
|
|
- .append("&password=" + password)
|
|
|
- .append("&content=" + content)
|
|
|
- .append("&mobile=" + mobile)
|
|
|
- .append("&productid=" + properties.getProductId())
|
|
|
- .append("&xh=");
|
|
|
-
|
|
|
- if(log.isDebugEnabled()){
|
|
|
- log.debug("【SMS】请求参数: {}",sb);
|
|
|
+ sb.append(SENDER_SERVER_URL).append("?username=" + properties.getUname()).append("&tkey=" + tKey).append("&password=" + password).append("&content=" + content).append("&mobile=" + mobile).append("&productid=" + properties.getProductId()).append("&xh=");
|
|
|
+
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
+ log.debug("【SMS】请求参数: {}", sb);
|
|
|
}
|
|
|
return sb.toString();
|
|
|
}
|