Mean-field expansion for spin models with medium-range interactions