我有一个基于MLM的单层项目,在该项目中,我制定了一些计划,其中每个赞助商都会产生直接收入和水平收入。但是我感到麻烦的是我得到了直接赞助商会员的等级收入,却没有得到赞助商的赞助商等级收入。 这是我要求的代码-
<a href="process_activate.php?member_user_id=<?php echo $row['member_user_id']; ?>" class="dropdown-item" onClick="return confirm('Sure to Topup!')"><i class="ft-briefcase"></i>Topup</a>
发送请求的HTML页面
include "../../config/config.php";
date_default_timezone_set("Asia/Calcutta");
$level=get_total_level();
功能
function get_parrent_id()
{
global $connection;
$str="Select * from tbl_memberreg order by member_id asc";
$res=mysqli_query($connection,$str);
$row=mysqli_fetch_array($res);
return $row['member_user_id'];
}
function total_active_member($member_user_id,$level)
{
global $connection;
$member_id=$member_user_id;
$parent_id=get_parrent_id();
for($cnt=1;$cnt<$level+1;$cnt++)
{
$mstr="Select * from tbl_memberreg where member_user_id='$member_id'";
$mresult=mysqli_query($connection,$mstr);
while($mrow=mysqli_fetch_array($mresult))
{
$sponcer_id=$mrow['sponcer_id'];
$sql="Update tbl_memberreg set total_active_member = total_active_member+1 where member_user_id='$sponcer_id'";
mysqli_query($connection,$sql);
if($member_id==$parent_id)
{
$cnt=$level+2;
}
}
$member_id=$sponcer_id; echo "<br/>";
}
}
下面是我的流程激活代码,我们在其中激活了计划
$member_user_id=$_REQUEST['member_user_id'];
$ssql="Select * from tbl_memberreg where member_user_id='$member_user_id'";
$res=mysqli_query($connection,$ssql);
while($rows=mysqli_fetch_array($res))
{
echo $member_id=$rows['member_id'];
echo$member_name=$rows['member_name'];
echo $sponcer_id=$rows['sponcer_id'];
$sponcer_name=$rows['sponcer_name'];
}
$plan_amt=2100;
$str="Update tbl_memberreg set status=1,activation_date='$sys_date',topup_amount=$plan_amt where member_user_id='$member_user_id'";
$result=mysqli_query($connection,$str);
if ($result == TRUE)
{
$direct_amount=200;
$sql="Update tbl_memberreg set direct_member=direct_member+1 where member_user_id='$sponcer_id'";
mysqli_query($connection,$sql);
//Calculate Total Active Member in Level
total_active_member($member_user_id,$level);
$admin_amt=0;$tds_amt=0;$net_amt=0;
$tds_amt=round($direct_amount*$tds_per/100);
$admin_amt=round($direct_amount*$admin_per/100);
$net_amt=$direct_amount-($admin_amt+$tds_amt);
echo $str_i="Insert Into tbl_member_income_dtails(member_user_id,calculate_date,exp_payment_date,income_amt,paid_status,income_level,exp_date_string,income_type,income_member_id,admin_per,admin_amt,tds_per,tds_amt,net_amt) values('$sponcer_id','$sys_date','$sys_date',$direct_amount,0,0,'$exp_date_string','DIRECT INCOME','$member_user_id',$admin_per,$admin_amt,$tds_per,$tds_amt,$net_amt)";
mysqli_query($connection,$str_i);
echo $str_w="Update tbl_memberreg set wallet_amount=wallet_amount+$net_amt where member_user_id='$sponcer_id'";
mysqli_query($connection,$str_w);
echo $mstr1="Select * from tbl_memberreg where member_user_id='$sponcer_id' and total_active_member >= 2 and direct_member >=2 and current_level=0";
$mresult=mysqli_query($connection,$mstr1);
while($rowss=mysqli_fetch_array($mresult))
{
$total_active_member=$rowss['total_active_member'];
$total_repurchase=$rowss['total_repurchase'];
$direct_member=$rowss['direct_member'];
$income_amt=100;
$level=1;
$tds_amt1=round($income_amt*$tds_per/100);
$admin_amt1=round($income_amt*$admin_per/100);
$net_amt1=$income_amt-($admin_amt1+$tds_amt1);
echo $str_l="Insert Into tbl_member_income_dtails(member_user_id,calculate_date,exp_payment_date,income_amt,paid_status,income_level,exp_date_string,income_type,income_member_id,admin_per,admin_amt,tds_per,tds_amt,net_amt) values('$sponcer_id','$sys_date','$sys_date','$income_amt',0,0,'$exp_date_string','LEVEL INCOME','$member_user_id','$admin_per','$admin_amt1','$tds_per','$tds_amt1','$net_amt1')";
mysqli_query($connection,$str_l);
$str_c="Update tbl_memberreg set current_level='$level' where member_user_id='$sponcer_id'";
mysqli_query($connection,$str_c);
}
echo $mstr2="Select * from tbl_memberreg where member_user_id='$sponcer_id' and total_active_member >= 6 and direct_member >= 2 and current_level=1";
$mresult2=mysqli_query($connection,$mstr2);
while($rowss2=mysqli_fetch_array($mresult2))
{
$total_active_member1=$rowss2['total_active_member'];
$total_repurchase1=$rowss2['total_repurchase'];
$direct_member1=$rowss2['direct_member'];
$income_amt=200;$level=2;
$tds_amt1=round($income_amt*$tds_per/100);
$admin_amt1=round($income_amt*$admin_per/100);
$net_amt1=$income_amt-($admin_amt1+$tds_amt1);
echo $str_l="Insert Into tbl_member_income_dtails(member_user_id,calculate_date,exp_payment_date,income_amt,paid_status,income_level,exp_date_string,income_type,income_member_id,admin_per,admin_amt,tds_per,tds_amt,net_amt) values('$sponcer_id','$sys_date','$sys_date','$income_amt',0,$level,'$exp_date_string','LEVEL INCOME','$member_user_id','$admin_per','$admin_amt1','$tds_per','$tds_amt1','$net_amt1')";
mysqli_query($connection,$str_l);
$str_c="Update tbl_memberreg set current_level='$level' where member_user_id='$sponcer_id'";
mysqli_query($connection,$str_c);
}
echo $mstr3="Select * from tbl_memberreg where member_user_id='$sponcer_id' and total_active_member >= 14 and direct_member >=2 and current_level=2";
$mresult3=mysqli_query($connection,$mstr3);
while($rowss3=mysqli_fetch_array($mresult3))
{
$total_active_member2=$rowss3['total_active_member'];
$total_repurchase2=$rowss3['total_repurchase'];
$direct_member2=$rowss3['direct_member'];
$income_amt=400;$level=3;
$tds_amt1=round($income_amt*$tds_per/100);
$admin_amt1=round($income_amt*$admin_per/100);
$net_amt1=$income_amt-($admin_amt1+$tds_amt1);
echo $str_l="Insert Into tbl_member_income_dtails(member_user_id,calculate_date,exp_payment_date,income_amt,paid_status,income_level,exp_date_string,income_type,income_member_id,admin_per,admin_amt,tds_per,tds_amt,net_amt) values('$sponcer_id','$sys_date','$sys_date','$income_amt',0,$level,'$exp_date_string','LEVEL INCOME','$member_user_id','$admin_per','$admin_amt1','$tds_per','$tds_amt1','$net_amt1')";
mysqli_query($connection,$str_l);
$str_c="Update tbl_memberreg set current_level='$level' where member_user_id='$sponcer_id'";
mysqli_query($connection,$str_c);
}
}
header("location:../pending_associate.php?msg='success'");