最近在和朋友一起研究一个项目,项目的主题就是
ECSHOP 的分成,ECSHOP的推荐分成,具有递归性,如果A他推荐了B,B推荐了C。那么C购买了商品之后,B,A都能得到一定的推荐分成金额。
1:ECSHOP分成处理步骤
后台->推荐管理->分成管理
2:ECSHOP分成原理
在ecshop的users表中,parent_id就是用来处理EC推荐分成中推荐人的会员ID的。通过分成等级。可以循环出EC某会员下所有的推荐人.
$num = count($affiliate['item']);//推荐等级
for ($i=0; $i < $num;$i++) { $affiliate['item'][$i]['level_point'] =(float)$affiliate['item'][$i]['level_point']; $affiliate['item'][$i]['level_money'] =(float)$affiliate['item'][$i]['level_money']; if ($affiliate['item'][$i]['level_point']) { $affiliate['item'][$i]['level_point'] /= 100; } if ($affiliate['item'][$i]['level_money']) { $affiliate['item'][$i]['level_money'] /= 100; } $setmoney = round($money * $affiliate['item'][$i]['level_money'],2); $setpoint = round($point * $affiliate['item'][$i]['level_point'],0); $row = $db->getRow("SELECT o.parent_id asuser_id,u.user_name FROM " .$GLOBALS['ecs']->table('users') . " o" . " LEFT JOIN" . $GLOBALS['ecs']->table('users') . " uON o.parent_id = u.user_id". " WHERE o.user_id = '$row[user_id]'" ); $up_uid = $row['user_id']; if (empty($up_uid) || empty($row['user_name'])) { break; } else { $info = sprintf($_LANG['separate_info'], $order_sn, $up_uid,$row['user_name'], $setmoney, $setpoint); log_account_change($up_uid, $setmoney, 0, 0, $setpoint,$info); write_affiliate_log($oid, $up_uid, $row['user_name'], $setmoney,$setpoint, $separate_by); } }
而这里的"SELECT o.parent_id as user_id,u.user_name FROM " .$GLOBALS['ecs']->table('users') . " o". " LEFT JOIN" .$GLOBALS['ecs']->table('users') . " u ON o.parent_id= u.user_id"." WHERE o.user_id ='$row[user_id]'";就是用来寻找上一级推荐人的帐户信息。通过循环,而进行分成。然后写入对应的日志。