Imagine the situation that someone just came back from a trip and you want to ask him about it. What would you say?
Did you have a good time?
Have you had a good time?
The key issue here is understanding the temporal order of tenses – that is, where the tenses would appear on a timeline relative to each other. Refer to this diagram (taken from here):
Your question is specifically about the simple past (Did...have...) versus the present perfect (Have...had...), which you can see on the above timeline.
For your question, the correct sentence is:
Did you have a good time? (simple past)
This is because the trip is over. Because the trip is over, any good time they had would be in the past.
That doesn't mean that using the present perfect is wrong, it's just that the present perfect is not the correct choice for this situation.
You would use the present perfect tense example in your question if you were at the end of the trip, but it had not yet ended. For example, if you were in an airport waiting for a flight home, or on the bus or train to the airport.
If the trip wasn't coming to an end, you could still use the present perfect, you would just need to add in a phrase like so far:
Have you had a good time so far?