$_total_charge=$Charge->where($where1)->where("status=1 and uid not in (".implode(",",$fuchi).")")->where($amap)->sum('money');
//var_dump($Charge->getLastSql());
if(!$_total_charge){
$_total_charge='0';
}
//礼物支出总和
$total_coin=$coin->where($where1)->where("type='expend' and action='sendgift'")->where($amap)->sum('totalcoin');
$total_coin=$coin->where($where1)->where("type='expend' and action='sendgift' and uid not in (".implode(",",$fuchi).")")->where($amap)->sum('totalcoin');
//var_dump($coin->getLastSql());
if(!$total_coin){
$total_coin='0';
}
//列表的数据
foreach($usersas$k=>$v){
if($v['tg_type']==2){
$v['rbac']='一级代理';
}elseif($v['tg_type']==3){
$v['rbac']='二级代理';
}elseif($v['tg_type']==4){
$v['rbac']='主播';
}elseif($v['tg_type']==5){
$v['rbac']='业务员';
}
if(!empty($users)){
$path1=setpath($v['id']);
foreach($usersas$k1=>$v1){
if($v1['tg_type']==2){
$v1['rbac']='一级代理';
}elseif($v1['tg_type']==3){
$v1['rbac']='二级代理';
}elseif($v1['tg_type']==4){
$v1['rbac']='主播';
}elseif($v1['tg_type']==5){
$v1['rbac']='业务员';
}
$path1=setpath($v1['id']);
$uids1=$Proxy->where("path like '%{$path1}%'")->getField('uid',true);//和当前列管理员有关的所有用户
$iszi=$Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count();
if(!$iszi){
$solt3+=$v3['totalcoin'];
$v1['total_charge_num']=$total_charge_num;
$v1['total_charge']=$total_charge;
//注册人数
$map2=$bmap;
$map2['id']=array('in',$uids1);
$total_reg=$User->where("user_type=2 and id not in (".implode(",",$fuchi).")")->where($map2)->count();
if(!$total_reg){
$total_reg='0';
}
$v1['total_reg']=$total_reg;
$map1=$amap;
$map1['uid']=array('in',$uids1);
//守护金额
$guardcoin=$coin->where("type='expend' and action='buyguard' and uid not in (".implode(",",$fuchi).")")->where($map1)->sum('totalcoin');
if(!$guardcoin){
$guardcoin='0';
}
$v1['guardcoin']=$guardcoin;
//商城消费buyvip buyliang buycar
$mallcoin=$coin->where("type='expend' and (action='buyvip' or action='buyliang' or action='buycar') and uid not in (".implode(",",$fuchi).")")->where($map1)->sum('totalcoin');
if(!$mallcoin){
$mallcoin='0';
}
$v1['mallcoin']=$mallcoin;
//自客自销,他客自销,自客他销
$solt1=0;
$solt2=0;
$expends=$coin->where("type='expend' and action='sendgift' and uid not in (".implode(",",$fuchi).")")->where($map1)->select();//当前列管理相关的所有用户送的礼物