Ken 2 settimane fa
parent
commit
f53ac5f8a4
1 ha cambiato i file con 93 aggiunte e 93 eliminazioni
  1. 93 93
      app/Services/BetService.php

+ 93 - 93
app/Services/BetService.php

@@ -405,109 +405,109 @@ class BetService extends BaseService
         if ($maintenanceSwitch != 0) {
             return;
         }
+        //后台是否开启虚拟投注
+        $betFake = Config::where('field', 'bet_fake')->first()->val;
+        if ($betFake != 1) return;
 
 
-        $betFake = Config::where('field', 'bet_fake')->first()->val;
-        if ($betFake) {
-            // 期数验证
-            $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
-            if ($pc28Switch == 1) {
-                $issueInfo = PcIssue::where('status', PcIssue::STATUS_BETTING)->orderBy('id', 'desc')->first();
-            } else {
-                $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
-            }
+        // 期数验证
+        $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
+        if ($pc28Switch == 1) {
+            $issueInfo = PcIssue::where('status', PcIssue::STATUS_BETTING)->orderBy('id', 'desc')->first();
+        } else {
+            $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
+        }
 
-            if ($issueInfo) {
-                $betFakeRandAmount = Config::where('field', 'bet_fake_rand_amount')->first()->val;
-                $betFakeRandAmount = explode(',', $betFakeRandAmount);
-                $betMini = $betFakeRandAmount[0] ?? 10;
-                $betMax = $betFakeRandAmount[1] ?? 10000;
-
-                $now_date = date('Y-m-d H:i:s', time() + 38); // 提前45秒
-                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();
-                    $member_id = self::generateRandomNumber(10);
-                    $betTimes = rand(1, $betNumber); // 每次下注次数
-                    Cache::add("封盘后下注单数_{$issueInfo->issue_no}", rand(3, 5), 4);
-
-
-                    $lastStr = self::hideMiddleDigits($member_id, 4);
-                    $lang = App::getLocale();
-                    $group_language = Config::where('field', 'group_language')->first()->val;
-                    $first_name = self::generateRandomString(6);
-                    App::setLocale($group_language);
-                    $groupText = lang("第") . "{$issueInfo->issue_no}" . lang("期") . "\n";
-                    $groupText .= lang("开奖时间") . ":" . date("H:i:s", strtotime($issueInfo['end_time'])) . "\n";
-                    $groupText .= lang('投注截止') . ":" . date("H:i:s", (strtotime($issueInfo['end_time'])) - 30) . "\n";;
-                    $groupText .= lang("成功") . "\n";
-                    $groupText .= lang('玩家') . ": 【{$lastStr}】 \n";
-                    App::setLocale($lang);
-                    $haveBet = false;
-                    for ($i = 0; $i < $betTimes; $i++) {
-                        if (strtotime($issueInfo['end_time']) - time() < IssueService::COUNTDOWN_TO_CLOSING_THE_MARKET) {
-                            $fake_bet_count = Cache::get("fake_bet_count_{$issueInfo->issue_no}", 0);
-                            $cc = Cache::get("封盘后下注单数_{$issueInfo->issue_no}");
-                            if ($fake_bet_count >= $cc) return;
-                        }
+        if ($issueInfo) {
+            $betFakeRandAmount = Config::where('field', 'bet_fake_rand_amount')->first()->val;
+            $betFakeRandAmount = explode(',', $betFakeRandAmount);
+            $betMini = $betFakeRandAmount[0] ?? 10;
+            $betMax = $betFakeRandAmount[1] ?? 10000;
 
+            $now_date = date('Y-m-d H:i:s', time() + 38); // 提前45秒
+            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();
+                $member_id = self::generateRandomNumber(10);
+                $betTimes = rand(1, $betNumber); // 每次下注次数
+                Cache::add("封盘后下注单数_{$issueInfo->issue_no}", rand(3, 5), 4);
 
-                        $randKey = array_rand($gameplayRuleList, 1);
-                        $gameplayRuleInfo = $gameplayRuleList[$randKey] ?? [];
-                        if ($gameplayRuleInfo) {
-                            if (in_array($gameplayRuleInfo['keywords'], $noRule)) {
-                                return;
-
-                            }
-                            if ($gameplayRuleInfo['maxinum'] < $betMax) {
-                                $betMax = $gameplayRuleInfo['maxinum'];
-                            }
-                            if ($gameplayRuleInfo['mininum'] > $betMini) {
-                                $betMini = $gameplayRuleInfo['mininum'];
-                            }
-
-                            $amount = rand($betMini, $betMax);
-                            $amount = floor($amount / 10) * 10;
-                            $input = $gameplayRuleInfo['keywords'] . ' ' . $amount;
-                            // $amount = number_format($amount,2);
-                            $item = [];
-                            $item['keywords'] = $gameplayRuleInfo['keywords'];
-                            $item['odds'] = floatval($gameplayRuleInfo['odds']);
-                            $item['amount'] = $amount;
-                            $item['first_name'] = $first_name;
-                            $item['member_id'] = $member_id;
-                            $item['profit'] = 0;
-                            // $input = $item['keywords'] . $item['amount'];
-
-                            $fake_bet_list[] = $item;
-                            $lang = App::getLocale();
-                            $group_language = Config::where('field', 'group_language')->first()->val;
-                            $first_name = self::generateRandomString(6);
-                            App::setLocale($group_language);
-                            $groupText .= "{$input} (" . $item['odds'] . lang("倍率") . ") \n";
-                            $haveBet = true;
-                            App::setLocale($lang);
-
-                            if (strtotime($issueInfo['end_time']) - strtotime($now_date) < 22) {
-                                $fake_bet_count = Cache::get("fake_bet_count_{$issueInfo->issue_no}", 0);
-                                Cache::put("fake_bet_count_{$issueInfo->issue_no}", $fake_bet_count + 1, 500);
-                            }
-                        }
-                    }
-                    if ($haveBet) {
-                        $groupText .= "\n-------- \n";
-                        $inlineButton = self::getOperateButton();
-                        // 群通知  暂停2秒再发送,避免同时发送多个消息而超过 Telegram 的频率限制
-                        self::asyncBettingGroupNotice($groupText, $inlineButton);   // 异步群通知
-                        sleep(2);
+
+                $lastStr = self::hideMiddleDigits($member_id, 4);
+                $lang = App::getLocale();
+                $group_language = Config::where('field', 'group_language')->first()->val;
+                $first_name = self::generateRandomString(6);
+                App::setLocale($group_language);
+                $groupText = lang("第") . "{$issueInfo->issue_no}" . lang("期") . "\n";
+                $groupText .= lang("开奖时间") . ":" . date("H:i:s", strtotime($issueInfo['end_time'])) . "\n";
+                $groupText .= lang('投注截止') . ":" . date("H:i:s", (strtotime($issueInfo['end_time'])) - 30) . "\n";;
+                $groupText .= lang("成功") . "\n";
+                $groupText .= lang('玩家') . ": 【{$lastStr}】 \n";
+                App::setLocale($lang);
+                $haveBet = false;
+                for ($i = 0; $i < $betTimes; $i++) {
+                    if (strtotime($issueInfo['end_time']) - time() < IssueService::COUNTDOWN_TO_CLOSING_THE_MARKET) {
+                        $fake_bet_count = Cache::get("fake_bet_count_{$issueInfo->issue_no}", 0);
+                        $cc = Cache::get("封盘后下注单数_{$issueInfo->issue_no}");
+                        if ($fake_bet_count >= $cc) return;
                     }
 
-                    Cache::put('fake_bet_' . $issueInfo->issue_no, $fake_bet_list, 500);
-                }
 
+                    $randKey = array_rand($gameplayRuleList, 1);
+                    $gameplayRuleInfo = $gameplayRuleList[$randKey] ?? [];
+                    if ($gameplayRuleInfo) {
+                        if (in_array($gameplayRuleInfo['keywords'], $noRule)) {
+                            return;
+
+                        }
+                        if ($gameplayRuleInfo['maxinum'] < $betMax) {
+                            $betMax = $gameplayRuleInfo['maxinum'];
+                        }
+                        if ($gameplayRuleInfo['mininum'] > $betMini) {
+                            $betMini = $gameplayRuleInfo['mininum'];
+                        }
 
+                        $amount = rand($betMini, $betMax);
+                        $amount = floor($amount / 10) * 10;
+                        $input = $gameplayRuleInfo['keywords'] . ' ' . $amount;
+                        // $amount = number_format($amount,2);
+                        $item = [];
+                        $item['keywords'] = $gameplayRuleInfo['keywords'];
+                        $item['odds'] = floatval($gameplayRuleInfo['odds']);
+                        $item['amount'] = $amount;
+                        $item['first_name'] = $first_name;
+                        $item['member_id'] = $member_id;
+                        $item['profit'] = 0;
+                        // $input = $item['keywords'] . $item['amount'];
+
+                        $fake_bet_list[] = $item;
+                        $lang = App::getLocale();
+                        $group_language = Config::where('field', 'group_language')->first()->val;
+                        $first_name = self::generateRandomString(6);
+                        App::setLocale($group_language);
+                        $groupText .= "{$input} (" . $item['odds'] . lang("倍率") . ") \n";
+                        $haveBet = true;
+                        App::setLocale($lang);
+
+                        if (strtotime($issueInfo['end_time']) - strtotime($now_date) < 22) {
+                            $fake_bet_count = Cache::get("fake_bet_count_{$issueInfo->issue_no}", 0);
+                            Cache::put("fake_bet_count_{$issueInfo->issue_no}", $fake_bet_count + 1, 500);
+                        }
+                    }
+                }
+                if ($haveBet) {
+                    $groupText .= "\n-------- \n";
+                    $inlineButton = self::getOperateButton();
+                    // 群通知  暂停2秒再发送,避免同时发送多个消息而超过 Telegram 的频率限制
+                    self::asyncBettingGroupNotice($groupText, $inlineButton);   // 异步群通知
+                    sleep(2);
+                }
+
+                Cache::put('fake_bet_' . $issueInfo->issue_no, $fake_bet_list, 500);
             }
+
+
         }
 
     }