Self-dual codes over $\mathbb{F}_{q}+u\mathbb{F}_{q}+u^2\mathbb{F}_{q}$ and applications