Generally, sunscreen is the final step of skincare, so moisturizer would go under and primer would go over. I’ve used multiple sunscreens with moisturizing ingredients and have never found them to be particularly moisturizing, at least not enough to replace a dedicated moisturizer (man, I’m using “moisturize” a lot!), but that’s just me and my Sahara skin!
I do use primer, but mostly because the powder I use (don’t use foundation) sticks better to it than to my sunscreen and I’m always a little paranoid that applying powder on top of sunscreen directly would somehow mess with its effectiveness (as in, the powder might “soak up” the sunscreen).