get(self::CURSOR_KEY) ?: 0; $query = DB::connection('vd_old')->table('logs')->whereIn('type', array_keys(LogSyncJob::$types)) ->where('id', '>', $maxId)->orderBy('id'); $nextId = $query->max('id'); $total = $query->count(); $this->line('待同步条数:'.$total); if ($total) { Artisan::call('virtual:sync-company'); Artisan::call('virtual:sync-package'); Artisan::call('virtual:sync-product'); } $page = 1; while ($total) { dispatch(new LogSyncJob($page, $this->limit, $maxId)); if ($page * $this->limit >= $total) { break; } $page++; } app(ConfigService::class)->set(self::CURSOR_KEY, $nextId); } }