Pārlūkot izejas kodu

短信发送的修改

sandm 1 gadu atpakaļ
vecāks
revīzija
09b37c3c1c
1 mainītis faili ar 7 papildinājumiem un 0 dzēšanām
  1. 7 0
      app/common/api/ChuanglanSmsApi.php

+ 7 - 0
app/common/api/ChuanglanSmsApi.php

@@ -31,6 +31,13 @@ class ChuanglanSmsApi {
         $deny_list = ["jjrcw.test", "jjrcw.test:8080","report.com","report.jinjianghc.com"]; //拒绝短信名单
         if (in_array($_SERVER["HTTP_HOST"], $deny_list))
             return false; //测试不发送信息
+        $redis = \app\common\Redis::instance(\think\facade\Config::get("cache.stores.redis.select"));
+        $unique = sha1($mobile.$msg);
+        $time = $redis->get($unique);
+        $now = time();
+        if(!empty($time) && $now-$time < 10800){
+            return false;//3小时内同一个手机号码同一条信息不重复发送
+        }
         $result = $this->curlPost(self::API_SEND_URL, $postArr);
         return $result;
     }