It is hard to understand for beginners to choose “did” or “have/has” statement. There is a good post that explains this very clear. I copied all the text because I don’t want to miss it. There is a link also.
What’s the difference between “did” and “have done”?
As the other answers said, “did” is past tense. “Have done” is present perfect.
Although in some contexts present perfect can imply that something was done recently, that is by no means the rule.
“Have you ever run a marathon?” “Yes I have. I ran one ten years ago.”
The question and the first sentence of the answer above are in present perfect tense. “I ran one” is past tense.
You cannot say “I have run one ten years ago.” That is not good English. But that is not because the race was not recent. “I have answered the question a minute ago,”is also bad. (The sentence should be in the past tense, not in the present perfect.)
The key to this mysterious behavior is the idea of a “temporal reference frame” or “implied time frame”. The time frame of the present perfect tense is a period of time that contains some of the past as well as the present. Key point: the present is in the frame. Let’s call what the frame contains a present-including past. (It has also been called anextended now.) When you use the present perfect, you are implying a view of past events as happening in a present-including past – the present being the time the sentence is said. Whereas, when you use the past tense, you view past events in a time frame that ended in the past – a present-excluding past. It sounds confusing, but consider some examples:
“Have you seen that movie?” “No, I haven’t seen it,” or “I haven’t seen it yet.” The question and answer imply that the movie is still available to be seen (or will be in the future.) Or at least, they leave that possibility open. The present is included in the implied time frame.
“Did you see that movie?” “No, I missed it.” The question and answer, both in the past tense, imply a time frame that ended in the past. This is appropriate if the movie is no longer available, or if you’re focusing on an event, like a showing, that is over.
“Have you taken your pills this morning?” is good if it is still morning, since then the time frame “this morning” includes the present. But if it is no longer morning, you cannot say that. If it is evening, the question becomes “Did you take your pills this morning?” since the time frame, this morning, terminated in the past.
“I’ve lived in San Francisco for ten years,” implies you’re still living there. It’s an extended now. “I lived in San Francisco for ten years,” implies you left at the end of that period. It’s over, finished.
“I played basketball last Tuesday,” is good. “I have played basketball last Tuesday,” is bad, because last Tuesday is over. “I played basketball every Tuesday,” is good English, but it implies that I am no longer doing that. (The past tense time frame is present-excluding.) “I have played basketball every Tuesday for the past ten years” is also good, and it implies the practice continues into the present.
Another aspect of the present perfect tense is that it can sometimes be seen as focusing on the present instead of the past – as a state in which past events have come to fruition. “I have passed the test” or “I’ve seen that movie” could be seen as describing your present state, not a past event. “I passed the test,” “I saw that movie,” on the other hand, are about those particular events in the past.