The amount of turns you have left to order food is affected by the number of turns you take to defeat the opposing Pokemon in battle.
When you order food, someone challenges you, right? Then you take a certain amount of turns to defeat their Pokemon. Let's say it takes two Moonblasts from your Primarina to defeat the opposing Drifblim. So, that's two turns. Your previous 9 turns would now have been decreased to 7 turns, instead of 8.
Does that make sense? When your amount of turns went from 5 to 0, that meant you probably took 5 turns to win in the last battle.
Also, if you defeat ten Pokemon, each with one turn, then you should get a prize.
Source: experience. It worked this way in some of the restaurants in Omega Ruby and Alpha Sapphire as well.