seven 1 周之前
父节点
当前提交
debe9fa14f
共有 2 个文件被更改,包括 34 次插入4 次删除
  1. 2 4
      app/Http/Controllers/api/TelegramWebHook.php
  2. 32 0
      app/Services/IssueService.php

+ 2 - 4
app/Http/Controllers/api/TelegramWebHook.php

@@ -27,6 +27,7 @@ use Illuminate\Support\Facades\Log;
 use App\Models\Config;
 use App\Services\GameplayRuleService;
 use App\Services\BetService;
+use App\Services\IssueService;
 
 class TelegramWebHook extends Controller
 {
@@ -282,10 +283,7 @@ class TelegramWebHook extends Controller
                         break;
                     case "开奖历史":
                         Util::delCache($chatId);
-                        $this->telegram->sendMessage([
-                            'chat_id' => $chatId,
-                            'text' => $text
-                        ]);
+                        IssueService::currentLotteryResults($chatId);
                         break;
                     case "当期下注":
                         Util::delCache($chatId);

+ 32 - 0
app/Services/IssueService.php

@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Log;
 use App\Services\GameplayRuleService;
 use App\Constants\GameplayRuleEnum;
 use App\Services\KeyboardService;
+use Telegram\Bot\FileUpload\InputFile;
 
 /**
  * 投注
@@ -532,4 +533,35 @@ class IssueService extends BaseService
         }
         return $result; // 不在任何段中
     }
+
+    /**
+     * @description: 近期开奖记录
+     * @return {*}
+     */    
+    public static function currentLotteryResults($memberId)
+    {
+        $result = self::model()::where('status', self::model()::STATUS_DRAW)->orderBy('id','desc')->get();
+        if($result){
+            if($result->image){
+                self::telegram()->sendPhoto([
+                    'chat_id' => $memberId,
+                    'photo' => InputFile::create(url($result->image)),
+                ]);
+            }else{
+                // if($result->combo){
+                //     self::telegram()->sendMessage([
+                //         'chat_id' => $memberId,
+                //         'text' => "",
+                //     ]);
+                // }else{
+                    self::telegram()->sendMessage([
+                        'chat_id' => $memberId,
+                        'text' => "暂无开奖记录",
+                    ]);
+                // }
+                
+            }
+            
+        }
+    }
 }