From 021640e69b32dbd9b88a538402671c47f280df9e Mon Sep 17 00:00:00 2001
From: luo <2855143437@qq.com>
Date: 星期三, 31 一月 2024 15:50:00 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/IgoTravel into dev

---
 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java
index ef7a8ff..8f87624 100644
--- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java
+++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java
@@ -1,9 +1,17 @@
 package com.stylefeng.guns.modular.system.util;
 
 
+import cn.hutool.http.ContentType;
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.twilio.Twilio;
 import com.twilio.rest.api.v2010.account.Message;
 import com.twilio.type.PhoneNumber;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
 import javax.net.ssl.*;
 import java.io.*;
@@ -16,6 +24,7 @@
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+@Component
 public class SMSUtil {
 
     //无需修改,用于格式化鉴权头域,给"X-WSSE"参数赋值
@@ -266,4 +275,32 @@
             return false;
         }
     }
+
+
+
+
+
+    public boolean sendCellulantMessage(String toPhone, String msg){
+        String url = "https://sms.nalosolutions.com/smsbackend/Nal_resl/send-message/";
+        HttpRequest post = HttpUtil.createPost(url);
+        post.contentType(ContentType.JSON.toString());
+        JSONObject params = new JSONObject();
+        params.put("key", "ru#0flkf3993qh!!rg!@y4)nhwi08c#tg_vasek!ja)kvfnfjyoljoz(@nai(jkf");
+        params.put("msisdn", toPhone);
+        params.put("message", msg);
+        params.put("sender_id", "I-GO");
+        post.body(params.toJSONString());
+        HttpResponse execute = post.execute();
+        String body = execute.body();
+        execute.close();
+        System.err.println("短信:" + body);
+        JSONObject jsonObject = JSON.parseObject(body);
+        Integer status = jsonObject.getInteger("status");
+        if(null != status && 1701 == status){
+            return true;
+        }else{
+            System.err.println("短信发送失败:" + jsonObject.toJSONString());
+            return false;
+        }
+    }
 }

--
Gitblit v1.7.1