|
|
@@ -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();
|