From 092750acd191ea00862d862d786bfd491e3fdb32 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 26 Mar 2021 11:54:18 +0800
Subject: [PATCH] 20210323  后台短信发送

---
 src/main/java/com/xcong/excoin/modules/Sms106Send.java |   66 ++++++++++++++------------------
 1 files changed, 29 insertions(+), 37 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/Sms106Send.java b/src/main/java/com/xcong/excoin/modules/Sms106Send.java
index c2f60bf..f7b4ce4 100644
--- a/src/main/java/com/xcong/excoin/modules/Sms106Send.java
+++ b/src/main/java/com/xcong/excoin/modules/Sms106Send.java
@@ -2,7 +2,9 @@
 
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Map;
 
+import cn.hutool.crypto.SecureUtil;
 import com.xcong.excoin.common.exception.GlobalException;
 
 import cn.hutool.core.date.DatePattern;
@@ -15,10 +17,11 @@
 @Slf4j
 public class Sms106Send {
 
-    private static final String URL = "http://www.qf106.com/sms.aspx";
-    private static final String ID = "16615";
-    private static final String ACCOUNT = "hibit";
-    private static final String PASSWORD = "123456";
+    private static final String URL = "http://zzsms365.com/v2sms.aspx?action=send";
+
+    private static final String USER_ID = "1654";
+    private static final String ACCOUNT = "1369815429";
+    private static final String PWD = "1369815429";
 
 
     /**
@@ -28,49 +31,38 @@
      * @return
      */
     public static boolean sendVerifyCode(String phone, String code, int time) {
-        String msg = "您的验证码是{},请在{}分钟内输入,请勿泄露给他人,如非本人操作,请及时修改密码。";
-        String content = StrUtil.format(msg, code, time);
-        return request(phone, content, "验证码");
+        String content = "【HiBit】您的验证码是{},请在{}分钟内输入,请勿泄露给他人,如非本人操作,请及时修改密码。";
+        return send(phone, StrUtil.format(content, code, time));
     }
 
-    public static boolean sendRechargeMsg(String phone, String time, String orderNo) {
-        String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,如有疑问请联系客服,订单编号为{}";
-        String content = StrUtil.format(msg, time, orderNo);
-        return request(phone, content, "充值");
+    public static boolean sendRechargeMsg(String telphone, Date time, String amount, String orderNo) {
+        String content = "【HiBit】尊敬的用户,恭喜您于{}有一笔充值已成功到账,充值数量为{}, 订单号为{}。";
+        return send(telphone, StrUtil.format(content, DateUtil.format(time, DatePattern.NORM_DATETIME_MINUTE_PATTERN), amount));
     }
 
-    public static boolean sendWithdrawalMsg(String phone, String time, String orderNo) {
-        String msg = "尊敬的用户,您的帐号于{}有一笔成功提现订单,如有疑问请联系客服,订单编号为{}";
-        String content = StrUtil.format(msg, time, orderNo);
-        return request(phone, content, "提现");
-    }
-    public static boolean sendWithdrawalCoinMsg(String phone, String time) {
-    	String msg = "尊敬的用户,您的帐号于{}有一笔成功提现订单,如有疑问请联系客服。";
-    	String content = StrUtil.format(msg, time);
-    	return request(phone, content, "提币");
+    public static boolean sendWithdrawalCoinMsg(String telphone, Date time, String amount) {
+        String content = "【HiBit】尊敬的用户,恭喜您于{}提现成功,数量为{}。";
+        return send(telphone, StrUtil.format(content, DateUtil.format(time, DatePattern.NORM_DATETIME_MINUTE_PATTERN), amount));
     }
 
-    private static boolean request(String phone, String content, String tagName) {
-        HashMap<String, Object> param = new HashMap<>();
-        param.put("userid", ID);
-        param.put("account", ACCOUNT);
-        param.put("password", PASSWORD);
-        param.put("mobile", phone);
-        param.put("content", content);
-        param.put("sendTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
-        param.put("action", "send");
-        param.put("checkcontent", 0);
-        param.put("taskName", tagName);
-        param.put("countnumber", 1);
-        param.put("mobilenumber", 1);
-        param.put("telephonenumber", 0);
+    private static boolean send(String telphone, String content) {
+        Map<String, Object> data = new HashMap<>();
+        Long time = System.currentTimeMillis();
+        data.put("userid", USER_ID);
+        data.put("timestamp", time);
+        data.put("mobile", telphone);
+        String signStr = ACCOUNT + PWD + time;
+        String sign = SecureUtil.md5(signStr);
+        data.put("sign", sign);
+        data.put("content", content);
 
-        String response = HttpUtil.post(URL, param);
-        log.info("发送短信:{}", response);
+        String response = HttpUtil.post(URL, data);
+        log.info("短信发送:{}", response);
         if ("Success".equals(XmlUtil.xmlToMap(response).get("returnstatus"))) {
             return true;
         } else {
-            throw new GlobalException((String) XmlUtil.xmlToMap(response).get("message"));
+//            throw new GlobalException((String) XmlUtil.xmlToMap(response).get("message"));
+            return false;
         }
     }
 

--
Gitblit v1.9.1