소스 검색

fix 当日输赢排行3

laowu 2 주 전
부모
커밋
7fbfb27582
2개의 변경된 파일72개의 추가작업 그리고 23개의 파일을 삭제
  1. 71 22
      app/Http/Controllers/Admin/WinLoseRankController.php
  2. 1 1
      resources/views/admin/win_lose_rank/index.blade.php

+ 71 - 22
app/Http/Controllers/Admin/WinLoseRankController.php

@@ -21,16 +21,16 @@ class WinLoseRankController extends Controller
         }
         $page = $q
             ->select([
-            'ruds.UserID',
-            'ruds.WinScore',
-            'ruds.LostScore',
-            'ruds.TotalBet',
-            DB::raw('CASE WHEN ruds.TotalBet > 0 THEN (ruds.WinScore - ruds.LostScore)/ruds.TotalBet ELSE 0 END as rtp'),
-            DB::raw('0 as sameRW'),
-            DB::raw('0 as KindID'), DB::raw('0 as TotalRecharge'), DB::raw('0 as TotalWithdraw'),
+                'ruds.UserID',
+                'ruds.WinScore',
+                'ruds.LostScore',
+                'ruds.TotalBet',
+                DB::raw('CASE WHEN ruds.TotalBet > 0 THEN (ruds.WinScore - ruds.LostScore)/ruds.TotalBet ELSE 0 END as rtp'),
+                DB::raw('0 as sameRW'),
+                DB::raw('0 as KindID'), DB::raw('0 as TotalRecharge'), DB::raw('0 as TotalWithdraw'),
                 DB::raw('\'\' as EmailAddress'), DB::raw('\'\' as PhoneNum'), DB::raw('0 as GameID'),
-        ])->where($condition)
-        ->paginate(15);
+            ])->where($condition)
+            ->paginate(15);
 
         if ($page->count() > 0) {
             $uids = array_column($page->items(), 'UserID');
@@ -51,28 +51,53 @@ class WinLoseRankController extends Controller
             foreach ($page->items() as $key => $item) {
                 $item->EmailAddress = $emails[$item->UserID] ?? '';
             }
+            // 身上的钱
+            $gameScores = DB::table('QPTreasureDB.dbo.GameScoreInfo')
+                ->lock('with(nolock)')
+                ->whereIn('UserID', $uids)
+                ->pluck('Score', 'UserID')->toArray();
+            // 待审核提现
+            $orderWtihdraws = DB::table('QPAccountsDB.dbo.OrderWithDraw')
+                ->lock('with(nolock)')
+                ->whereIn('UserID', $uids)
+                ->where('State', 1)
+                ->selectRaw('SUM(WithDraw) as WithDraw, UserID')
+                ->groupBy('UserID')
+                ->pluck('WithDraw', 'UserID')->toArray();
             $totals = DB::table('QPRecordDB.dbo.RecordUserTotalStatistics as ruts')->whereIn('UserID', $uids)
                 ->get()->toArray();
             foreach ($page->items() as $key => $item) {
-                foreach ($totals as  $total) {
+                $item->Score = $gameScores[$item->UserID] ?? 0;
+                $item->WithDrawWaitAudit = $orderWtihdraws[$item->UserID] ?? 0;
+                foreach ($totals as $total) {
                     if ($item->UserID == $total->UserID) {
                         $item->TotalRecharge = $total->Recharge;
                         $item->TotalWithdraw = $total->Withdraw;
                     }
                 }
             }
+
+            //关联用户信息
             $phones = array_filter(array_column($page->items(), 'PhoneNum'));
             $emails = array_filter(array_column($page->items(), 'EmailAddress'));
             $phoneRWs = [];
             if (count($phones) > 0) {
                 $phoneUids = DB::table('QPAccountsDB.dbo.AccountPhone')->whereIn('PhoneNum', $phones)
-                    ->pluck('UserID', 'PhoneNum')->toArray();
+                    ->get()->toArray();
                 if (count($phoneUids) > 0) {
-                    $res = DB::table('QPRecordDB.dbo.RecordUserTotalStatistics')->whereIn('UserID', $phoneUids)
+                    $res = DB::table('QPRecordDB.dbo.RecordUserTotalStatistics')
+                        ->whereIn('UserID', array_column($phoneUids, 'UserID'))
                         ->get();
                     foreach ($res as $row) {
-                        $phone = array_search($row->UserID, $phoneUids);
-                        $phoneRWs[$phone] = $row->Recharge - $row->Withdraw/NumConfig::NUM_VALUE;
+                        foreach ($phoneUids as $ap) {
+                            if ($ap->UserID == $row->UserID) {
+                                $phone = $ap->PhoneNum;
+                                if (!isset($phoneRWs[$phone])) {
+                                    $phoneRWs[$phone] = [];
+                                }
+                                $phoneRWs[$phone][$row->UserID] = $row->Recharge - $row->Withdraw / NumConfig::NUM_VALUE;
+                            }
+                        }
                     }
                 }
             }
@@ -80,21 +105,45 @@ class WinLoseRankController extends Controller
             if (count($emails) > 0) {
                 $emailUids = DB::table('QPAccountsDB.dbo.AccountWithdrawInfo')
                     ->whereIn('EmailAddress', $emails)
-                    ->pluck('UserID', 'EmailAddress')->toArray();
+                    ->get()->toArray();
                 if (count($emailUids) > 0) {
-                    $res = DB::table('QPRecordDB.dbo.RecordUserTotalStatistics')->whereIn('UserID', $emailUids)
+                    $res = DB::table('QPRecordDB.dbo.RecordUserTotalStatistics')
+                        ->whereIn('UserID', array_column($emailUids, 'UserID'))
                         ->get();
                     foreach ($res as $row) {
-                        $email = array_search($row->UserID, $emailUids);
-                        $emailRWs[$email] = $row->Recharge - $row->Withdraw/NumConfig::NUM_VALUE;
+                        foreach ($emailUids as $awi) {
+                            if ($awi->UserID == $row->UserID) {
+                                $email = $awi->EmailAddress;
+                                if (!isset($emailRWs[$email])) {
+                                    $emailRWs[$email] = [];
+                                }
+                                $emailRWs[$email][$row->UserID] = $row->Recharge - $row->Withdraw / NumConfig::NUM_VALUE;
+                            }
+                        }
                     }
                 }
             }
-
-            foreach ($page as $k => $v) {
-                $page[$k]->sameRW = ($emailRWs[$v->EmailAddress] ?? 0) + ($phoneRWs[$v->PhoneNum] ?? 0);
-                $page[$k]->KindID = $lockers[$v->UserID] ?? 0;
+            try {
+                foreach ($page as $k => $v) {
+                    $uidRws = [];
+                    if ($v->EmailAddress) {
+                        foreach ($emailRWs[$v->EmailAddress] ?? [] as $uid => $value) {
+                            $uidRws[$uid] = $value;
+                        }
+                    }
+                    if ($v->PhoneNum) {
+                        foreach ($phoneRWs[$v->PhoneNum] ?? [] as $uid => $value) {
+                            $uidRws[$uid] = $value;
+                        }
+                    }
+                    $page[$k]->sameRW = array_sum($uidRws) - ($uidRws[$v->UserID] ?? 0);
+                    $page[$k]->KindID = $lockers[$v->UserID] ?? 0;
+                }
+            } catch (\Exception $e) {
+                var_dump($e->getMessage());
+                return;
             }
+
         }
         $gameServerNames = DB::table(TableName::QPPlatformDB() . 'RoomConfig')
             ->pluck('RoomName', 'GameID')->toArray();

+ 1 - 1
resources/views/admin/win_lose_rank/index.blade.php

@@ -48,7 +48,7 @@
                                                 <td>{{ $row->GameID }}</td>
                                                 <td>{{ ($row->WinScore - $row->LostScore)/\App\Http\helper\NumConfig::NUM_VALUE }}</td>
                                                 <td>{{ $row->TotalBet ? ($row->WinScore - $row->LostScore)/$row->TotalBet : 0 }}</td>
-                                                <td>{{ $row->TotalRecharge - $row->TotalWithdraw/\App\Http\helper\NumConfig::NUM_VALUE }}</td>
+                                                <td>{{ $row->TotalRecharge - ($row->TotalWithdraw + $row->Score + $row->WithDrawWaitAudit)/\App\Http\helper\NumConfig::NUM_VALUE}}</td>
                                                 <td>{{ $row->sameRW }}</td>
                                                 <td>{{ $row->KindID == 0 ? '离线' : $gameServerNames[$row->KindID] ?? '' }}</td>
                                             </tr>