COLLAPSING HOT MOLECULAR CORES: A MODEL FOR THE DUST SPECTRUM AND AMMONIA LINE EMISSION OF THE G31.41+0.31 HOT CORE