Browse Source

Merge branch 'master' of http://47.76.126.2:3000/seven/bot-28

Ken 2 weeks ago
parent
commit
4d190bc1ba

+ 1 - 1
app/Http/Controllers/admin/Bet.php

@@ -49,7 +49,7 @@ class Bet extends Controller
     // 模拟下注
     public function fake()
     {
-        $num = rand(1,5);
+        $num = rand(1,3);
         for($i = 0;$i< $num;$i++){
             BetService::fakeBet();
         }

+ 27 - 0
app/Services/BaseService.php

@@ -8,6 +8,8 @@ use Telegram\Bot\Api;
 use App\Models\Config;
 use Telegram\Bot\FileUpload\InputFile;
 use Illuminate\Support\Facades\Log;
+use App\Jobs\SendTelegramMessageJob;
+use App\Jobs\SendTelegramGroupMessageJob;
 
 class BaseService 
 {
@@ -166,6 +168,18 @@ class BaseService
         
     }
 
+    /**
+     * @description: 异步群组通知
+     * @param {string} $text 通知内容
+     * @param {array} $keyboard 操作按钮
+     * @param {*string} $image  图片
+     * @return {*}
+     */
+    public static function asyncBettingGroupNotice($text ,$keyboard = [], $image = '' ,$isTop = false)
+    {
+        SendTelegramGroupMessageJob::dispatch($text ,$keyboard ,$image ,$isTop);
+    }
+
     /**
      * @description: 发送消息
      * @param {string} $chatId 聊天ID
@@ -193,6 +207,19 @@ class BaseService
         }
     }
 
+    /**
+     * @description: 异步发送消息
+     * @param {string} $chatId 聊天ID
+     * @param {string} $text 消息内容
+     * @param {array} $keyboard 操作按钮
+     * @param {*string} $image  图片
+     * @return {*}
+     */
+    public static function asyncSendMessage($chatId ,$text ,$keyboard = [] ,$image = '')
+    {
+        SendTelegramMessageJob::dispatch($chatId ,$text ,$keyboard ,$image);
+    }
+
     /**
      * @description: 弹窗提示
      * @param {*} $memberId

+ 5 - 3
app/Services/BetService.php

@@ -347,7 +347,8 @@ class BetService extends BaseService
         $inlineButton = self::getOperateButton();
 
         // 群通知
-        self::bettingGroupNotice($groupText, $inlineButton);   // 群通知
+        // self::bettingGroupNotice($groupText, $inlineButton);   // 群通知
+        self::asyncBettingGroupNotice($groupText, $inlineButton);   // 异步群通知
 
         return $msg;
     }
@@ -372,7 +373,7 @@ class BetService extends BaseService
                 $betMini = $betFakeRandAmount[0]??10;
                 $betMax = $betFakeRandAmount[1]??10000;
 
-                $now_date = date('Y-m-d H:i:s',time() + 30); // 提前30秒
+                $now_date = date('Y-m-d H:i:s',time() + 60); // 提前60秒
                 if($issueInfo['end_time'] > $now_date){
                     $fake_bet_list = Cache::get('fake_bet_' . $issueInfo->issue_no, []);
 
@@ -424,7 +425,8 @@ class BetService extends BaseService
                             $inlineButton = self::getOperateButton();
 
                             // 群通知
-                            self::bettingGroupNotice($groupText, $inlineButton);   // 群通知
+                            // self::bettingGroupNotice($groupText, $inlineButton);   // 群通知
+                            self::asyncBettingGroupNotice($groupText, $inlineButton);   // 异步群通知
                         }
                     }
                     Cache::put('fake_bet_' . $issueInfo->issue_no, $fake_bet_list, 500);

+ 6 - 3
app/Services/IssueService.php

@@ -208,7 +208,8 @@ class IssueService extends BaseService
             if ($image) {
                 $image = url($image);
             }
-            self::bettingGroupNotice($text, $buttons, $image);
+            // self::bettingGroupNotice($text, $buttons, $image);
+            self::asyncBettingGroupNotice($text, $buttons, $image);
         }
         $replyInfo = KeyboardService::findOne(['button' => '封盘开奖']);
         if ($replyInfo) {
@@ -218,7 +219,8 @@ class IssueService extends BaseService
             if ($image) {
                 $image = url($image);
             }
-            self::bettingGroupNotice($text, $buttons, $image);
+            // self::bettingGroupNotice($text, $buttons, $image);
+            self::asyncBettingGroupNotice($text, $buttons, $image);
         }
         return ['code' => self::YES, 'msg' => '封盘成功'];
     }
@@ -895,7 +897,8 @@ class IssueService extends BaseService
                     if (Cache::has('issue_countdown_' . $info->id)) {
 
                     } else {
-                        self::bettingGroupNotice($text, $buttons, $image);
+                        // self::bettingGroupNotice($text, $buttons, $image);
+                        self::asyncBettingGroupNotice($text, $buttons, $image);
                         Cache::put('issue_countdown_' . $info->id, true, 60); // 缓存50秒,防止多次发送
                     }