seven hai 1 día
pai
achega
babefb7f51

+ 7 - 0
app/Http/Controllers/admin/Bet.php

@@ -34,6 +34,13 @@ class Bet extends Controller
         return $this->success($result);
     }
 
+    // 模拟下注
+    public function fake()
+    {
+        BetService::fakeBet();
+        return $this->success();
+    }
+
     // /**
     //  * @description: 修改|新增
     //  * @return {*}

+ 12 - 0
app/Services/BaseService.php

@@ -247,4 +247,16 @@ class BaseService
         $lastChar = mb_substr($str, $length - 1, $num, 'UTF-8');
         return $lastChar;
     }
+
+    public static function generateRandomString($length = 8) {
+        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+        $randomString = '';
+        
+        for ($i = 0; $i < $length; $i++) {
+            $randomString .= $characters[rand(0, strlen($characters) - 1)];
+        }
+        
+        return $randomString;
+    }
+
 }

+ 59 - 2
app/Services/BetService.php

@@ -3,6 +3,7 @@
 
 namespace App\Services;
 
+use App\Http\Controllers\admin\GameplayRule;
 use App\Services\BaseService;
 use App\Models\Bet;
 use App\Models\Config;
@@ -297,6 +298,57 @@ class BetService extends BaseService
         return $msg;
     }
 
+
+    // 模拟下注
+    public static function fakeBet()
+    {
+        
+        // 期数验证
+        $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,[]);
+
+            $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'];
+
+                $fake_bet_list[] = $item;
+
+                $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";
+
+                
+                $inlineButton = self::getOperateButton();
+                
+                // 群通知
+                self::bettingGroupNotice($groupText,$inlineButton);   // 群通知
+            }
+
+            Cache::put('fake_bet_'.$issueInfo->issue_no,$fake_bet_list,500);
+
+            
+
+        }
+    }
+
     /**
      * @description: 当期下注
      * @param {*} $memberId
@@ -428,6 +480,8 @@ class BetService extends BaseService
 
         $bet_num = 0;
         foreach($list->toArray() as $k => $v){
+            $userInfo = UserService::findAll(['member_id' => $v['member_id']]);
+            $lastStr = self::getLastChar($userInfo->first_name,1);
             $item = [];
             $item['id'] = $v['id'];
             $item['status'] =  self::model()::STATUS_SETTLED;
@@ -441,7 +495,8 @@ class BetService extends BaseService
 
                 $yl = $profit - $v['amount'];
                 if($k+1 <= 15){
-                    $text .= "私聊下注 【******】 {$yl}\n";
+
+                    $text .= "私聊下注 【******".$lastStr."】 {$yl}\n";
                     $bet_num++;
                 }
                 // 结算
@@ -453,7 +508,7 @@ class BetService extends BaseService
                 BalanceLogService::addLog($v['member_id'],$profit,$balance,($balance+$profit),'中奖',$v['id'],'');
             }else{
                 if($k+1 <= 15){
-                    $text .= "私聊下注 【******】 -{$v['amount']}\n";
+                    $text .= "私聊下注 【******".$lastStr."】 -{$v['amount']}\n";
                     $bet_num++;
                 }
             }
@@ -476,4 +531,6 @@ class BetService extends BaseService
          // 群通知
         self::bettingGroupNotice($text, $inlineButton, '');
     }
+
+
 }

+ 1 - 0
routes/admin.php

@@ -66,6 +66,7 @@ Route::middleware(['admin.jwt'])->group(function () {
         // 投注记录
         Route::prefix('/bet')->group(function () {
             Route::get('/', [Bet::class, 'index']);
+            Route::get('/fake', [Bet::class, 'fake']);
         });
 
         // 玩法规则路由