Ken 1 ngày trước cách đây
mục cha
commit
ab33aa5138

+ 1 - 4
app/Http/Controllers/admin/Bet.php

@@ -41,10 +41,7 @@ class Bet extends Controller
     // 模拟下注
     public function fake()
     {
-        $num = rand(1,3);
-        for($i = 0;$i< $num;$i++){
-            BetService::fakeBet();
-        }
+
         return $this->success();
     }
 

+ 4 - 0
app/Jobs/FiveSecondTaskJob.php

@@ -2,6 +2,7 @@
 
 namespace App\Jobs;
 
+use App\Services\BetService;
 use App\Services\PcIssueService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldBeUnique;
@@ -57,6 +58,9 @@ class FiveSecondTaskJob implements ShouldQueue
             // 你的业务逻辑
             IssueService::getLatestIssue(); // 获取最新的期号
 
+            //随机虚拟投注//随机最大人数:3人
+            BetService::randomVirtualBetting(3);
+
             // 重要:使用类名而不是 self(),避免递归
             FiveSecondTaskJob::dispatch()->delay(now()->addSeconds(15));
 

+ 13 - 3
app/Services/BetService.php

@@ -259,9 +259,8 @@ class BetService extends BaseService
 
         if (empty($issueInfo)) {
             if ($pc28Switch == 1) {
-
                 $issueCloseInfo = PcIssue::where('status', PcIssue::STATUS_CLOSE)->orderBy('id', 'desc')->first();
-            }else{
+            } else {
                 $issueCloseInfo = IssueService::model()::where('status', IssueService::model()::STATUS_CLOSE)->orderBy('id', 'desc')->first();
             }
 
@@ -372,9 +371,20 @@ class BetService extends BaseService
         return true;
     }
 
+    //随机虚拟下注
+    public static function randomVirtualBetting($maxPeople = 1): void
+    {
+        $maxPeople = intval($maxPeople);
+        $maxPeople = max($maxPeople, 1);
+        $maxPeople = min($maxPeople, 20);
+        $num = rand(1, $maxPeople);
+        for ($i = 0; $i < $num; $i++) {
+            static::fakeBet();
+        }
+    }
 
     // 模拟下注
-    public static function fakeBet()
+    private static function fakeBet()
     {
         $noRule = ['0操', '27操'];
         // 防止一开就虚拟投注