|
|
@@ -14,18 +14,22 @@ class PlayedGameService
|
|
|
if ($memberIds === []) return [];
|
|
|
|
|
|
$played = [];
|
|
|
- $third = DB::table('third_game_orders as o')->join('users as u', function ($join) {
|
|
|
- $join->on('o.user_id', '=', 'u.id')->orWhere(function ($join) {
|
|
|
- $join->whereNull('o.user_id')->on('o.member_id', '=', 'u.member_id');
|
|
|
- });
|
|
|
- })->whereIn('u.member_id', $memberIds)
|
|
|
- ->where(function ($query) {
|
|
|
- $query->whereNull('o.member_id')->orWhere('o.member_id', '')->orWhereColumn('o.member_id', 'u.member_id');
|
|
|
- })
|
|
|
- ->whereIn('o.game_type', range(1, 7))->whereIn('o.status', [0, 1])->where('o.bet_amount', '>', 0);
|
|
|
- if ($start && $end) $third->whereBetween('o.bet_time', [$start, $end]);
|
|
|
- foreach ($third->distinct()->get(['u.member_id', 'o.game_type']) as $row) {
|
|
|
- $played[$row->member_id]['third:' . $row->game_type] = true;
|
|
|
+ $schema = DB::connection()->getSchemaBuilder();
|
|
|
+ // Game modules are optional; installations may not have every order table.
|
|
|
+ if ($schema->hasTable('third_game_orders')) {
|
|
|
+ $third = DB::table('third_game_orders as o')->join('users as u', function ($join) {
|
|
|
+ $join->on('o.user_id', '=', 'u.id')->orWhere(function ($join) {
|
|
|
+ $join->whereNull('o.user_id')->on('o.member_id', '=', 'u.member_id');
|
|
|
+ });
|
|
|
+ })->whereIn('u.member_id', $memberIds)
|
|
|
+ ->where(function ($query) {
|
|
|
+ $query->whereNull('o.member_id')->orWhere('o.member_id', '')->orWhereColumn('o.member_id', 'u.member_id');
|
|
|
+ })
|
|
|
+ ->whereIn('o.game_type', range(1, 7))->whereIn('o.status', [0, 1])->where('o.bet_amount', '>', 0);
|
|
|
+ if ($start && $end) $third->whereBetween('o.bet_time', [$start, $end]);
|
|
|
+ foreach ($third->distinct()->get(['u.member_id', 'o.game_type']) as $row) {
|
|
|
+ $played[$row->member_id]['third:' . $row->game_type] = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// sport_order.user_id stores the member ID, unlike third_game_orders.user_id (users.id).
|
|
|
@@ -38,8 +42,8 @@ class PlayedGameService
|
|
|
];
|
|
|
$startTimestamp = $start ? Carbon::parse($start, ShareDefaults::TIMEZONE)->timestamp : null;
|
|
|
$endTimestamp = $end ? Carbon::parse($end, ShareDefaults::TIMEZONE)->timestamp : null;
|
|
|
- $schema = DB::connection()->getSchemaBuilder();
|
|
|
foreach ($sources as [$table, $memberColumn, $timeColumn, $category, $statusColumn, $statuses, $timestamp]) {
|
|
|
+ if (!$schema->hasTable($table)) continue;
|
|
|
$query = DB::table($table)->whereIn($memberColumn, $memberIds)
|
|
|
->whereIn($statusColumn, $statuses)->where('amount', '>', 0);
|
|
|
// Historical lottery/sports tables may not contain this optional per-order flag.
|