i am implementing chain system with auto bidding. when one user referred by parent(referral) then direct referral account have to credited with 10% of the user package amount and all parents of the direct referral credited 5% of the amount. how can i implement it. please tell me in basics not in oops.
here is users table user4 referred by user2 then 10% commision credited to user2 and 5% commision added to indirect referral usr1 and usr0.
then user gets daily commision according to their package. daily commision is added to user only not referral. every user got their daily commission every day.
registered users referred by another user.
commission(referral amount) is some percentage of user package amount. for details please check above tables
Because you mentioned “my job” I’m assuming this is not for a fun exercise and unless someone is a generous philanthropist the money will need to come from somewhere.
depends on the package amount the referral gets percentage. direct referral gets 10% and indirect referral gets 5%. these percentage of amount added to their income column in users table.
//pseudo-code
// create user record
$commrate = 0.1;
while ($referred_by !="Global" or nothing or however you detect top of tree) {
// write credit transaction to referrer, however to note they have a commission
// set commrate to 0.05 for 5% for all remaining referrers
// read row where user_id = referred_by, to get new referred_by id
} // run through loop again
That was the brief explanation. I don’t know enough about your database to go into much more detail, for example where are the transactions written?
All you need to do is to store the new user details, read the first referrer_id and assign them 10% of the value, then read their referrer and give them 5% of the value, and keep doing that last step until the referrer_id is blank, or “Global”, or whatever tells you to stop.
Have a go at converting my pseudo-code above into PHP code, and post your code if you have trouble with it.