$uids1=$Proxy->where("path like '%{$path1}%' and type = -1")->getField('uid',true);
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
}
$where['id']=array('in',$uids1);
}
$this->assign('type',$_REQUEST['type']);
$this->assign('types',array(
array(
'type'=>0,
'name'=>"我的数据"
),
array(
'type'=>4,
'name'=>"业务员"
)
));
$this->assign('showlevel',3);
}elseif($user['tg_type']==5){//业务员查看用户消费情况
//$where['tg_type'] = 1;
$where['id']=$adminid;//默认自己
$this->assign('types',array(
array(
'type'=>0,
'name'=>"我的数据"
),
));
}
}
/* 展示列表 */
$users=$User
->field('*')
->where($where)
->order("create_time DESC")
->select();//列表用户信息
if(!empty($users)){
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}%' and (type = 0 or type = 3)")->getField('uid',true);//和当前列管理员有关的所有普通用户或者主播
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
}
//充值金额
$map=$amap;
$map['uid']=array('in',$uids1);
$total_charge=$Charge->where("status=1 and uid not in (".implode(",",$fuchi).")")->where($map)->sum('money');
if(!$total_charge){
$total_charge='0';
}
//充值人数
$total_charge_num=count($Charge->where("status=1 and uid not in (".implode(",",$fuchi).")")->where($map)->group('uid')->select());
//$v1['sql'] = $Charge->getLastSql();
if(!$total_charge_num){
$total_charge_num='0';
}
$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();//当前列管理相关的所有用户送的礼物