分成代码:
Ecshop升级用户等级推广人获得分成3级分成代码
[code lang=”php”]
/**
*
* @param undefined $uinfo 用户信息
* @param undefined $gotorank 要升级的用户等级
*
* @return
*/
function fenchenbynovip($uinfo,$gotorank){//非VIP升级分成
if($uinfo[‘user_rank’]!=0) return false; //第一次升级才有奖励
$uname = $uinfo[‘user_name’];
if($gotorank==1){//升级普通会员
$points1 = $GLOBALS[‘_CFG’][‘update_vip’];
//var_dump($uinfo);
}
if($gotorank==2){//升级成金牌会员
$points1 = $GLOBALS[‘_CFG’][‘update_goldvip’];
}
//echo $points;
for ($i=0; $i < 3; $i++)
{
$points = $points1;
$sql = "SELECT parent_id as user_id FROM ecs_users WHERE user_id = ‘".$uinfo[‘user_id’]."’";
$uinfo = $GLOBALS[‘db’]->getRow($sql);
$up_uid = $uinfo[‘user_id’];
// echo $up_uid."<br>";
$urank = $GLOBALS[‘db’]->getOne("select user_rank from ecs_users where user_id=".$up_uid);
$info = $uname."升级成为".get_rank_info_by_id($gotorank)."的奖励分成";
//var_dump($uinfo);
if($urank==1&&$i==0){//推广人是普通会员,只允许一级分成
if($i==0){
$setmoney = $points*0.15*0.9;
$setpoint = $points*0.15*0.1;
log_account_change($up_uid, $setmoney, 0, 0, $setpoint, $info);
}
}elseif($urank>1){//普通会员以上,三级分成
$affiliate = unserialize($GLOBALS[‘_CFG’][‘affiliate’]);
$affiliate[‘item’][$i][‘level_point’] = (float)$affiliate[‘item’][$i][‘level_point’];
if ($affiliate[‘item’][$i][‘level_point’])
{
$affiliate[‘item’][$i][‘level_point’] /= 100;
}
$money = round($points * $affiliate[‘item’][$i][‘level_point’], 2);
$points = round($points * $affiliate[‘item’][$i][‘level_point’], 0);
$setmoney = $money*0.9;
$setpoint = $points*0.1;
// echo $up_uid."::".$setmoney."::".$setpoint."::".$points."<br>";
log_account_change($up_uid, $setmoney, 0, 0, $setpoint, $info);
}
}
}
[/code]