From b640cc3489981365bf7edcc46dc9701c10f04eeb Mon Sep 17 00:00:00 2001
From: shicf <shi_chongfu@163.com>
Date: 星期五, 17 四月 2026 14:04:02 +0800
Subject: [PATCH] 凌凯短信
---
src/main/java/com/product/text/message/util/LinKaiSMSUtil.java | 124 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 124 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/product/text/message/util/LinKaiSMSUtil.java b/src/main/java/com/product/text/message/util/LinKaiSMSUtil.java
new file mode 100644
index 0000000..628232f
--- /dev/null
+++ b/src/main/java/com/product/text/message/util/LinKaiSMSUtil.java
@@ -0,0 +1,124 @@
+package com.product.text.message.util;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.stereotype.Service;
+
+import com.product.core.config.Global;
+import com.product.core.exception.BaseException;
+import com.product.core.message.ISMSService;
+import com.product.core.spring.context.SpringMVCContextHolder;
+import com.product.util.config.ErrorCode;
+
+/**
+ * 瀹炵幇鐭俊鍙戦��
+ * 鏈夊彉鏇达紝鍙﹀啓涓�涓柊绫伙紝瀹炵幇鎺ュ彛锛屽苟鍘绘帀鑰佺被鐨勫疄鐜扮被锛屽嵆鍙�
+ * @version 鍒涘缓鏃堕棿锛�2017骞�3鏈�27鏃� 涓嬪崍2:36:08
+ *
+ */
+@Service
+public class LinKaiSMSUtil implements ISMSService {
+ private static String Url = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
+ private static String CorpID="CDJS003057";//璐︽埛鍚�
+ private static String Pwd="zm0513@";//瀵嗙爜
+ private static String Signature="銆愭垚閮介緳娆h蒋浠舵湁闄愬叕鍙搞��";//绛惧悕 寰锋鼎缇庡 浼佷笟绠$悊骞冲彴 鎴愰兘榫欐绉戞妧
+ static Map<String,String> error=new HashMap<>();
+ static{
+ error.put("-1","璐﹀彿鏈敞鍐�");
+ error.put("-2","鍏朵粬閿欒:");
+ error.put("-3","甯愬彿鎴栧瘑鐮侀敊璇�");
+ error.put("-5","浣欓涓嶈冻锛岃鍏呭��");
+ error.put("-6","瀹氭椂鍙戦�佹椂闂翠笉鏄湁鏁堢殑鏃堕棿鏍煎紡");
+ error.put("-7","鎻愪氦淇℃伅鏈熬鏈姞绛惧悕锛岃娣诲姞涓枃鐨勪紒涓氱鍚嶃�愩��");
+ error.put("-8","鍙戦�佸唴瀹归渶鍦�1鍒�300瀛椾箣闂�");
+ error.put("-9","鍙戦�佸彿鐮佷负绌�");
+ error.put("-10","瀹氭椂鏃堕棿涓嶈兘灏忎簬绯荤粺褰撳墠鏃堕棿");
+ error.put("-11","灞忚斀鎵嬫満鍙风爜");
+ error.put("-100","IP榛戝悕鍗�");
+ error.put("-101","璋冪敤鎺ュ彛棰戠巼杩囧揩(澶т簬30s璋冪敤涓�娆�)");
+ error.put("-102","璐﹀彿榛戝悕鍗�");
+ error.put("-103","IP鏈鐧�");
+ }
+ /**鏋楀嚤-鐧奸�佺煭淇℃帴鍙�*/
+ /**
+ *
+ */
+ @Override
+ public int sendSMS(String mobile,String content,String send_time) throws BaseException{
+ URL url = null;
+ content+=Signature;
+ try {
+ String send_content=URLEncoder.encode(content.replaceAll("<br/>", " "), "GBK");//鍙戦�佸唴瀹�
+ url = new URL("https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID="+CorpID+"&Pwd="+Pwd+"&Mobile="+mobile+"&Content="+send_content+"&Cell=&SendTime="+send_time);
+ // url = new URL("https://sdk2.028lk.com/sdk2/SelSum.aspx?CorpID="+CorpID+"&Pwd="+Pwd); // 鏌ヨ鐭俊鍓╀綑鏉℃暟
+ BufferedReader in = null;
+ int inputLine = 0;
+ in = new BufferedReader(new InputStreamReader(url.openStream()));
+ inputLine = new Integer(in.readLine()).intValue();
+ SpringMVCContextHolder.getSystemLogger().info("鐭俊鍙戦�侊細"+content+",杩斿洖缁撴灉锛�"+inputLine);
+ if(inputLine<0) {
+ throw new BaseException(""+inputLine,""+error.get(""+inputLine));
+ }
+ return inputLine;
+ }catch(Exception e) {
+ e.printStackTrace();
+ throw new BaseException(ErrorCode.MESSAGE_SMS_SEND_FAIL);
+ }
+
+ }
+// /**鏋楀嚤-鐧奸�佺煭淇℃帴鍙�*/
+// @Override
+// public int sendSMS(String Mobile,String Content,String send_time)throws BaseException {
+// URL url = null;
+// Content+=Signature;
+// String send_content= null;//鍙戦�佸唴瀹�
+// try {
+// send_content = URLEncoder.encode(Content.replaceAll("<br/>", " "), "GBK");
+// url = new URL("https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID="+CorpID+"&Pwd="+Pwd+"&Mobile="+Mobile+"&Content="+send_content+"&Cell=&SendTime="+send_time);
+// } catch (UnsupportedEncodingException | MalformedURLException e) {
+// throw new BaseException("public int sendSMS(String Mobile,String Content,String send_time)throws BaseException",e.getMessage());
+// }
+// System.out.println("url锛�"+url.to);
+//// url = new URL("https://sdk2.028lk.com/sdk2/SelSum.aspx?CorpID="+CorpID+"&Pwd="+Pwd); // 鏌ヨ鐭俊鍓╀綑鏉℃暟
+// BufferedReader in = null;
+// int inputLine = 0;
+// try {
+// System.out.println("寮�濮嬪彂閫佺煭淇℃墜鏈哄彿鐮佷负 锛�"+Mobile);
+// in = new BufferedReader(new InputStreamReader(url.openStream()));
+// inputLine = new Integer(in.readLine()).intValue();
+// } catch (Exception e) {
+// e.printStackTrace();
+// System.out.println("缃戠粶寮傚父,鍙戦�佺煭淇″け璐ワ紒");
+// throw new BaseException("缃戠粶寮傚父,鍙戦�佺煭淇″け璐ワ紒-2",e.getMessage());
+// }
+// System.out.println("缁撴潫鍙戦�佺煭淇¤繑鍥炲�硷細 "+inputLine);
+// return inputLine;
+// }
+
+ public String SendSMS(String phoneNum) {
+ int mobile_code = (int)((Math.random()*9+1)*100000);
+ String content = new String("鎮ㄧ殑楠岃瘉鐮佹槸锛�" + mobile_code + "锛岃涓嶈鎶婇獙璇佺爜娉勯湶缁欏叾浠栦汉銆�");
+ int result;
+ try {
+ result = sendSMS(phoneNum, content, "");
+ if (result > 0) {
+ return mobile_code + "";
+ }
+ } catch (Exception e) {
+ return "-2";
+ }
+ return result + "";
+ }
+ public static void main(String[] args) {
+ LinKaiSMSUtil smsUtil = new LinKaiSMSUtil();
+ System.out.println(smsUtil.SendSMS("18030850875"));
+
+ }
+}
--
Gitblit v1.9.2