If Bayern accepts Barca's offer of, say, 45 mil, does Bayern get the 45 mil?
That's the idea.
If so, what does Lew get?
From what I've heard 12 million euro yearly salary (plus bonuses) and undisclosed signing-on fee.
Is there a free agency in footbal: a player's contract expires and then he's open to sign with any club
Yes. Most players signed by Ekstraklasa and Pierwsza Liga teams are free transfers but in better leagues it is also quite common. Lewandowski was a free transfer when he came to Bayern - his contract with Dortmund expired prior to the move.