seven 1 week ago
parent
commit
9541a0f1cc

+ 6 - 0
app/Http/Controllers/api/TelegramWebHook.php

@@ -346,6 +346,7 @@ class TelegramWebHook extends Controller
             $message = $callbackQuery->message;
             $from = $callbackQuery->from;
             $data = $callbackQuery->data; // 获取 callback_data
+            $callbackId = $callbackQuery->id; // 获取 callback_query 的 ID
             $m = new Message();
             $m->json = $data;
             $m->save();
@@ -370,6 +371,11 @@ class TelegramWebHook extends Controller
                 //给每个用户生成一个专属的USDT钱包
                 WalletService::getUserWallet($chatId);
 
+                // 查看余额弹窗
+                if($data === 'balanceAlert'){
+                    $alertText = WalletService::getBalance($chatId)['text'];
+                    WalletService::alertNotice($callbackId , $alertText);
+                }
 
                 //取消创建游戏
                 if ($data === "games@@cancel") {

+ 15 - 0
app/Services/BaseService.php

@@ -143,4 +143,19 @@ class BaseService
         }
         self::telegram()->sendMessage($botMsg);
     }
+
+    /**
+     * @description: 弹窗提示
+     * @param {*} $memberId
+     * @param {*} $address
+     * @return {*}
+     */
+    public static function alertNotice($callbackId ,$text)
+    {
+        self::telegram()->answerCallbackQuery([
+            'callback_query_id' => $callbackId,
+            'text' => $text,
+            'show_alert' => true // 显示为弹窗
+        ]);
+    }
 }

+ 6 - 5
app/Services/BetService.php

@@ -247,17 +247,18 @@ class BetService extends BaseService
         $groupText .= "{$input} \n";
         $groupText .= "----------- \n";
 
+        $username = config('services.telegram.username');
         $inlineButton = [];
         $inlineButton[] = [
-            ['text' => "查看余额", 'callback_data' => 'balance'],
-            ['text' => "✅唯一财务", 'callback_data' => 'finance']
+            ['text' => "查看余额", 'callback_data' => 'balanceAlert'],
+            ['text' => "✅唯一财务", 'callback_data' => 'financeAlert']
         ];
         $inlineButton[] = [
-            ['text' => "近期注单", 'callback_data' => 'recent_bets'],
-            ['text' => "今日流水", 'callback_data' => 'today_flow']
+            ['text' => "近期注单", 'callback_data' => 'betsAlert'],
+            ['text' => "今日流水", 'callback_data' => 'todayFlowAlert']
         ];
         $inlineButton[] = [
-            ['text' => "私聊下注", 'callback_data' => 'private_bet']
+            ['text' => "私聊下注", 'callback_data' => "@{$username}"]
         ];
         $inlineButton[] = [
             ['text' => "官方频道", 'url' => 'https://t.me/xxx']