Didi Chuxing has agreed to buy 99 - Uber's main Brazilian rival - according to people with knowledge of the transaction.