| 1234567891011121314151617181920212223 |
- <?php
- namespace App\Console\Commands;
- use App\Support\MemberAudience;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- class SyncUserType extends Command
- {
- protected $signature = 'users:sync-type';
- protected $description = '给前台新注册的游客(from = 2)补上 user_type = 1;游客转正后改回 0。后台模拟会员(2)不动';
- public function handle(): int
- {
- if (!MemberAudience::enabled()) return self::SUCCESS;
- $guests = DB::table('users')->where('from', '2')->where('user_type', 0)->update(['user_type' => 1]);
- $normal = DB::table('users')->where('user_type', 1)->where(fn ($q) => $q->whereNull('from')->orWhere('from', '<>', '2'))->update(['user_type' => 0]);
- if ($guests || $normal) $this->info("游客 +{$guests},转正 {$normal}");
- return self::SUCCESS;
- }
- }
|