Commit b29be75d by java-李谡

短信发送

parent 362dad5d
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package com.ejweb.core.conf; package com.ejweb.core.conf;
import com.ejweb.core.security.DES3Utils; import com.ejweb.core.security.DES3Utils;
import com.ejweb.core.util.Util;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
...@@ -78,9 +79,9 @@ public class SecurityPropertyPlaceholderConfigurer extends PropertyPlaceholderCo ...@@ -78,9 +79,9 @@ public class SecurityPropertyPlaceholderConfigurer extends PropertyPlaceholderCo
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(DES3Utils.encrypt("foctest", CONF_DESC_KEY)); // System.out.println(DES3Utils.encrypt("foctest", CONF_DESC_KEY));
System.out.println(DES3Utils.decrypt("dc6788486fc8fa46bdc79e88019874d2dba29c9323df0d41d422c89b73b481946acb4985946fc04c9e83784b79a27bf935e0dbe240259eb88daa2a68d7c26b3c05ef21acf1ec90e77072592f9207bf97", CONF_DESC_KEY)); // System.out.println(DES3Utils.decrypt("dc6788486fc8fa46bdc79e88019874d2dba29c9323df0d41d422c89b73b481946acb4985946fc04c9e83784b79a27bf935e0dbe240259eb88daa2a68d7c26b3c05ef21acf1ec90e77072592f9207bf97", CONF_DESC_KEY));
System.out.println(DES3Utils.decrypt("776b3d2f912b12f8", CONF_DESC_KEY)); // System.out.println(DES3Utils.decrypt("776b3d2f912b12f8", CONF_DESC_KEY));
System.out.println(DES3Utils.decrypt("6f2237c231b1464c6474030c906ec914", CONF_DESC_KEY)); System.out.println(DES3Utils.decrypt("f5c9d35c1df1eb31c0f15d23ee5af33d15ee14d1133b16ae580893ec603fc77c0057d3cccb34407d0505fc99a849cd7ee060d2c605d68b21ea7fea2a325dd4026e7f13e65e216d967bc7696f608fe56ef11ae4801b727c51d09bc4beb44b24f0", CONF_DESC_KEY));
} }
} }
...@@ -11,6 +11,7 @@ import com.ejweb.core.conf.GConstants; ...@@ -11,6 +11,7 @@ import com.ejweb.core.conf.GConstants;
import com.ejweb.core.fetcher.FetchEntity; import com.ejweb.core.fetcher.FetchEntity;
import com.ejweb.core.fetcher.HCFetcher; import com.ejweb.core.fetcher.HCFetcher;
import com.ejweb.core.util.IdWorker; import com.ejweb.core.util.IdWorker;
import com.ejweb.core.util.Util;
import com.ejweb.modules.message.bean.ShortMsgBean; import com.ejweb.modules.message.bean.ShortMsgBean;
import com.ejweb.modules.message.bean.ShortMsgListBean; import com.ejweb.modules.message.bean.ShortMsgListBean;
import com.ejweb.modules.message.bean.ShortMsgUserListBean; import com.ejweb.modules.message.bean.ShortMsgUserListBean;
...@@ -57,20 +58,34 @@ public class ShortMessageService extends BaseService<ShortMessageDao> { ...@@ -57,20 +58,34 @@ public class ShortMessageService extends BaseService<ShortMessageDao> {
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
String[] phones = phone.split(",|,"); String[] phones = phone.split(",|,");
boolean abroadPhone = false;
for (int i = 0, len = phones.length; i < len; i++) { for (int i = 0, len = phones.length; i < len; i++) {
if (i > 0) { if (i > 0) {
builder.append(","); builder.append(",");
} }
builder.append(phones[i].replaceAll("^0+", "")); //判断号码去掉开头的0之后是否是国内号码
String phone1 = phones[i].replaceAll("^0+", "");
if (Util.phoneReg(phone1)) {
builder.append(phone1);
} else {
builder.append(phones[i]);
abroadPhone = true;
}
} }
//电话号码去除空格,否则导致发送失败 //电话号码去除空格,否则导致发送失败
phone = builder.toString().trim(); phone = builder.toString().trim();
if (StringUtils.isEmpty(phone)) { if (StringUtils.isEmpty(phone)) {
return false; return false;
} }
String url = "";
if (abroadPhone) {
url = GConstants.JDAIR_SMS_API + "&mobile=" + phone + "&msg=" + URLEncoder.encode(bean.getMessage(), "UTF-8") + "&isInternetPhone=1";
} else {
url = GConstants.JDAIR_SMS_API + "&mobile=" + phone + "&msg=" + URLEncoder.encode(bean.getMessage(), "UTF-8");
}
logger.info("短信地址:" + url);
HCFetcher fetcher = HCFetcher.getInstance(); HCFetcher fetcher = HCFetcher.getInstance();
FetchEntity entity = fetcher.post(GConstants.JDAIR_SMS_API + "&mobile=" + phone + "&msg=" + URLEncoder.encode(bean.getMessage(), "UTF-8"), null); FetchEntity entity = fetcher.post(url, null);
if (entity != null && entity.isSuccess()) { if (entity != null && entity.isSuccess()) {
String resultStr = entity.getContent("utf-8"); String resultStr = entity.getContent("utf-8");
// 成功获取数据 // 成功获取数据
......
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