seven 2 nedēļas atpakaļ
vecāks
revīzija
ba7186bd84
1 mainītis faili ar 56 papildinājumiem un 11 dzēšanām
  1. 56 11
      app/Services/BetService.php

+ 56 - 11
app/Services/BetService.php

@@ -580,7 +580,7 @@ class BetService extends BaseService
         $noticeNum = rand($betNoticeMini, $betNoticeMax);
 
         $realNoticeNum = ceil($noticeNum / 2);
-
+        $openList = [];
         $bet_num = 0;
         foreach ($list->toArray() as $k => $v) {
             // $userInfo = UserService::findAll(['member_id' => $v['member_id']]);
@@ -589,6 +589,7 @@ class BetService extends BaseService
             $item = [];
             $item['id'] = $v['id'];
             $item['status'] = self::model()::STATUS_SETTLED;
+            
 
             if (in_array($v['keywords'], $awards)) {
                 // $profit = $v['amount'] * $v['odds'];
@@ -604,11 +605,11 @@ class BetService extends BaseService
 
                 // $yl = $profit - $amount;
                 $yl = bcsub($profit, $amount, 2); // 盈利
-                if ($k + 1 <= $realNoticeNum) {
-
-                    $text .= "{$v['keywords']} 【" . $lastStr . "】{$v['amount']} {$profit} {$yl}\n";
-                    $bet_num++;
-                }
+                // if ($k + 1 <= $realNoticeNum) {
+                    
+                //     // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$profit} {$yl}\n";
+                //     $bet_num++;
+                // }
                 // 结算
                 WalletService::updateBalance($v['member_id'], $profit);
 
@@ -616,15 +617,59 @@ class BetService extends BaseService
                 $balance = $walletInfo['available_balance'];
 
                 BalanceLogService::addLog($v['member_id'], $profit, $balance, ($balance + $profit), '中奖', $v['id'], '');
+
+                if(isset($openList[$v['member_id']])){
+                    $openList[$v['member_id']]['member_id'] = $v['member_id'];
+                    $openList[$v['member_id']]['first_name'] = $v['first_name'];
+                    $openList[$v['member_id']]['amount'] += $v['amount'];
+                    $openList[$v['member_id']]['profit'] += $profit;
+                    $openList[$v['member_id']]['lastStr'] = $lastStr;
+                }else{
+                    $openList[$v['member_id']]['member_id'] = $v['member_id'];
+                    $openList[$v['member_id']]['first_name'] = $v['first_name'];
+                    $openList[$v['member_id']]['amount'] = $v['amount'];
+                    $openList[$v['member_id']]['profit'] = $profit;
+                    $openList[$v['member_id']]['lastStr'] = $lastStr;
+                }
             } else {
-                if ($k + 1 <= $realNoticeNum) {
-                    $text .= "---- 【" . $lastStr . "】{$v['amount']} {$v['profit']} -{$v['amount']}\n";
-                    $bet_num++;
+
+                if(isset($openList[$v['member_id']])){
+                    $openList[$v['member_id']]['member_id'] = $v['member_id'];
+                    $openList[$v['member_id']]['first_name'] = $v['first_name'];
+                    $openList[$v['member_id']]['amount'] += $v['amount'];
+                    $openList[$v['member_id']]['lastStr'] = $lastStr;
+                }else{
+                    $openList[$v['member_id']]['member_id'] = $v['member_id'];
+                    $openList[$v['member_id']]['first_name'] = $v['first_name'];
+                    $openList[$v['member_id']]['amount'] = $v['amount'];
+                    $openList[$v['member_id']]['profit'] = 0;
+                    $openList[$v['member_id']]['lastStr'] = $lastStr;
                 }
+
+                // if ($k + 1 <= $realNoticeNum) {
+                //     // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$v['profit']} -{$v['amount']}\n";
+                //     $bet_num++;
+                // }
             }
 
             self::model()::where('id', $v['id'])->update($item);
         }
+
+        foreach($openList as $k => $v){
+            $amount = $v['amount'];
+            if($v['profit'] > 0){
+                $profit = number_format($v['profit'],2);
+                $yl = bcsub($v['profit'], $v['amount'], 2); // 盈利
+                $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} {$profit} {$yl}\n";
+            }else{
+                $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} 0 -{$amount}\n";
+            }
+            if(++$bet_num >= $realNoticeNum){
+                break;
+            }
+
+        }
+
         $inlineButton = self::getOperateButton();
 
         $rand_num = $noticeNum - $bet_num;
@@ -669,13 +714,13 @@ class BetService extends BaseService
                 // $yl = $profit - $amount;
                 $yl = bcsub($profit, $amount, 2); // 盈利
                 if ($k + 1 <= $rand_num) {
-                    $text .= "{$v['keywords']} 【" . $lastStr . "】 {$v['amount']} {$profit} {$yl}\n";
+                    $text .= "会员下注 【" . $lastStr . "】 {$v['amount']} {$profit} {$yl}\n";
                 }
             } else {
                 $v['amount'] = number_format($v['amount'],2);
 
                 if ($k + 1 <= $rand_num) {
-                    $text .= "---- 【" . $lastStr . "】 {$v['amount']} {$v['profit']} -{$v['amount']}\n";
+                    $text .= "会员下注 【" . $lastStr . "】 {$v['amount']} {$v['profit']} -{$v['amount']}\n";
                 }
             }