From c6ad3eb590eb5c58341569a631e23fa03cb34a9e Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Thu, 27 Oct 2022 20:40:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Command/JinlingCommand.php | 63 +++++++++++++++++++++++++++++++++- app/Model/DeviceRecord.php | 10 ++++++ app/Model/UserLoginRecord.php | 10 ++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 app/Model/DeviceRecord.php create mode 100644 app/Model/UserLoginRecord.php diff --git a/app/Command/JinlingCommand.php b/app/Command/JinlingCommand.php index c239603..8e1b4fd 100644 --- a/app/Command/JinlingCommand.php +++ b/app/Command/JinlingCommand.php @@ -5,6 +5,8 @@ declare(strict_types=1); namespace App\Command; use App\Helper\Client\Lanhuo; +use App\Model\DeviceRecord; +use App\Model\UserLoginRecord; use Hyperf\Command\Command as HyperfCommand; use Hyperf\Command\Annotation\Command; use Hyperf\Contract\ContainerInterface; @@ -93,6 +95,65 @@ class JinlingCommand extends HyperfCommand 'status' => 1, //支付状态(待支付 0 已支付 1 支付失败 2) ]); */ - var_dump(Lanhuo::auth()); + // var_dump(Lanhuo::auth()); + } + + public function deleteUserLoginRecord() { + $gameIds = $this->getNeedDeleteGameIds(); + $this->info('deleteUserLoginRecord:' . implode(',', $gameIds)); + foreach ($gameIds as $gameId) { + $this->deleteUserLoginRecordByGameId($gameId); + } + } + + private function getNeedDeleteGameIds() { + $gameIds = explode(',', '274,229,230,199,197,189,172,168,77,164,159,224,200,198,190,173,169,78,165,160,221,225,226,271'); + $gameIds = array_merge($gameIds, explode(',', '201,155,217,237,269,202,156,218,238,270')); + $gameIds = array_merge($gameIds, explode(',', '193,183,179,203,209,227,241,243,249,251,194,184,180,204,210,228,242,244,250,252')); + $gameIds = array_merge($gameIds, explode(',', '153,231,258,272,291,154,232,259,273,292')); + $gameIds = array_merge($gameIds, explode(',', '213,214,233,234')); + 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 . ' ======='); } } \ No newline at end of file diff --git a/app/Model/DeviceRecord.php b/app/Model/DeviceRecord.php new file mode 100644 index 0000000..fbc4344 --- /dev/null +++ b/app/Model/DeviceRecord.php @@ -0,0 +1,10 @@ +