什么是公排零碎?公排制模式并不是繁多的模式,依照制度、模式、奖金等不同模式分为:寰球公排一条线模式、二二复制公排 (双轨制)、三三复制排位 (三轨制)、五级三阶模式等等,主动滑落跳排排位。
三三复制大公排,代码开发思路大抵如下,开发详情征询小编 wei→hkkf5566:
$x = 1;
$y = 0;
$h = 1;
for($y;$y<4;$y++){$s = $h - pow(3,$y-1);
for($x;$x<$h + pow(3,$y);$x++){if($h > 1){if(($x-$h > 0) && ($x - $h)%3 == 0){$s ++;}
echo $s.'->'.$x.' ';
}else{echo $x.' ';}
}
$h = $x;
echo '</br>';
}
本人写的
// 取余数
function Kmod($bn, $sn)
{
return intval(fmod(floatval($bn), $sn));
}
// 增加会员 主动匹配地位依据图谱降级
function sadd(){
$sid = 0;
$slevel = 0;
$count = Db::name('gongpai')->count();
if($count > 0){
$count++;
$yu = Kmod($count,3);
if($yu == 0){$sid = $count/3;}elseif($yu == 1){$sid = ($count-1)/3;
}elseif($yu == 2){$sid = ($count+1)/3;
}
$whr['id'] = $sid;
$slevel = Db::name('gongpai')->where($whr)->find();
$data['fatherid'] = $sid;
$data['level'] = $slevel['level']+1;
$data['dengji'] = 0;
if($slevel['level'] < 9){Db::name('gongpai')->insert($data);
svipup($sid);
}
}else{$data['fatherid'] = 0;
$data['level'] = 1;
$data['dengji'] = 0;
Db::name('gongpai')->insert($data);
}
}
//siv 降级
function svipup($sid){
$whr['id'] = $sid;
$sinfo = Db::name('gongpai')->where($whr)->find();
$whrs['fatherid'] = $sinfo['id'];
$whrs['dengji'] = $sinfo['dengji'];
$sons = Db::name('gongpai')->where($whrs)->count();
if($sons > 2){
// 公排等级更新
$data['dengji'] = $sinfo['dengji']+1;
$whrup['id'] = $sinfo['id'];
Db::name('gongpai')->where($whrup)->update($data);
// 会员 svip 等级更新
if($sinfo['fatherid'] > 0){svipup($sinfo['fatherid']);
}
}else{if($sinfo['fatherid'] > 0){svipup($sinfo['fatherid']);
}
}
}