Book contracts almost invariably work on a percentage of the cover price, a sliding scale that increases as the number of copies sold goes up.
A standard hardcover book contract may be, say, 10% on the first 5,000 copies, 12.5% on the next 5,000 and 15% after that. (Paperback book contracts are similar but with lower percentages.)
A superbestseller like Dan Brown may be able to command higher percentages, but I would be stunned if anyone got even 20%. usually just the sheer number of books makes up for the lack of increase in percentage.
The money comes in as royalties against the advance. That means that if Brown gets a million dollars up front, he sees nothing again until the percentages of sales equals more than a million dollars.
In the real world, contracts are much more complex than this. A big name author would make money, with different percentages, on book club sales, audio book sales, movie options, foreign sales, and a dozen other categories.
Authors can also lose money, in a sense. Mass market paperbacks are returnable by bookstores for a full cost refund. So if 1,000,000 books are sold to bookstores perhaps 500,000 of them will come back as unsold. Most publishers hold back royalties on paperbacks to accommodate this, but it’s possible for a specific royalty period to end up in the red. The author does not have to give back any money, of course, but any negatives have to be made up in future royalties before any more money is sent out.
More than you wanted probably.