Is this cactus salvageable?

I purchased this cactus at a plant store from the clearance section and brought it home and the top fell off. I’m assuming I can plant the part that fell off in a new pot? What should I do about the rotting top on the main cactus? Can it be saved?