pending()->where('unlock_at', '<=', $at) ->select('agent_id')->distinct()->chunkById(200, function ($agents) use ($wallets, $at, &$released, &$failed) { foreach ($agents as $agent) { try { $released += $wallets->releaseManualCredits((int) $agent->agent_id, $at); } catch (\Throwable $e) { ++$failed; report($e); } } }, 'agent_id'); $this->info("已解锁 {$released} 笔,失败 {$failed} 个账户"); return $failed === 0 ? self::SUCCESS : self::FAILURE; } }