From 36be00e0f3cbe0d559c646fd2977e6e3a74aa6f9 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 30 Sep 2024 16:57:22 +0800
Subject: [PATCH] Merge branch 'bea' of http://120.27.238.55:7000/r/exchange into bea

---
 src/main/java/com/xcong/excoin/utils/mail/SmsSend.java |   64 ++++++++++++++++++++++++++------
 1 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/utils/mail/SmsSend.java b/src/main/java/com/xcong/excoin/utils/mail/SmsSend.java
index 9d21ddc..e2e8ed2 100644
--- a/src/main/java/com/xcong/excoin/utils/mail/SmsSend.java
+++ b/src/main/java/com/xcong/excoin/utils/mail/SmsSend.java
@@ -1,5 +1,6 @@
 package com.xcong.excoin.utils.mail;
 
+import cn.hutool.core.date.DateUtil;
 import net.sf.json.JSONObject;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
@@ -13,6 +14,8 @@
 import org.apache.http.util.EntityUtils;
 
 import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.Date;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -28,30 +31,68 @@
 
     public static final String TYPE_MD5 = "md5";
     public static final String TYPE_SHA1 = "sha1";
+
+    private static final String APP_ID = "51258";
+    private static final String APP_KEY = "a9b6e0758dc40d3c346887fc0e154642";
+    private static final String SIGN_TYPE = "";
     /**
      * API 请求接口配置
      */
     private static final String URL = "https://api.mysubmail.com/message/xsend";
 
 
+    /**
+     * 发送验证码
+     *
+     * @param telphone 手机号
+     * @param code     验证码
+     * @param time     超时时间
+     * @return
+     */
     public static boolean sendVerifyCode(String telphone, String code, int time) {
         TreeMap<String, Object> requestData = new TreeMap<String, Object>();
         JSONObject vars = new JSONObject();
 
-        String appid = "51258";
-        String appkey = "a9b6e0758dc40d3c346887fc0e154642";
         String project = "2CHnV3";
-        String signtype = "";
         vars.put("code", code);
         vars.put("time", time);
 
-        requestData.put("appid", appid);
+        requestData.put("appid", APP_ID);
         requestData.put("project", project);
         requestData.put("to", telphone);
         if (!vars.isEmpty()) {
             requestData.put("vars", vars.toString());
         }
+        return requestSend(requestData);
+    }
 
+    /**
+     * 发送充值成功消息
+     *
+     * @param phone   手机号
+     * @param time    充值时间
+     * @param amount  金额
+     * @param orderNo 订单号
+     */
+    public static void sendRechargeMsg(String phone, String time, String amount, String orderNo) {
+        TreeMap<String, Object> requestData = new TreeMap<String, Object>();
+        JSONObject vars = new JSONObject();
+        vars.put("time", time);
+        vars.put("price", amount);
+        vars.put("orderNo", orderNo);
+        String project = "Cqky91";
+        requestData.put("appid", APP_ID);
+        requestData.put("project", project);
+        requestData.put("to", phone);
+        if (!vars.isEmpty()) {
+            requestData.put("vars", vars.toString());
+        }
+
+        requestSend(requestData);
+    }
+
+
+    private static boolean requestSend(TreeMap<String, Object> requestData) {
         MultipartEntityBuilder builder = MultipartEntityBuilder.create();
         @SuppressWarnings("deprecation")
         ContentType contentType = ContentType.create(HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8);
@@ -62,17 +103,17 @@
                 builder.addTextBody(key, String.valueOf(value), contentType);
             }
         }
-        if (signtype.equals(TYPE_MD5) || signtype.equals(TYPE_SHA1)) {
+        if (SIGN_TYPE.equals(TYPE_MD5) || SIGN_TYPE.equals(TYPE_SHA1)) {
             String timestamp = getTimestamp();
             requestData.put("timestamp", timestamp);
-            requestData.put("sign_type", signtype);
-            String signStr = appid + appkey + RequestEncoder.formatRequest(requestData) + appid + appkey;
+            requestData.put("sign_type", SIGN_TYPE);
+            String signStr = APP_ID + APP_KEY + RequestEncoder.formatRequest(requestData) + APP_ID + APP_KEY;
 
             builder.addTextBody("timestamp", timestamp);
-            builder.addTextBody("sign_type", signtype);
-            builder.addTextBody("signature", RequestEncoder.encode(signtype, signStr), contentType);
+            builder.addTextBody("sign_type", SIGN_TYPE);
+            builder.addTextBody("signature", RequestEncoder.encode(SIGN_TYPE, signStr), contentType);
         } else {
-            builder.addTextBody("signature", appkey, contentType);
+            builder.addTextBody("signature", APP_KEY, contentType);
         }
 
         HttpPost httpPost = new HttpPost(URL);
@@ -97,7 +138,6 @@
 
     /**
      * 获取时间戳
-     *
      */
     private static String getTimestamp() {
         CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build();
@@ -119,6 +159,6 @@
     }
 
     public static void main(String[] args) {
-        sendVerifyCode("15773002834", "123456", 2);
+//        sendVerifyCode("15773002834", "123456", 2);
     }
 }

--
Gitblit v1.9.1