Welcome to WebmasterWorld Guest from 126.96.36.199
Right now it sets a cookie if one does not already exist, so it won't be overwritten, and if there is no affiliate referral then the cookie is set as no referral.
It all depends on how you've setup your affiliate agreement. I've seen both ways done, but I have seen more giving credit to the affiliate. (It's the same issue as when someone comes through Affiliate A, doesn't buy, then comes through Affiliate B and buys.)
Or should there be no referral on the sale since the buyer visited my site first without using an affiliates referral id?
This sounds like you want to credit affiliates for the new visitors only (and only when they buy). I would never bother about such program. Not because I'm greedy but because it is almost impossible to make any money on it.