|
@@ -6,21 +6,34 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
public class SMSUtils {
|
|
|
|
|
|
- /** key */
|
|
|
+ /**
|
|
|
+ * key
|
|
|
+ */
|
|
|
private static final String ACCOUNT = "account";
|
|
|
private static final String PASSWORD = "password";
|
|
|
- /** 通知短信 账户 */
|
|
|
+ /**
|
|
|
+ * 通知短信 账户
|
|
|
+ */
|
|
|
private static final String ACCOUNT_NOTICE = "N2532063";
|
|
|
private static final String PASSWORD_NOTICE = "jzVvYmuP4D7f1b";
|
|
|
- /** 验证码短信 账户 */
|
|
|
+ /**
|
|
|
+ * 验证码短信 账户
|
|
|
+ */
|
|
|
private static final String ACCOUNT_YZM = "YZM6372171";
|
|
|
private static final String PASSWORD_YZM = "1L8ZaIEW7fa3ca";
|
|
|
- /** 营销短信 账户 */
|
|
|
+ /**
|
|
|
+ * 营销短信 账户
|
|
|
+ */
|
|
|
private static final String ACCOUNT_ADS = "M1666161";
|
|
|
private static final String PASSWORD_ADS = "TO3xSGvEUk6ddc";
|
|
|
- /** 请求地址 */
|
|
|
+ /**
|
|
|
+ * 请求地址
|
|
|
+ */
|
|
|
private static final String SMS_URL = "http://smssh1.253.com/msg/send/json";
|
|
|
|
|
|
|
|
@@ -29,7 +42,7 @@ public class SMSUtils {
|
|
|
// private static String account = "0755cmxx";
|
|
|
// private static String password = "CaimeiSMS999";
|
|
|
|
|
|
- public static boolean sendSms(Integer type,String mobile, String content){
|
|
|
+ public static boolean sendSms(Integer type, String mobile, String content) {
|
|
|
|
|
|
// String res = SmsClientSend.sendSms(url, userid, account, password, mobile, content);
|
|
|
// return res.indexOf("Success") != -1;
|
|
@@ -50,27 +63,38 @@ public class SMSUtils {
|
|
|
// }
|
|
|
|
|
|
// 获取core服务器地址
|
|
|
- String coreServer = Global.getConfig("caimei.core");
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String uri = coreServer + "/tools/sms/send";
|
|
|
- // 发起Post请求
|
|
|
- MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>();
|
|
|
- paramMap.add("type", type.toString());
|
|
|
- paramMap.add("mobile", mobile);
|
|
|
- paramMap.add("content", content);
|
|
|
- String result = restTemplate.postForObject(uri, paramMap, String.class);
|
|
|
- System.out.println(result);
|
|
|
- JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
- if (null != json && json.getInteger("code") == 0) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add("15917362709");
|
|
|
+ list.add("15814011616");
|
|
|
+ list.add("13100721916");
|
|
|
+ list.add("15113936829");
|
|
|
+ list.add("15827317748");
|
|
|
+ list.add("18476937515");
|
|
|
+ list.add("18175515644");
|
|
|
+ if (list.contains(mobile)) {
|
|
|
+ String coreServer = Global.getConfig("caimei.core");
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ String uri = coreServer + "/tools/sms/send";
|
|
|
+ // 发起Post请求
|
|
|
+ MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>();
|
|
|
+ paramMap.add("type", type.toString());
|
|
|
+ paramMap.add("mobile", mobile);
|
|
|
+ paramMap.add("content", content);
|
|
|
+ String result = restTemplate.postForObject(uri, paramMap, String.class);
|
|
|
+
|
|
|
+ System.out.println(result);
|
|
|
+ JSONObject json = (JSONObject) JSONObject.parse(result);
|
|
|
+ if (null != json && json.getInteger("code") == 0) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
-// String e="abc";
|
|
|
-// System.out.println(sendSms(3,"1817515644", "【采美365】 尊敬的采美供应商用户,您在采美上架的商品“" + e + "”资质证书将于3个月后失效,请及时登录采美网站上传新证书。"));
|
|
|
-// System.out.println(sendSms("18175515644", "您短信验证码是:7895"));
|
|
|
+// public static void main (String[]args){
|
|
|
+//// String e="abc";
|
|
|
+//// System.out.println(sendSms(3,"1817515644", "【采美365】 尊敬的采美供应商用户,您在采美上架的商品“" + e + "”资质证书将于3个月后失效,请及时登录采美网站上传新证书。"));
|
|
|
+//// System.out.println(sendSms("18175515644", "您短信验证码是:7895"));
|
|
|
+// }
|
|
|
}
|
|
|
-}
|