公排互助制模式智能合约系统怎么开发?按照制度、模式、奖金等不同形式分为:单线大公排、双轨二二复制公排、三三复制排位(三轨制)、五级三阶模式等等,自动滑落跳排排位。
三三复制大公排,代码开发思路大致如下:
$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++){开发wei→hkkf5566
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']);
}
}