From e143e08a77c00047048a5596bed1d674f967649d Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 18 Nov 2024 18:01:33 +0800
Subject: [PATCH] feat(mall): 更新短信发送功能并优化数据统计

---
 src/main/java/cc/mrbird/febs/mall/controller/CommonController.java |   15 -------
 src/main/resources/mapper/modules/MallSalesmanMapper.xml           |    2 
 src/main/java/cc/mrbird/febs/common/utils/InfobipSmsSend.java      |   47 +++++++++++++++++++++++
 pom.xml                                                            |    6 +++
 4 files changed, 55 insertions(+), 15 deletions(-)

diff --git a/pom.xml b/pom.xml
index 29148a4..3f933da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,12 @@
     </properties>
 
     <dependencies>
+        <!--        短信模块-->
+        <dependency>
+            <groupId>com.infobip</groupId>
+            <artifactId>infobip-api-java-client</artifactId>
+            <version>4.3.2</version>
+        </dependency>
 
         <dependency>
             <groupId>org.json</groupId>
diff --git a/src/main/java/cc/mrbird/febs/common/utils/InfobipSmsSend.java b/src/main/java/cc/mrbird/febs/common/utils/InfobipSmsSend.java
new file mode 100644
index 0000000..43d24b1
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/common/utils/InfobipSmsSend.java
@@ -0,0 +1,47 @@
+package cc.mrbird.febs.common.utils;
+
+import cn.hutool.core.util.StrUtil;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+
+import java.io.IOException;
+
+@Slf4j
+public class InfobipSmsSend {
+
+    public static boolean sendSms(String phone,String code){
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        MediaType mediaType = MediaType.parse("application/json");
+        String appId = "0988dc701f3b79a65e5cbf3769f10a59-8a62bea2-1e45-418d-ac93-eba20c0c4ce0";
+        String zw = StrUtil.format("您的验证码:{}。",code);
+        String yw = StrUtil.format("you code is :{}。",code);
+        String sender = "447491163443";
+        String to = phone;
+
+        RequestBody body = RequestBody.create(mediaType,
+                "{\"messages\":[{\"sender\":\""+sender+"\"" +
+                        ",\"destinations\":[{\"to\":\""+to+"\"}]" +
+                        ",\"content\":{\"text\":\""+zw+yw+"\"}}]}");
+        Request request = new Request.Builder()
+                .url("https://m3x5pw.api.infobip.com/sms/3/messages")
+                .method("POST", body)
+                .addHeader("Authorization", "App " + appId)
+                .addHeader("Content-Type", "application/json")
+                .addHeader("Accept", "application/json")
+                .build();
+        try {
+            client.newCall(request).execute();
+        } catch (IOException e) {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
+
+    public static void main(String[] args) {
+        sendSms("15274802129","123456");
+    }
+
+
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/controller/CommonController.java b/src/main/java/cc/mrbird/febs/mall/controller/CommonController.java
index 12fecbc..1fdb110 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/CommonController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/CommonController.java
@@ -8,30 +8,19 @@
 import cc.mrbird.febs.mall.dto.Base64UploadDto;
 import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
 import cc.mrbird.febs.mall.service.ICommonService;
-import cn.hutool.core.io.file.FileNameUtil;
-import cn.hutool.core.lang.UUID;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
-import com.thoughtworks.xstream.core.BaseException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import net.coobird.thumbnailator.Thumbnails;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.util.FileCopyUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
-import sun.misc.BASE64Encoder;
 
-import javax.imageio.ImageIO;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -64,9 +53,7 @@
 
         // 发送手机验证码
         if (AppContants.ACCOUNT_TYPE_MOBILE.equals(type)) {
-//            boolean result = Sms106Send.sendVerifyCode(account, code.toString(), 2);
-            boolean result = ZzSmsSend.sendALiYun(account, code.toString());
-//            boolean result = ZzSmsSend.sendVerifyCode(account, code.toString(), 2);
+            boolean result = InfobipSmsSend.sendSms(account, code.toString());
             if (result) {
                 Map<String, Object> map = new HashMap<>();
                 boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120);
diff --git a/src/main/resources/mapper/modules/MallSalesmanMapper.xml b/src/main/resources/mapper/modules/MallSalesmanMapper.xml
index 994a14b..a7a8dd5 100644
--- a/src/main/resources/mapper/modules/MallSalesmanMapper.xml
+++ b/src/main/resources/mapper/modules/MallSalesmanMapper.xml
@@ -41,7 +41,7 @@
                 </if>
             </if>
         </where>
-        group by a.city
+        group by a.city,a.province
     </select>
 
     <select id="selectSumOrderAmountByProvinceAndCity" resultType="java.math.BigDecimal">

--
Gitblit v1.9.1