公排智能合约dapp系统开发代码方案详情

什么是公排系统?公排制模式并不是单一的模式,按照制度、模式、奖金等不同形式分为:全球公排一条线模式、二二复制公排(双轨制)、三三复制排位(三轨制)、五级三阶模式等等,自动滑落跳排排位。

三三复制大公排,代码开发思路大致如下,开发详情咨询小编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 '
'; }

自己写的

//取余数

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']);
    }
     
}
 

}

你可能感兴趣的:(solidity前端)