Dynamical analysis of a generalized hepatitis B epidemic model and its dynamically consistent discrete model