China’s largest e-commerce firm was slipping in the war for consumers’ wallets. Then it reshaped its relationship with merchants.