Chosen Solution
A couple of months back I replaced my iPhone 7’s battery because the battery section in settings showed 78% relative to when it was new. So I went to change it and for about a month it worked, except it still died just as fast as it did before. The battery screen continued to show 78% so I just let it be and used it. About a month later I noted that my phone would unexpectedly shutdown and reboot slowly. After it rebooted it would show a battery percentage way off what I had before (I had about 92% battery, then 9% after it rebooted.) It would continue in this loop infinitely until I did something physical to the phone like drop it flat on its back or hit the front. Then it’d kill about 10% and go back to how it was before. I thought it was a software issue but after downgrading from the iOS 13 beta to iOS 12 and watching the same thing happen, I figured there was something wrong with the battery connector or the battery itself. Is it because the battery in my phone isn’t designed for an iPhone 7 and maybe for another model?
As Akash suggests, I would certainly do a good visual inspection of the battery connector area. I would also specifically concentrate on a tiny component right next to the connector (R2201) which allows the battery state to be communicated to the CPU. Sometimes this component can be damaged or missing causing erratic readings such as you are seeing.
The other possibility here is that either your replacement battery is defective or your charge circuit may be damaged. This can happen when using low quality chargers and cables.
That is the result of bad contact of battery to battery connector,Specially a BSI ways.The pin of the battery connector might be bend,Check it.