seven 3 天之前
父节点
当前提交
bf9a4a6f03
共有 1 个文件被更改,包括 42 次插入27 次删除
  1. 42 27
      app/Services/BetService.php

+ 42 - 27
app/Services/BetService.php

@@ -223,6 +223,17 @@ class BetService extends BaseService
             return $msg;
         }
 
+        $now_date = date('Y-m-d H:i:s',time() + 30); // 提前30秒
+        if($issueInfo['end_time'] < $now_date){
+            $text = "封盘中,本次下注无效!\n";
+
+            $msg['text'] = $text;
+            if ($messageId) {
+                $msg['reply_to_message_id'] = $messageId;
+            }
+            return $msg;
+        }
+
         // 投注限制校验
         if ($amount < $gameplayRuleInfo['mininum']) {
             $text = "下注失败,最小金额限制{$gameplayRuleInfo['mininum']}\n";
@@ -347,43 +358,47 @@ class BetService extends BaseService
             // 期数验证
             $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
             if ($issueInfo) {
-                $fake_bet_list = Cache::get('fake_bet_' . $issueInfo->issue_no, []);
+                $now_date = date('Y-m-d H:i:s',time() + 30); // 提前30秒
+                if($issueInfo['end_time'] > $now_date){
+                    $fake_bet_list = Cache::get('fake_bet_' . $issueInfo->issue_no, []);
 
-                $gameplayRuleList = GameplayRuleService::model()::where('odds', '>', 0)->get();
-                $gameplayRuleList = $gameplayRuleList->toArray();
-                $randKey = array_rand($gameplayRuleList, 1);
-                $gameplayRuleInfo = $gameplayRuleList[$randKey] ?? [];
-                if ($gameplayRuleInfo) {
+                    $gameplayRuleList = GameplayRuleService::model()::where('odds', '>', 0)->get();
+                    $gameplayRuleList = $gameplayRuleList->toArray();
+                    $randKey = array_rand($gameplayRuleList, 1);
+                    $gameplayRuleInfo = $gameplayRuleList[$randKey] ?? [];
+                    if ($gameplayRuleInfo) {
 
 
-                    $item = [];
-                    $item['keywords'] = $gameplayRuleInfo['keywords'];
-                    $item['odds'] = $gameplayRuleInfo['odds'];
-                    $item['amount'] = rand($gameplayRuleInfo['mininum'], $gameplayRuleInfo['maxinum']);
-                    $item['first_name'] = self::generateRandomString(6);
-                    $item['profit'] = 0;
-                    $input = $item['keywords'] . $item['amount'];
+                        $item = [];
+                        $item['keywords'] = $gameplayRuleInfo['keywords'];
+                        $item['odds'] = $gameplayRuleInfo['odds'];
+                        $item['amount'] = rand($gameplayRuleInfo['mininum'], $gameplayRuleInfo['maxinum']);
+                        $item['first_name'] = self::generateRandomString(6);
+                        $item['profit'] = 0;
+                        $input = $item['keywords'] . $item['amount'];
 
-                    $fake_bet_list[] = $item;
+                        $fake_bet_list[] = $item;
 
-                    $lastStr = self::getLastChar($item['first_name'], 1);
+                        $lastStr = self::getLastChar($item['first_name'], 1);
 
-                    $groupText = "";
-                    $groupText .= "私聊下注 【xxxxxx" . $lastStr . "】 \n";
-                    $groupText .= "下注期数:{$issueInfo->issue_no} \n";
-                    $groupText .= "下注内容: \n";
-                    $groupText .= "----------- \n";
-                    $groupText .= "{$input} \n";
-                    $groupText .= "----------- \n";
+                        $groupText = "";
+                        $groupText .= "私聊下注 【xxxxxx" . $lastStr . "】 \n";
+                        $groupText .= "下注期数:{$issueInfo->issue_no} \n";
+                        $groupText .= "下注内容: \n";
+                        $groupText .= "----------- \n";
+                        $groupText .= "{$input} \n";
+                        $groupText .= "----------- \n";
 
 
-                    $inlineButton = self::getOperateButton();
+                        $inlineButton = self::getOperateButton();
 
-                    // 群通知
-                    self::bettingGroupNotice($groupText, $inlineButton);   // 群通知
-                }
+                        // 群通知
+                        self::bettingGroupNotice($groupText, $inlineButton);   // 群通知
+                    }
 
-                Cache::put('fake_bet_' . $issueInfo->issue_no, $fake_bet_list, 500);
+                    Cache::put('fake_bet_' . $issueInfo->issue_no, $fake_bet_list, 500);
+                }
+                
 
 
             }