container = $container; parent::__construct('jinling'); } public function configure() { parent::configure(); $this->setDescription('廖金灵测试'); } public function handle() { } public function deleteUserLoginRecord() { $gameIds = $this->getNeedDeleteGameIds(); $this->info('deleteUserLoginRecord:' . implode(',', $gameIds)); foreach ($gameIds as $gameId) { $this->deleteUserLoginRecordByGameId($gameId); } } private function getNeedDeleteGameIds() { $gameIds = explode(',', '175,185,262,275,282,293,295,297,303,305,311,323,327,331,333,337,339,343,345,351,355,357,359,176,186,263,276,283,294,296,298,304,306,312,324,328,332,334,338,340,344,346,352,356,358,360'); return $gameIds; } private function deleteUserLoginRecordByGameId($gameId) { $this->info('======= begin delete game_id ' . $gameId . ' ======='); $firstId = 0; $hasMore = true; do { $this->info('delete game_id ' . $gameId . ' from id' . $firstId); // UserLoginRecord::query()->where('game_id', $gameId)->where('id', '>=', $firstId)->limit(10000)->delete(); $record = UserLoginRecord::query()->where('game_id', $gameId)->first(); if (empty($record)) { $hasMore = false; } else { $firstId = $record->id; } } while($hasMore); $this->info('======= end delete game_id ' . $gameId . ' ======='); } public function deleteDeviceRecord() { $gameIds = $this->getNeedDeleteGameIds(); $this->info('deleteDeviceRecord:' . implode(',', $gameIds)); foreach ($gameIds as $gameId) { $this->deleteDeviceRecordByGameId($gameId); } } private function deleteDeviceRecordByGameId($gameId) { $this->info('======= begin delete game_id ' . $gameId . ' ======='); $firstId = 0; $hasMore = true; do { $this->info('delete game_id ' . $gameId . ' from id' . $firstId); // DeviceRecord::query()->where('game_id', $gameId)->where('id', '>=', $firstId)->limit(10000)->delete(); $record = DeviceRecord::query()->where('game_id', $gameId)->first(); if (empty($record)) { $hasMore = false; } else { $firstId = $record->id; } } while($hasMore); $this->info('======= end delete game_id ' . $gameId . ' ======='); } }