An exact solution of the partition function for mean-field quantum spin systems without the static approximation