Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter联合利华传销收入分配_Php_Codeigniter_Mlm - Fatal编程技术网

Php Codeigniter联合利华传销收入分配

Php Codeigniter联合利华传销收入分配,php,codeigniter,mlm,Php,Codeigniter,Mlm,我来这里是想得到你的帮助 我正在使用Codeigniter制作联合利华传销 现在我可以成功地添加新成员了 但问题是我需要将收益分配到其他层面 成功添加新成员后 见下图: 我需要像上面的图片一样分发 我希望你能帮我对付这些家伙。好的,我有一个解决方案给你。我使用的过程是基于我对问题的理解 就是这样,首先我检查了一个注册帖子,如果有帖子请求,我会使用帖子中的推荐id来获取与该推荐id相关的注册数量,该推荐id尚未获得100分。如果此查询结果的计数等于4,则我循环遍历所有这些记录,并给它们100的收

我来这里是想得到你的帮助

我正在使用Codeigniter制作联合利华传销 现在我可以成功地添加新成员了

但问题是我需要将收益分配到其他层面 成功添加新成员后

见下图:

我需要像上面的图片一样分发


我希望你能帮我对付这些家伙。

好的,我有一个解决方案给你。我使用的过程是基于我对问题的理解

就是这样,首先我检查了一个注册帖子,如果有帖子请求,我会使用帖子中的推荐id来获取与该推荐id相关的注册数量,该推荐id尚未获得100分。如果此查询结果的计数等于4,则我循环遍历所有这些记录,并给它们100的收入,并更新它们的已支付状态以反映它们已支付,然后我插入记录,否则我只插入记录

太多的文字,让我们看看代码

 //this is the controller code
//first check for post of registration
    if($_POST){

       //kindly do your form validation here

        $register = array(
            "name" => $this->input->post('name'),
            "refid" => $this->input->post('refID')
        );

        //during post, get the referral id from the post
        $refID = $this->input->post('refID');

        //before registering, use referral id to get the referred that have not been given earnings yet
        $thereffered = $this->referral_m->getReferred($refID);

        //check for the number of registration
        if(count($thereffered) == 4){

            //then get their ids and give them their earnings and update them to paid
            foreach($thereffered as $referred){

                $earnings = array(
                    "userID" => $referred->id,
                    "amount" => 100
                );

                $paid = array(
                    "paid" => 1
                );

                //give earning
                $this->referral_m->giveEarning($earnings); //this adds the user id to earning table and give it an amount of 100
                $this->referral_m->updateUser($paid, $referred->id); //this updates the user with the paid status

            }

            //then proceed to register the new record
            $this->referral_m->register($register);

        }else{

            //register the new record
            $this->referral_m->register($register);

        }
        //redirect after registration
        redirect();

    }else{
        //load view here
    }
这就是模型的样子

function getReferred($refID){
    return $this->db->get_where('referral', array("refid" => $refID, "paid" => '0'))->result();
}

function giveEarning($record){
    $this->db->insert('earnings', $record);
}

function register($array){
    $this->db->insert('referral', $array);
}

function updateUser($array, $id){
    $this->db->where('id', $id);
    $this->db->update('referral', $array);
}

从模型中,您会发现我创建了2个数据库表,我假设您已经创建了这些表,只需使用逻辑更新代码即可。如果您发现任何困难,请发表评论,让我们来解决它好的,我有一个解决方案给您。我使用的过程是基于我对问题的理解

就是这样,首先我检查了一个注册帖子,如果有帖子请求,我会使用帖子中的推荐id来获取与该推荐id相关的注册数量,该推荐id尚未获得100分。如果此查询结果的计数等于4,则我循环遍历所有这些记录,并给它们100的收入,并更新它们的已支付状态以反映它们已支付,然后我插入记录,否则我只插入记录

太多的文字,让我们看看代码

 //this is the controller code
//first check for post of registration
    if($_POST){

       //kindly do your form validation here

        $register = array(
            "name" => $this->input->post('name'),
            "refid" => $this->input->post('refID')
        );

        //during post, get the referral id from the post
        $refID = $this->input->post('refID');

        //before registering, use referral id to get the referred that have not been given earnings yet
        $thereffered = $this->referral_m->getReferred($refID);

        //check for the number of registration
        if(count($thereffered) == 4){

            //then get their ids and give them their earnings and update them to paid
            foreach($thereffered as $referred){

                $earnings = array(
                    "userID" => $referred->id,
                    "amount" => 100
                );

                $paid = array(
                    "paid" => 1
                );

                //give earning
                $this->referral_m->giveEarning($earnings); //this adds the user id to earning table and give it an amount of 100
                $this->referral_m->updateUser($paid, $referred->id); //this updates the user with the paid status

            }

            //then proceed to register the new record
            $this->referral_m->register($register);

        }else{

            //register the new record
            $this->referral_m->register($register);

        }
        //redirect after registration
        redirect();

    }else{
        //load view here
    }
这就是模型的样子

function getReferred($refID){
    return $this->db->get_where('referral', array("refid" => $refID, "paid" => '0'))->result();
}

function giveEarning($record){
    $this->db->insert('earnings', $record);
}

function register($array){
    $this->db->insert('referral', $array);
}

function updateUser($array, $id){
    $this->db->where('id', $id);
    $this->db->update('referral', $array);
}

从模型中,您会发现我创建了2个数据库表,我假设您已经创建了这些表,只需使用逻辑更新代码即可。如果您发现任何困难,请发表评论,让我们来解决它

您能进一步解释一下吗,这样我可以帮助您。添加新会员后,您希望通过分配收入来实现什么?例如,我将详细介绍,以便我能够理解并帮助您了解@SundayOkoi,例如,我已经介绍了4位用户。。如果一个新会员使用我的推荐再次注册,我将给我之前的4个推荐用户100的奖金。。我将分发他们每个100..我如何才能做到这一点使用codeigniter。获取我的最后4个推荐用户,如果有新会员使用我的推荐注册,请给他们每人100奖金。请您进一步解释,以便我能提供帮助。添加新会员后,您希望通过分配收入来实现什么?例如,我将详细介绍,以便我能够理解并帮助您了解@SundayOkoi,例如,我已经介绍了4位用户。。如果一个新会员使用我的推荐再次注册,我将给我之前的4个推荐用户100的奖金。。我将分发他们每个100..我如何才能做到这一点使用codeigniter。获取我的最后4个推荐用户,如果有新会员使用我的推荐注册,则每人可获得100奖金