Statistical mechanics of the nonlinear Schrödinger equation. II. Mean field approximation