Really, you can do it in any way you want, as long as you can repair the weapon. (or if it's a MyShop item and can be used when broken.. I'm not sure if you can compound a broken item though? I really have never tried to. Anyway...)
However, the only time you should refine second is if you're going to temper the weapon first. Stats from refinement are set and will not change when tempered.