| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Services;
- use App\Facade\TableName;
- use Illuminate\Support\Facades\DB;
- class GamesCount
- {
- // 游戏对局【局数】
- public function gameCount($UserID)
- {
- $openGames = config('games.openKGame');
- // 游戏名称
- $gameNames = DB::table(TableName::QPPlatformDB() . 'GameKindItem')
- ->whereIn('KindID', $openGames)
- ->select('KindName', 'KindID')
- ->pluck('KindName', 'KindID')->toArray();
- // 用户游戏局数
- $gameCount = DB::table(TableName::QPRecordDB() . 'RecordUserGameCount')
- ->where('UserID',$UserID)
- ->whereIn('GameID', $openGames)
- ->pluck('Cnt', 'GameID')->toArray();
- $data = [];
- foreach ($gameNames as $key => &$value){
- $data[$value] = $gameCount[$key] ?? 0;
- }
- return $data;
- }
- }
|