Example 16 Given $a_{0}=-1, a_{1}=1, a_{n}=2 a_{n-1}+3 a_{n-2}+3^{n}(n \geqslant 2)$, find $a_{n}$.
Let $f(x)=a_{0}+a_{1} x+a_{2} x^{2}+\cdots+a_{n} x^{n}+\cdots$
Then
$$
\begin{array}{l}
-2 x f(x)=-2 a_{0} x-2 a_{1} x^{2}-\cdots-2 a_{n-1} x^{n}+\cdots \\
-3 x^{2} f(x)=-3 a_{0} x^{2}-\cdots-3 a_{n-2} x^{n}+\cdots \\
-\frac{1}{1-3 x}=-1-3 x-3^{2} x^{2}-\cdots-3^{n} x^{n}+\cdots
\end{array}
$$

Adding the above four equations and using the given conditions, we get
$$
\begin{array}{l}
\left(1-2 x-3 x^{2}\right) f(x)-\frac{1}{1-3 x}=-2, \\
f(x)=\frac{6 x-1}{(1+x)(1-3 x)^{2}}=\frac{A}{1+x}+\frac{B}{1-3 x}+\frac{C}{(1-3 x)^{2}} .
\end{array}
$$

Then
$$
\begin{array}{l}
A=\left.f(x)(1+x)\right|_{x \rightarrow-1}=-\frac{7}{16}, C=\left.f(x)(1-3 x)^{2}\right|_{x=\frac{1}{3}}=\frac{3}{4}, \\
0=\lim _{x \rightarrow+\infty} x f(x)=\lim _{x \rightarrow+\infty}\left[\frac{A x}{1+x}+\frac{B x}{1-3 x}+\frac{C x}{(1-3 x)^{2}}\right]=A-\frac{1}{3} B,
\end{array}
$$

So $B=3 A=-\frac{21}{16}$, thus
$$
\begin{array}{l} 
f(x)=-\frac{7}{16(1+x)}-\frac{21}{16(1-3 x)}+\frac{3}{4(1-3 x)^{2}} \\
=-\frac{7}{16} \sum_{n=0}^{\infty}(-1)^{n} x^{n}-\frac{21}{16} \sum_{n=0}^{\infty} 3^{n} x^{n}+\frac{3}{4} \sum_{n=0}^{\infty} C_{n+1}^{1} 3^{n} x^{n} \\
=\sum_{n=4}^{\infty}\left[\frac{(4 n-3) \cdot 3^{n+1}-(-1)^{n} \cdot 7}{16}\right] x^{n}, \\
\text { Hence } a_{n}=\frac{1}{16}\left[(4 n-3) \cdot 3^{n+1}-(-1)^{n} \cdot 7\right] .
\end{array}
$$