Gavi and Anthony Gordon struck either side of half-time before substitute Raphinha's double took him to a century of Barcelona goals.