seven há 6 dias atrás
pai
commit
a7ffe73de8
2 ficheiros alterados com 65 adições e 43 exclusões
  1. 43 9
      app/Services/BetService.php
  2. 22 34
      app/Services/IssueService.php

+ 43 - 9
app/Services/BetService.php

@@ -526,19 +526,53 @@ class BetService extends BaseService
         $inlineButton = self::getOperateButton();
 
         $rand_num = 30 - $bet_num;
-        for ($i = 0; $i < $rand_num; $i++) {
-            // 生成 -100000 到 100000 的随机数,但排除 -10 到 10 的范围
-            $randomNumber = random_int(-1000000, 1000000) / 100;
-            if ($randomNumber >= -10 && $randomNumber <= 10) {
-                // 如果落在 -10 到 10 之间,重新生成或调整
-                $randomNumber = $randomNumber < 0 ? -random_int(10, 100000) : random_int(10, 100000);
-            }
-            $text .= "私聊下注 【******】 {$randomNumber}\n";
-        }
+        $text .= self::fakeLotteryDraw($issue_no, $awards, $rand_num);
+        // for ($i = 0; $i < $rand_num; $i++) {
+        //     // 生成 -100000 到 100000 的随机数,但排除 -10 到 10 的范围
+        //     $randomNumber = random_int(-1000000, 1000000) / 100;
+        //     if ($randomNumber >= -10 && $randomNumber <= 10) {
+        //         // 如果落在 -10 到 10 之间,重新生成或调整
+        //         $randomNumber = $randomNumber < 0 ? -random_int(10, 100000) : random_int(10, 100000);
+        //     }
+        //     $text .= "私聊下注 【******】 {$randomNumber}\n";
+        // }
 
         // 群通知
         self::bettingGroupNotice($text, $inlineButton, '');
     }
 
 
+    // 虚拟开奖
+    public static function fakeLotteryDraw($issue_no,$awards,$rand_num = 30)
+    {
+
+        $fake_bet_list = Cache::get('fake_bet_'.$issue_no,[]);
+        $text = "";
+
+        foreach($fake_bet_list as $k => $v){
+            $lastStr = self::getLastChar($v['first_name'],1);
+            if(in_array($v['keywords'],$awards)){
+                $profit = $v['amount'] * $v['odds'];
+                if($profit > 880000){
+                    $profit = 880000; // 单注最高奖金880000
+                }
+                $item['profit'] = $profit;
+
+                $yl = $profit - $v['amount'];
+                if($k+1 <= $rand_num){
+                    $text .= "私聊下注 【******".$lastStr."】 {$yl}\n";
+                }
+            }else{
+                if($k+1 <= $rand_num){
+                    $text .= "私聊下注 【******".$lastStr."】 -{$v['amount']}\n";
+                }
+            }
+            
+        }
+
+        return $text;
+    }
+
+
+
 }

+ 22 - 34
app/Services/IssueService.php

@@ -288,46 +288,34 @@ class IssueService extends BaseService
 
 
     // 虚拟开奖
-    public static function fakeLotteryDraw()
+    public static function fakeLotteryDraw($issue_no,$awards)
     {
-         // 期数验证
-        $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,[]);
-            $winning_numbers = '5,6,2';
-            // 计算中奖
-            $awards = self::award(explode(',',$winning_numbers));
-            $text = "虚拟开奖\n";
-
-            foreach($fake_bet_list as $k => $v){
-                $lastStr = self::getLastChar($v['first_name'],1);
-
-                if(in_array($v['keywords'],$awards)){
-                    $profit = $v['amount'] * $v['odds'];
-                    if($profit > 880000){
-                        $profit = 880000; // 单注最高奖金880000
-                    }
-                    $item['profit'] = $profit;
 
-                    $yl = $profit - $v['amount'];
-                    if($k+1 <= 30){
+        $fake_bet_list = Cache::get('fake_bet_'.$issue_no,[]);
+        $text = "";
 
-                        $text .= "私聊下注 【******".$lastStr."】 {$yl}\n";
-                       
-                    }
-                  
-                }else{
-                    if($k+1 <= 30){
-                        $text .= "私聊下注 【******".$lastStr."】 -{$v['amount']}\n";
-                    }
+        foreach($fake_bet_list as $k => $v){
+            $lastStr = self::getLastChar($v['first_name'],1);
+            if(in_array($v['keywords'],$awards)){
+                $profit = $v['amount'] * $v['odds'];
+                if($profit > 880000){
+                    $profit = 880000; // 单注最高奖金880000
                 }
-                
-            }
+                $item['profit'] = $profit;
 
-            $inlineButton = self::getOperateButton();
-             // 群通知
-            self::bettingGroupNotice($text, $inlineButton, '');
+                $yl = $profit - $v['amount'];
+                if($k+1 <= 30){
+                    $text .= "私聊下注 【******".$lastStr."】 {$yl}\n";
+                }
+            }else{
+                if($k+1 <= 30){
+                    $text .= "私聊下注 【******".$lastStr."】 -{$v['amount']}\n";
+                }
+            }
+            
         }
+
+        return $text;
     }