The thermodynamic properties of a shell of bosons with the inner surface locating at Planck length away from the horizon of Schwarzschild black holes by using statistical mechanics are studied. The covariant partition function of bosons is obtained, from which the Bose-Einstein condensation of bosons is found at a non-zero temperature in the curved spacetimes. As a special case of bosons, we analyze the entropy of photon gas near the horizon of the Schwarzschild black hole, which shows an area dependence similar to the Bekenstein-Hawking entropy. The results may offer new perspectives on the study of black hole thermodynamics. All these are extended to the $D+1$ dimensional spherically symmetric static spacetimes.