doge пре 5 дана
родитељ
комит
f4ebdd8a9e
3 измењених фајлова са 37 додато и 14 уклоњено
  1. 11 5
      app/Jobs/SendTelegramGroupMessageJob.php
  2. 18 7
      app/Services/BetService.php
  3. 8 2
      app/Services/IssueService.php

+ 11 - 5
app/Jobs/SendTelegramGroupMessageJob.php

@@ -25,6 +25,7 @@ class SendTelegramGroupMessageJob implements ShouldQueue
     public $image;
     public $isTop;
     public $separator;
+    public $meta = [];
 
     /**
      * @param string $chatId
@@ -32,32 +33,37 @@ class SendTelegramGroupMessageJob implements ShouldQueue
      * @param array $buttons
      * @param string|null $image
      * @param string $separator 分隔符
+     * @param array $meta 日志上下文
      */
-    public function __construct($text, $buttons = [], $image = null, $isTop = false, $separator = "\n")
+    public function __construct($text, $buttons = [], $image = null, $isTop = false, $separator = "\n", $meta = [])
     {
         $this->text = $text;
         $this->buttons = $buttons;
         $this->image = $image;
         $this->isTop = $isTop;
         $this->separator = $separator;
+        $this->meta = $meta;
     }
 
     public function handle()
     {
+        $meta = is_array($this->meta) ? $this->meta : [];
         try {
             BaseService::bettingGroupNotice($this->text, $this->buttons, $this->image, $this->isTop, $this->separator);
-            Log::channel('issue')->info('Telegram群消息发送成功', [
+            Log::channel('issue')->info('Telegram群消息发送成功', array_merge([
                 'attempt' => $this->attempts(),
                 'text_length' => strlen((string)$this->text),
                 'has_image' => !empty($this->image),
                 'is_top' => $this->isTop,
-            ]);
+                'message_type' => $meta['message_type'] ?? 'unknown',
+            ], $meta));
         } catch (\Throwable $exception) {
-            $this->handleTelegramJobFailure($exception, 'Telegram群消息发送失败', [
+            $this->handleTelegramJobFailure($exception, 'Telegram群消息发送失败', array_merge([
                 'text_length' => strlen((string)$this->text),
                 'has_image' => !empty($this->image),
                 'is_top' => $this->isTop,
-            ], false);
+                'message_type' => $meta['message_type'] ?? 'unknown',
+            ], $meta), false);
         }
     }
 }

+ 18 - 7
app/Services/BetService.php

@@ -795,8 +795,8 @@ class BetService extends BaseService
         $sum = $otherSum + $fakeOtherSum;
         $betNoticeNum = Config::where('field', 'bet_notice_num')->first()->val;
         $betNoticeNum = explode(',', $betNoticeNum);
-        $betNoticeMini = $betNoticeNum[0] ?? 26;
-        $betNoticeMax = $betNoticeNum[1] ?? 38;
+        $betNoticeMini = max(1, (int)($betNoticeNum[0] ?? 26));
+        $betNoticeMax = max($betNoticeMini, (int)($betNoticeNum[1] ?? 38));
         $noticeNum = rand($betNoticeMini, $betNoticeMax);
 
         $realNoticeNum = ceil($noticeNum / 2);
@@ -1053,8 +1053,8 @@ class BetService extends BaseService
     {
         $betNoticeNum = Config::where('field', 'bet_notice_num')->first()->val;
         $betNoticeNum = explode(',', $betNoticeNum);
-        $betNoticeMini = $betNoticeNum[0] ?? 26;
-        $betNoticeMax = $betNoticeNum[1] ?? 38;
+        $betNoticeMini = max(1, (int)($betNoticeNum[0] ?? 26));
+        $betNoticeMax = max($betNoticeMini, (int)($betNoticeNum[1] ?? 38));
         $noticeNum = rand($betNoticeMini, $betNoticeMax);
         // shuffle($openList);
         // Log::error('lotteryNotice openList', $openList);
@@ -1065,7 +1065,10 @@ class BetService extends BaseService
         $text = "{$issue_no} " . lang("期开奖结果");
         $text .= "\n-----" . lang("本期开奖账单") . "----- \n";
         App::setLocale($lang);
-        foreach ($openList as $k => $v) {
+        $noticeIndex = 0;
+        $noticeRows = 0;
+        foreach ($openList as $v) {
+            $noticeIndex++;
 
 
             $amount = number_format($v['amount'], 2);
@@ -1079,7 +1082,8 @@ class BetService extends BaseService
                 $openKeyword = implode(',', $v['openKeywords']);
             }
 
-            if (($k + 1) <= $noticeNum) {
+            if ($noticeIndex <= $noticeNum) {
+                $noticeRows++;
                 $lang = App::getLocale();
                 $group_language = Config::where('field', 'group_language')->first()->val;
                 App::setLocale($group_language);
@@ -1133,8 +1137,15 @@ class BetService extends BaseService
                     'pc28_switch' => $pc28Switch,
                     'text_length' => strlen($text),
                     'open_list_count' => count($openList),
+                    'notice_num' => $noticeNum,
+                    'notice_rows' => $noticeRows,
                 ]);
-                SendTelegramGroupMessageJob::dispatch($text, $inlineButton, '', false, '--------------------------------')->afterCommit();
+                SendTelegramGroupMessageJob::dispatch($text, $inlineButton, '', false, '--------------------------------', [
+                    'message_type' => 'settlement_list',
+                    'issue_no' => $issue_no,
+                    'open_list_count' => count($openList),
+                    'notice_rows' => $noticeRows,
+                ])->afterCommit();
             } else {
                 Log::channel('issue')->info('结算列表群通知跳过', [
                     'issue_no' => $issue_no,

+ 8 - 2
app/Services/IssueService.php

@@ -385,13 +385,19 @@ class IssueService extends BaseService
 
                 }
                 // self::bettingGroupNotice($text, $buttons, $image, true);
-                if ($pc28Switch == 0) SendTelegramGroupMessageJob::dispatch($text, $buttons, $image, true)->afterCommit();
+                if ($pc28Switch == 0) SendTelegramGroupMessageJob::dispatch($text, $buttons, $image, true, "\n", [
+                    'message_type' => 'draw_result',
+                    'issue_no' => $info->issue_no,
+                ])->afterCommit();
             }
 
             $recordImage = self::lotteryImage($info->issue_no);
             if ($recordImage) {
                 // self::bettingGroupNotice('', [], url($recordImage));
-                if ($pc28Switch == 0) SendTelegramGroupMessageJob::dispatch('', [], url($recordImage), false)->afterCommit();
+                if ($pc28Switch == 0) SendTelegramGroupMessageJob::dispatch('', [], url($recordImage), false, "\n", [
+                    'message_type' => 'draw_history_image',
+                    'issue_no' => $info->issue_no,
+                ])->afterCommit();
             }
             $info->image = $recordImage;
             $info->save();