PRISM theory of the structure, thermodynamics, and phase transitions of polymer liquids and alloys