The phenols and ammonia-nitrogen compounds in semi-coking wastewater are used to react with formaldehyde to generate phenolic resin and curing agent urotropine, so as to achieve the resourceful preparation of thermosetting phenolic resin. The effects of pH value of wastewater, reaction time, reaction temperature, formaldehyde addition amount and other conditions on the quality of phenolic resin were investigated. Response surface methodology was used to optimize the preparation conditions of phenolic resin, and the effect of ammonia on the preparation of phenolic resin was explored. Moreover, solid content, carbon yield, gel time and viscosity of the prepared phenolic resin were determined. The experimental results showed that the quality of phenolic resin prepared when the pH value of wastewater was 9.5, the reaction time was 2.5 h, the reaction temperature was 140 degrees C, and the additive amount of formaldehyde was 1.4 mL, phenolic resin with best quality could be obtained. The solid content of phenolic resin prepared is 94.25%, the carbon yield is 40.02%, the gel time is 92 s, and the viscosity is 1.50 x 104 mPa<middle dot>s. This study has solved the problems such as high chemical oxygen demand (COD), high ammonia-nitrogen, as well as difficult degradation and treatment.