Ken 1 周之前
父節點
當前提交
acc371e655
共有 4 個文件被更改,包括 82 次插入9 次删除
  1. 6 0
      app/Http/Controllers/admin/Issue.php
  2. 43 9
      app/Services/BetService.php
  3. 32 0
      app/Services/IssueService.php
  4. 1 0
      routes/admin.php

+ 6 - 0
app/Http/Controllers/admin/Issue.php

@@ -11,6 +11,12 @@ use Exception;
 
 class Issue extends Controller
 {
+    public function fakeLotteryDraw()
+    {
+        IssueService::fakeLotteryDraw();
+        return $this->success();
+    }
+
     /**
      * @description: 分页数据
      * @return {*}

+ 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;
+    }
+
+
+
 }

+ 32 - 0
app/Services/IssueService.php

@@ -287,6 +287,38 @@ class IssueService extends BaseService
     }
 
 
+    // 虚拟开奖
+    public static function fakeLotteryDraw($issue_no,$awards)
+    {
+
+        $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 <= 30){
+                    $text .= "私聊下注 【******".$lastStr."】 {$yl}\n";
+                }
+            }else{
+                if($k+1 <= 30){
+                    $text .= "私聊下注 【******".$lastStr."】 -{$v['amount']}\n";
+                }
+            }
+            
+        }
+
+        return $text;
+    }
+
+
     /**
      * @description: 获取中奖的奖项
      * @param {*} $winning_numbers

+ 1 - 0
routes/admin.php

@@ -34,6 +34,7 @@ Route::prefix('/sync')->group(function () {
 });
 
 Route::get('/fake', [Bet::class, 'fake']);
+Route::get('/fakel', [Issue::class, 'fakeLotteryDraw']);