| 1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Console\Commands;
- use App\Services\Simulation\SimulationMemberService;
- use Illuminate\Console\Command;
- class SimulationRenameMembers extends Command
- {
- protected $signature = 'simulation:rename-members {--dry-run : 只统计会改多少,不写库}';
- protected $description = '给早期创建的模拟会员改名:去掉账号 sim_ 前缀和“模拟”昵称,换成随机的真实风格;不清空数据,可重复执行';
- public function handle(): int
- {
- $dryRun = (bool) $this->option('dry-run');
- try {
- $counts = SimulationMemberService::renameLegacy($dryRun);
- } catch (\Throwable $e) {
- $this->error($e->getMessage());
- return self::FAILURE;
- }
- $labels = ['members' => '涉及的模拟会员', 'accounts' => '改账号', 'nicknames' => '改昵称', 'ips' => '改注册 IP', 'login_logs' => '登录日志',
- 'third_game_orders' => '第三方注单', 'withdraw_orders' => '提现单', 'sport_orders' => '体育注单'];
- $this->info($dryRun ? '试运行,没有修改任何数据。将要改动:' : '已完成。改动:');
- foreach ($counts as $key => $count) $this->line(sprintf(' %s:%d', $labels[$key] ?? $key, $count));
- return self::SUCCESS;
- }
- }
|