Derivation of Ginzburg-Landau
We need to calculate free energy, $\Omega = -T \ln \cal{Z}$, for Hamiltonian $H = H_0 + V$. From perturbation theory, the partition function
$${\cal{Z}} = e^{-\beta H} = e^{-\Omega_0}\sum_n \frac{(-1)^n}{n!}\int d\tau_1 ... d\tau_n \langle {\cal T}_\tau V(\tau_1) ... V(\tau_n)\rangle,$$
where $V(\tau) = e^{H_0\tau} V e^{-H_0\tau} $ is the perturbation in the interaction representation. The series can be resummed using the linked cluster theorem, yielding
$$\Delta \Omega = -\frac{1}{\beta}\sum_n \frac{(-1)^n}{n}\int d\tau_1 ... d\tau_n \langle {\cal T}_\tau V(\tau_1) ... V(\tau_n)\rangle_{conn},$$
such that ${\cal Z} = e^{\Omega_0 + \Delta \Omega}$.
Now, if we consider the specific case of electron-ion interaction, $V = \sum_{k,q} v_q \rho_q \psi^\dagger_{k+q}\psi_k$. Then,
$$\Delta \Omega^{(2)} = -\frac{1}{2 \beta} \int d\tau_1 d\tau_2 \langle {\cal T}_\tau \sum_{k_1,q_2}v_{q_1} \rho_{q_1} \psi^\dagger_{k_1+q_1}\psi_{k_1}|_{\tau_1} \sum_{k_2,q_2} v_{q_2} \rho_{q_2} \psi^\dagger_{k_2+q_2}\psi_{k_2}|_{\tau_2}\rangle_{conn} \\ = \frac{|v_q \rho_{q}|^2}{2 \beta} \int d\tau_1 d\tau_2 G_p(\tau_2 - \tau_1) G_{p-q}(\tau_1 - \tau_2)\\ = \frac{|v_q \rho_{q}|^2}{2 \beta} \int d\tau_1 d\tau_2 G_p(\tau_2 - \tau_1) G_{p-q}(\tau_1 - \tau_2)\\ = \frac{|v_q \rho_{q}|^2}{2 \beta} \sum_{\omega_n, p} G_p(\omega_n) G_{p-q}(\omega_n).$$
Here, the electronic Green functions are $G(\tau) = -\langle{\cal T}_\tau \psi(\tau) \psi^\dagger(0)\rangle$ and $G(\omega_n) = [i\omega_n - \epsilon]^{-1}$.
Similarly,
$$\Delta \Omega^{(3)} = -\frac{v_{q_0}^3 \rho_{q_1} \rho_{q_2}\rho_{q_3}}{3 \beta} \sum_{\omega_n, k} G_1(\omega_n) G_2(\omega_n)G_3(\omega_n),$$
where we assume that in every vertex the momentum transfer is the same in magnitude (density condenses always on the ring of radius $q_0$) and the interaction is isotropic (does not depend on the direction of momentum transfer). The subscript of Green functions indicates electron momentum that corresponds conserving momentum in every interaction vertex.
Finally, the 4th order contribution is
$$\Delta \Omega^{(4)} = \frac{v_{q_0}^4 \rho_{q_1} \rho_{q_2}\rho_{q_3}\rho_{q_4}}{4 \beta} \sum_{\omega_n, k} G_1(\omega_n) G_2(\omega_n)G_3(\omega_n) G_4(\omega_n).$$
Some references that we can use for comparison of coefficients in various orders are Melikyan [1] and and older paper by Yao [2]