|
@@ -1,7 +1,12 @@
|
|
|
package com.ruoyi.common.utils;
|
|
|
|
|
|
|
|
|
+import cn.hutool.crypto.SecureUtil;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
|
|
|
/**阿里云
|
|
|
* @author tjf
|
|
@@ -75,5 +80,68 @@ public class SendSmsUtils {
|
|
|
}
|
|
|
return code;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 助通发送短信
|
|
|
+ * https://cloud.zthysms.com/#/login
|
|
|
+ * <!-- alibaba fastjson -->
|
|
|
+ * <dependency>
|
|
|
+ * <groupId>com.alibaba</groupId>
|
|
|
+ * <artifactId>fastjson</artifactId>
|
|
|
+ * <version>1.2.47</version>
|
|
|
+ * </dependency>
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * <!-- hutool util -->
|
|
|
+ * <dependency>
|
|
|
+ * <groupId>cn.hutool</groupId>
|
|
|
+ * <artifactId>hutool-all</artifactId>
|
|
|
+ * <version>5.0.5</version>
|
|
|
+ * </dependency>
|
|
|
+ *
|
|
|
+ * @param phone
|
|
|
+ * @param templateCode
|
|
|
+ * @param smsCode
|
|
|
+ */
|
|
|
+ public static String sendSmsTp(String phone, String templateCode, String smsCode) {
|
|
|
+ //地址
|
|
|
+ String urls = "https://api-shss.zthysms.com/v2/sendSmsTp";
|
|
|
+ //请求入参
|
|
|
+ JSONObject requestJson = new JSONObject();
|
|
|
+ //账号
|
|
|
+ requestJson.put("username", "ahzxy001");
|
|
|
+ //tKey
|
|
|
+ long tKey = System.currentTimeMillis() / 1000;
|
|
|
+ requestJson.put("tKey", tKey);
|
|
|
+ //明文密码
|
|
|
+ requestJson.put("password", SecureUtil.md5(SecureUtil.md5("1qaz!QAZ") + tKey));
|
|
|
+ //模板ID
|
|
|
+ requestJson.put("tpId", templateCode);
|
|
|
+ //签名
|
|
|
+ requestJson.put("signature", "【潜山市政协办公室】");
|
|
|
+ //扩展号
|
|
|
+ requestJson.put("ext", "");
|
|
|
+ //自定义参数
|
|
|
+ requestJson.put("extend", "");
|
|
|
+ //发送记录集合
|
|
|
+ JSONArray records = new JSONArray();
|
|
|
+ JSONObject record = new JSONObject();
|
|
|
+ //手机号
|
|
|
+ record.put("mobile", phone);
|
|
|
+ //替换变量
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("name", smsCode);
|
|
|
+ record.put("tpContent", param);
|
|
|
+ records.add(record);
|
|
|
+ requestJson.put("records", records);
|
|
|
+ String result = HttpRequest.post(urls)
|
|
|
+ .timeout(60000)
|
|
|
+ .body(requestJson.toJSONString(), MediaType.APPLICATION_JSON_UTF8_VALUE).execute().body();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ System.out.println(jsonObject);
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
+ return code;
|
|
|
+ }
|
|
|
}
|
|
|
|