Referral codes are meant to be promotional. Once a code has been used and the new account is 90+ days past their first positive transaction, then credit the creator_id account with a free month and a new referral code.
We could add a column to the invites table rewarded_at. Cronjob would scan the table for used_by_id IS NOT NULL AND rewarded_at IS NULL and then inner join against transactions on used_by_id = customer_id WHERE amount > 0 GROUP BY customer_id HAVING MIN(transactions.created_at) > localtimestamp - '90 days' and any results have not been rewarded yet and have a positive transaction at least 90 days old, so do the rewards to creator_id and set rewarded_at to localtimestamp.
To clarify, the rewards would be a month of credit and a newly generated invite code?
We may want to be slightly careful in the future.
If someone invites themselves, and then asks support to transfer some money to their sub-account, it will trigger this case and we’ll give them extra money and allow them to invite someone new. This isn’t really a technical opinion, but it’s something we may want to think about as we go along.
Yes, month of credit + new code.
And yes, this is for all positive transactions, so we need to make sure we’re not doing manual transactions against invited accounts without being careful.