代码点火器单级传销收入分配



我在这里向你寻求一些帮助。

我正在使用代码点火器制作单级传销 现在我可以成功添加新成员

但问题是我需要将收入分配给其他级别 成功添加新成员后

见下图:

收入分配

我需要像上图一样分发。

我希望你能帮我解决这个问题。

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

就是这样,首先我检查了一个注册帖子,如果提出了帖子请求,我使用帖子中的推荐 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 个数据库表,我假设您已经创建了这些表,只需使用逻辑更新代码即可。如果您发现任何困难,请发表评论,让我们解决一下

最新更新