Does it have any kind of water damage ? Have you tried putting it in a rice sack so that all the absorbed moisture inside the phone is completely gone ? This helped me once. I kept mine for 24 hours.
One more tricked which worked for me was cleaning the charging port with Alcohol Solution carefully, to remove any debris or carbon formation, if any. and then using a hair dryer to blow remaining debris out, on low heat setting. it also dries out the moisture and carbon formation to some extent. I've done this many times and it works most of the time. If you don't have an alcohol solution, you could use a good quality perfume (Not deo), by keeping the nozzle near the charging port.
Disclaimer: Please try these steps by putting your device on switched off mode, always and let it dry out completely for 10-15 minutes before you start your phone or put it on charge.