Semianalytical model for planetary resonances