Commit 7280e223 by 冷斌

fix bug

parent 9a960dc0
<admintpl file="header" /> <admintpl file="header" />
</head> </head>
<body> <body>
<div class="wrap js-check-wrap"> <div class="wrap js-check-wrap">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="{:U('Gather/index')}">列表</a></li> <li class="active"><a href="{:U('Gather/index')}">列表</a></li>
<if condition="$isshow"> <if condition="$isshow">
<li><a href="{:U('Gather/add')}">添加</a></li> <li><a href="{:U('Gather/add')}">添加</a></li>
</if> </if>
</ul> </ul>
<form class="well form-search" method="post" action="{:U('Gather/index')}"> <form class="well form-search" method="post" action="{:U('Gather/index')}">
代理、推广员、主播:
<input type="text" name="keyword" style="width: 200px;" value="{$formget.keyword}" placeholder="请输入用户名、昵称..."> 类型:
时间段: <select class="select_2" name="type" id="four">
<input type="text" name="start_time" class="js-date date" id="start_time" value="{$formget.start_time}" style="width: 80px;" autocomplete="off">- <volist name="types" id="v">
<input type="text" class="js-date date" name="end_time" id="end_time" value="{$formget.end_time}" style="width: 80px;" autocomplete="off"> &nbsp; &nbsp; <option value="{$v['type']}" <if condition="$formget.type eq $v['type']">selected</if>>{$v['name']}</option>
<input type="submit" class="btn btn-primary" value="搜索"> </volist>
<div style="margin-top:10px"> </select>
{$date}数据统计 (根据筛选条件统计) 时间段:
<span style="color:red;font-size: 17px;"> <input type="text" name="start_time" class="js-date date" id="start_time" value="{$formget.start_time}" style="width: 80px;" autocomplete="off">-
<input type="text" class="js-date date" name="end_time" id="end_time" value="{$formget.end_time}" style="width: 80px;" autocomplete="off"> &nbsp; &nbsp;
<input type="submit" class="btn btn-primary" value="搜索">
<div style="margin-top:10px">
{$date}月数据统计 (根据筛选条件统计)
<span style="color:red;font-size: 17px;">
普客总充值:¥{$_total_charge} 普客总充值:¥{$_total_charge}
普客刷礼(钻石):{$total_coin} 普客刷礼(萌豆):{$total_coin}
</span> </span>
</div> </div>
<if condition="$my eq 1"> </form>
<div style="margin-top:10px"> <table class="table table-hover table-bordered">
注册人数:{$my_total_reg} <thead>
充值金额:{$my_total_charge} <tr>
充值人数:{$my_total_charge_num} <th width="50">ID</th>
自客自销(钻石):{$mysolt1} <th>角色</th>
他客自销(钻石):{$mysolt3} <th>账号</th>
自客他销(钻石):{$mysolt2} <th>昵称</th>
</div> <th>手机</th>
</if> <th>注册人数</th>
<th>充值金额</th>
<th>充值人数</th>
</form> <th>守护金额(萌币)</th>
<table class="table table-hover table-bordered"> <th>商城消费(萌币)</th>
<thead> <th>自客自销(萌币)</th>
<tr> <th>他客自销(萌币)</th>
<th width="50">ID</th> <th>自客他销(萌币)</th>
<th>角色</th> </tr>
<th>账号</th> </thead>
<th>昵称</th> <tbody>
<th>手机</th> <php>$user_statuses=array("0"=>L('已拉黑'),"1"=>'正常',"2"=>'未验证');</php>
<th>注册人数</th> <foreach name="users" item="vo">
<th>充值金额</th> <tr>
<th>充值人数</th> <td>{$vo.id}</td>
<th>守护金额(钻石)</th> <td>{$vo.rbac}</td>
<th>商城消费(钻石)</th> <td>{$vo.user_login}</td>
<th>自客自销(钻石)</th> <td>{$vo.user_nicename}</td>
<th>他客自销(钻石)</th> <td>{$vo.mobile}</td>
<th>自客他销(钻石)</th> <td>{$vo.total_reg}</td>
</tr> <td>{$vo.total_charge}</td>
</thead> <td>{$vo.total_charge_num}</td>
<tbody> <td>{$vo.guardcoin}</td>
<php>$user_statuses=array("0"=>L('已拉黑'),"1"=>'正常',"2"=>'未验证');</php> <td>{$vo.mallcoin}</td>
<foreach name="users" item="vo"> <td>{$vo.solt1}</td>
<tr> <td>{$vo.solt3}</td>
<td>{$vo.id}</td> <td>{$vo.solt2}</td>
<td>{$vo.rbac}</td> <!-- <td>{$vo.test}</td>
<td>{$vo.user_login}</td> <td>{$vo.test2}</td> -->
<td>{$vo.user_nicename}</td> </tr>
<td>{$vo.mobile}</td> </foreach>
<td>{$vo.total_reg}</td> </tbody>
<td>{$vo.total_charge}</td> </table>
<td>{$vo.total_charge_num}</td> <div class="pagination">{$page}</div>
<td>{$vo.total_coin}</td> </div>
<td>{$vo.total_votes}</td> <script src="__PUBLIC__/js/common.js"></script>
<td>{$vo.solt1}</td> <script type="text/javascript">
<td>{$vo.solt3}</td> </script>
<td>{$vo.solt2}</td>
<!-- <td>{$vo.test}</td> -->
</tr>
</foreach>
</tbody>
</table>
<div class="pagination">{$page}</div>
</div>
<script src="__PUBLIC__/js/common.js"></script>
</body> </body>
</html> </html>
...@@ -4,330 +4,474 @@ namespace Admin\Controller; ...@@ -4,330 +4,474 @@ namespace Admin\Controller;
use Common\Controller\AdminbaseController; use Common\Controller\AdminbaseController;
class GatherController extends AdminbaseController{ class GatherController extends AdminbaseController{
protected $users_model,$role_model; protected $users_model,$role_model;
function _initialize() { function _initialize() {
parent::_initialize(); parent::_initialize();
$this->users_model = D("Common/Users"); $this->users_model = D("Common/Users");
$this->role_model = D("Common/Role"); $this->role_model = D("Common/Role");
} }
function index(){ function index(){
//var_dump(123);
$Charge=M('users_charge');//充值表
$coin=M("users_coinrecord");//礼物支出
$Proxy=M('users_proxy');
$User=M('users');
$adminid = $_SESSION['ADMIN_ID'];
$date = date("Y-m");//默认当月 $date = date("Y-m");//默认当月
$stime = $date.'-01 00:00:00';//默认当月一号开始 $stime = $date.'-01 00:00:00';//默认当月一号开始
$etime = $date.date("-d H:i:s");//当前时间 $etime = $date.date("-d H:i:s");//当前时间
//默认时间搜索条件 //默认时间搜索条件
$amap['addtime'] = array("between",array(strtotime($stime),strtotime($etime))); $amap['addtime'] = array("between",array(strtotime($stime),strtotime($etime)));
$bmap['create_time'] = array("between",array($stime,$etime)); $bmap['create_time'] = array("between",array($stime,$etime));
$Charge=M('users_charge');//充值表
$coin=M("users_coinrecord");//礼物支出
$User=M('users');
$where=[]; $where=[];
$where1=[];
//默认时间
$mysolt1 = 0;
$mysolt2 = 0;
$mysolt3 = 0;
$_total_charge = 0;
$total_coin = 0;
$users = [];
$fuchi = [];
// $path0=setpath($adminid);
// $cuids=$Proxy->where("(type=0 or type=3) and path like '%{$path0}%'")->getField('uid',true);
// if(!$cuids){
// $cuids=[];
// array_push($cuids,'0');
// }
// //var_dump($cuids);
// $where1['uid'] = array('in',$cuids);
// if($user['tg_type'] != 0){//不是平台账号默认展示自己的
// $where['id'] = $adminid;
// }
if($_REQUEST['keyword']!=''){
$where['user_login|user_nicename']=array("like","%{$_REQUEST['keyword']}%");
$_GET['keyword']=$_REQUEST['keyword'];
}
if($_REQUEST['start_time']!=''){ if($_REQUEST['start_time']!=''){
$amap['addtime']=array("gt",strtotime($_REQUEST['start_time'])); $amap['addtime']=array("gt",strtotime($_REQUEST['start_time'].' 00:00:00'));
$bmap['create_time']=array("gt",$_REQUEST['start_time']); $bmap['create_time']=array("gt",$_REQUEST['start_time'].' 00:00:00');
$_GET['start_time']=$_REQUEST['start_time']; $_GET['start_time']=$_REQUEST['start_time'];
} }
if($_REQUEST['end_time']!=''){ if($_REQUEST['end_time']!=''){
$amap['addtime']=array("lt",strtotime($_REQUEST['end_time'])); $amap['addtime']=array("lt",strtotime($_REQUEST['end_time'].' 23:59:59'));
$bmap['create_time']=array("lt",$_REQUEST['end_time']); $bmap['create_time']=array("lt",$_REQUEST['end_time'].' 23:59:59');
$_GET['end_time']=$_REQUEST['end_time']; $_GET['end_time']=$_REQUEST['end_time'];
} }
if($_REQUEST['start_time']!='' && $_REQUEST['end_time']!='' ){ if($_REQUEST['start_time']!='' && $_REQUEST['end_time']!='' ){
$amap['addtime']=array("between",array(strtotime($_REQUEST['start_time']),strtotime($_REQUEST['end_time']))); $amap['addtime']=array("between",array(strtotime($_REQUEST['start_time'].' 00:00:00'),strtotime($_REQUEST['end_time'].' 23:59:59')));
$bmap['create_time']=array("between",array($_REQUEST['start_time'],$_REQUEST['end_time'])); $bmap['create_time']=array("between",array($_REQUEST['start_time'].' 00:00:00',$_REQUEST['end_time'].' 23:59:59'));
$_GET['start_time']=$_REQUEST['start_time']; $_GET['start_time']=$_REQUEST['start_time'];
$_GET['end_time']=$_REQUEST['end_time']; $_GET['end_time']=$_REQUEST['end_time'];
} }
//扶持账户
$fuchi = $User->where("rg_multiple>1")->getField('id',true);//充值倍数大于1的
$Proxy=M('users_proxy'); //当前管理员
$user = $this->users_model->where("id={$_SESSION['ADMIN_ID']}")->find(); $user = $User->where("id={$_SESSION['ADMIN_ID']}")->find();
$_GET['type'] = 0;
//管理员类型
if($user['tg_type'] == 0){//平台
if($user['tg_type'] == 0){//平台方
$where['tg_type'] = array('in',array('2','3','4','5')); $where['tg_type'] = array('in',array('2','3','4','5'));
$this->assign('my',0);
}else{//代理,业务员和主播
$this->assign('my',1);
if($user['tg_type'] == 2){//一级代理
$where['tg_type'] = array('in',array('3','4','5'));//查看自己下面的和二级代理,主播,业务员
}elseif($user['tg_type'] == 3){//二级代理
$where['tg_type'] = array('in',array('4','5'));//查看主播,业务员
}elseif($user['tg_type'] == 4){//主播
$where['tg_type'] = array('in',array('5'));//查看业务员
}elseif($user['tg_type'] == 5){//业务员
$where['tg_type'] = 1;
if($_REQUEST['type'] == 1){
$where['tg_type'] = 2;
$_GET['type'] = 1;
} }
$path=setpath($user['id']); if($_REQUEST['type'] == 2){
$where['tg_type'] = 3;
$uids=$Proxy->where("path like '%{$path}%'")->getField('uid',true);//与当前管理员,代理,主播,业务员有关的所有用户 $_GET['type'] = 2;
if($uids){
$where["id"] = array('in',$uids);
$where1["uid"] = array('in',$uids);
}else{
$where["id"] = array('in',array('0'));
$where1["uid"] = array('in',array('0'));
} }
//充值金额 if($_REQUEST['type'] == 3){
$map=$amap; $where['tg_type'] = 4;
$map['uid'] = array('in',$uids); $_GET['type'] = 3;
$my_total_charge=$Charge->where("status=1")->where($map)->sum('money');
if(!$my_total_charge){
$my_total_charge='0';
} }
$this->assign('my_total_charge',$my_total_charge); if($_REQUEST['type'] == 4){
//充值人数 $where['tg_type'] = 5;
$my_total_charge_num=count($Charge->where("status=1")->where($map)->group('uid')->select()); $_GET['type'] = 4;
//$v['sql'] = $Charge->getLastSql();
if(!$my_total_charge_num){
$my_total_charge_num='0';
} }
$this->assign('my_total_charge_num',$my_total_charge_num);
// $v['total_charge_num']=$total_charge_num; $this->assign('types',array(
// $v['total_charge']=$total_charge; array(
'type' => 0,
//注册人数 'name' => "总数据"
$map2=$bmap; ),
$map2['id'] = array('in',$uids); array(
$my_total_reg=$User->where("user_type=2")->where($map2)->count(); 'type' => 1,
if(!$my_total_reg){ 'name' => "一级推广"
$my_total_reg='0'; ),
array(
'type' => 2,
'name' => "二级推广"
),
array(
'type' => 3,
'name' => "主播"
),
array(
'type' => 4,
'name' => "业务员"
)
));
}else{//代理主播业务员
//和自己有关的用户
$pa=setpath($adminid);
$uids0=$Proxy->where("path like '%{$pa}%' and (type = 3 or type = 0)")->getField('uid',true);
if(!$uids0){
$uids0=[];
array_push($uids0,'0');
} }
$this->assign('my_total_reg',$my_total_reg); $where1['uid'] = array('in',$uids0);
//$v['total_reg']=$total_reg; if($user['tg_type'] == 2){//一级代理
if($_REQUEST['type'] == 0){
$where['id'] = $adminid;//默认自己
//自客自销,他客自销,自客他销 }else{
$mysolt1 = 0; $where['tg_type'] = array('in',array('3','4','5'));//查看自己下面的和二级代理,主播,业务员
$mysolt2 = 0; }
$map1=$amap;
$map1['uid'] = array('in',$uids); if($_REQUEST['type'] == 2){
$where['tg_type'] = 3;
$_GET['type'] = 2;
//和自己有关的二级代理
$path1=setpath($adminid);
$expends = $coin->where("type='expend' and action='sendgift'")->where($map1)->select();//当前列管理相关的用户所有送的礼物 $uids1=$Proxy->where("path like '%{$path1}%' and type = 2")->getField('uid',true);
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
}
$where['id'] = array('in',$uids1);
//和二级代理有关的
}
if($_REQUEST['type'] == 3){
$where['tg_type'] = 4;
$_GET['type'] = 3;
//和自己有关的主播
$path1=setpath($adminid);
foreach ($expends as $k1 => $v1) { $uids1=$Proxy->where("path like '%{$path1}%' and type = 3")->getField('uid',true);
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
}
$where['id'] = array('in',$uids1);
}
if($_REQUEST['type'] == 4){
$where['tg_type'] = 5;
$_GET['type'] = 4;
//和自己有关的业务员
$path1=setpath($adminid);
$uid = str_pad($v1['uid'],8,"0",STR_PAD_LEFT);//送礼的人 $uids1=$Proxy->where("path like '%{$path1}%' and type = -1")->getField('uid',true);
$touid = str_pad($v1['touid'],8,"0",STR_PAD_LEFT);//收礼的人 if(!$uids1){
$uids1=[];
$iszi = $Proxy->where("uid = {$v1['uid']} and (type = 0 or type = 3) and path like '%{$touid}%'")->count(); array_push($uids1,'0');
//var_dump($Proxy->getLastSql()); }
if($iszi){//自客自销 $where['id'] = array('in',$uids1);
$mysolt1 += $v1['totalcoin'];
}else{//自客他销
$mysolt2 += $v1['totalcoin'];
} }
} $this->assign('type',$_REQUEST['type']);
// $v['solt1'] = $solt1; $this->assign('types',array(
// $v['solt2'] = $solt2; array(
'type' => 0,
'name' => "我的数据"
//他客自销 ),
$mysolt3 = 0; array(
$map3 = $amap; 'type' => 2,
if($user['tg_type'] == 2 || $user['tg_type'] == 3){//如果是代理 'name' => "二级推广"
),
$uids2 = $Proxy->where("type = 3 and path like '%{$path}%'")->getField('uid',true);//相关的主播 array(
if(!$uids2){ 'type' => 3,
$uids2=[]; 'name' => "主播"
array_push($uids2,'0'); ),
array(
'type' => 4,
'name' => "业务员"
)
));
}elseif($user['tg_type'] == 3){//二级代理
//$where['tg_type'] = array('in',array('4','5'));//查看主播,业务员
if($_REQUEST['type'] == 0){
$where['id'] = $adminid;//默认自己
}else{
$where['tg_type'] = array('in',array('4','5'));//查看自己下面的,主播,业务员
} }
$map3['touid'] = array('in',$uids2); if($_REQUEST['type'] == 3){
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//当前列管理相关的主播所收的礼物 $where['tg_type'] = 4;
foreach ($expends1 as $k3 => $v3) { $_GET['type'] = 3;
//$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人 //和自己有关的主播
$touid = str_pad($v3['touid'],8,"0",STR_PAD_LEFT);//收礼的人 $path1=setpath($adminid);
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count();
if(!$iszi){ $uids1=$Proxy->where("path like '%{$path1}%' and type = 3")->getField('uid',true);
$mysolt3 += $v3['totalcoin']; if(!$uids1){
$uids1=[];
array_push($uids1,'0');
} }
$where['id'] = array('in',$uids1);
} }
if($_REQUEST['type'] == 4){
$where['tg_type'] = 5;
$_GET['type'] = 4;
//和自己有关的业务员
$path1=setpath($adminid);
$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' => 3,
'name' => "主播"
),
array(
'type' => 4,
'name' => "业务员"
)
));
}elseif($user['tg_type'] == 4){//主播 }elseif($user['tg_type'] == 4){//主播
$map3['touid'] = $user['id']; //$where['tg_type'] = array('in',array('5'));//查看业务员的
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//主播收的礼物 if($_REQUEST['type'] == 0){
$touid = str_pad($user['id'],8,"0",STR_PAD_LEFT);//收礼的人 $where['id'] = $adminid;//默认自己
foreach ($expends1 as $k3 => $v3) { }else{
//$uid = str_pad($v1['uid'],8,"0",STR_PAD_LEFT);//送礼的人 $where['tg_type'] = array('in',array('5'));//查看自己下面的,业务员
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count(); }
if(!$iszi){ if($_REQUEST['type'] == 4){
$mysolt3 += $v3['totalcoin']; $where['tg_type'] = 5;
$_GET['type'] = 4;
//和自己有关的业务员
$path1=setpath($adminid);
$uids1=$Proxy->where("path like '%{$path1}%' and type = -1")->getField('uid',true);
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
} }
$where['id'] = array('in',$uids1);
} }
}elseif($user['tg_type'] == 5){//业务员 $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' => "我的数据"
),
));
} }
} }
/* 展示列表 */ /* 展示列表 */
$count=$User->where($where)->count(); $count=$User->where($where)->count();
$page = $this->page($count, 20); $page = $this->page($count, 20);
$users = $User $users = $User
->field('*') ->field('*')
->where($where) ->where($where)
->order("create_time DESC") ->order("create_time DESC")
->limit($page->firstRow . ',' . $page->listRows) ->limit($page->firstRow . ',' . $page->listRows)
->select();//列表用户信息 ->select();//列表用户信息
//var_dump($User->getLastSql());
//var_dump($users);
//总充值金额 //总充值金额
$_total_charge = $Charge->where($where1)->where("status=1")->where($amap)->sum('money'); $_total_charge = $Charge->where($where1)->where("status=1 and uid not in (".implode(",", $fuchi).")")->where($amap)->sum('money');
//var_dump($Charge->getLastSql()); //var_dump($Charge->getLastSql());
if(!$_total_charge){ if(!$_total_charge){
$_total_charge='0'; $_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()); //var_dump($coin->getLastSql());
if(!$total_coin){ if(!$total_coin){
$total_coin='0'; $total_coin='0';
} }
if(!empty($users)){
//列表的数据
foreach($users as $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'] = '业务员';
}
$path1=setpath($v['id']); foreach ($users as $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);//和当前列管理员有关的所有用户 $uids1=$Proxy->where("path like '%{$path1}%' and (type = 0 or type = 3)")->getField('uid',true);//和当前列管理员有关的所有普通用户或者主播
if(!$uids1){
if(!$uids1){ $uids1=[];
$uids1=[]; array_push($uids1,'0');
array_push($uids1,'0'); }
} //充值金额
//$v['test'] = implode("--", $uids1); $map=$amap;
$map['uid'] = array('in',$uids1);
//充值金额
$map=$amap;
$map['uid'] = array('in',$uids1);
$total_charge=$Charge->where("status=1")->where($map)->where($amap)->sum('money');
if(!$total_charge){
$total_charge='0';
}
//充值人数 $total_charge=$Charge->where("status=1 and uid not in (".implode(",", $fuchi).")")->where($map)->sum('money');
$total_charge_num=count($Charge->where("status=1")->where($map)->where($amap)->group('uid')->select()); if(!$total_charge){
//$v['sql'] = $Charge->getLastSql(); $total_charge='0';
if(!$total_charge_num){
$total_charge_num='0';
}
$v['total_charge_num']=$total_charge_num;
$v['total_charge']=$total_charge;
//注册人数
$map2=$bmap;
$map2['id'] = array('in',$uids1);
$total_reg=$User->where("user_type=2")->where($map2)->count();
if(!$total_reg){
$total_reg='0';
}
$v['total_reg']=$total_reg;
//自客自销,他客自销,自客他销
$solt1 = 0;
$solt2 = 0;
$map1=$amap;
$map1['uid'] = array('in',$uids1);
$expends = $coin->where("type='expend' and action='sendgift'")->where($map1)->select();//当前列管理相关的所有送的礼物
foreach ($expends as $k1 => $v1) {
$uid = str_pad($v1['uid'],8,"0",STR_PAD_LEFT);//送礼的人
$touid = str_pad($v1['touid'],8,"0",STR_PAD_LEFT);//收礼的人
$iszi = $Proxy->where("uid = {$v1['uid']} and (type = 0 or type = 3) and path like '%{$touid}%'")->count();
//var_dump($Proxy->getLastSql());
if($iszi){//自客自销
$solt1 += $v1['totalcoin'];
}else{//自客他销
$solt2 += $v1['totalcoin'];
} }
}
$v['solt1'] = $solt1; //充值人数
$v['solt2'] = $solt2; $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';
$solt3 = 0;
$map3 = $amap;
if($v['tg_type'] == 2 || $v['tg_type'] == 3){//如果是代理
$uids2 = $Proxy->where("type = 3 and path like '%{$path1}%'")->getField('uid',true);//相关的主播
if(!$uids2){
$uids2=[];
array_push($uids2,'0');
} }
$map3['touid'] = array('in',$uids2); $v1['total_charge_num']=$total_charge_num;
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//当前列管理相关的所有主播收的礼物 $v1['total_charge']=$total_charge;
foreach ($expends1 as $k3 => $v3) {
//$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人 //注册人数
$touid = str_pad($v3['touid'],8,"0",STR_PAD_LEFT);//收礼的人 $map2=$bmap;
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count(); $map2['id'] = array('in',$uids1);
if(!$iszi){ $total_reg=$User->where("user_type=2 and id not in (".implode(",", $fuchi).")")->where($map2)->count();
$solt3 += $v3['totalcoin']; 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();//当前列管理相关的所有用户送的礼物
//$v1['test'] = $coin->getLastSql();
if($v1['tg_type'] == 2 || $v1['tg_type'] == 3){//对于代理来说
foreach ($expends as $k2 => $v2) {
if(!empty($fuchi) && in_array($v2['uid'], $fuchi)){//排除扶持账户
continue;
}
// $uid = str_pad($v2['uid'],8,"0",STR_PAD_LEFT);//送礼的人
// $iszi = $Proxy->where("uid = {$v2['uid']} and (type = 0 or type = 3) and path like '%{$path1}%'")->count();
$touid = str_pad($v2['touid'],8,"0",STR_PAD_LEFT);//收礼的人
$iszi = $Proxy->where("uid = {$v2['touid']} and (type = 0 or type = 3) and path like '%{$path1}%'")->count();
//var_dump($Proxy->getLastSql());
if($iszi){//自客自销
$solt1 += $v2['totalcoin'];
}else{//自客他销
$solt2 += $v2['totalcoin'];
}
} }
$v1['solt1'] = $solt1;
$v1['solt2'] = $solt2;
}elseif($v1['tg_type'] == 4 || $v1['tg_type'] == 5){//主播,业务员
foreach ($expends as $k2 => $v2) {
if(!empty($fuchi) && in_array($v2['uid'], $fuchi)){//排除扶持账户
continue;
}
$uid = str_pad($v2['uid'],8,"0",STR_PAD_LEFT);//送礼的人
$touid = str_pad($v2['touid'],8,"0",STR_PAD_LEFT);//收礼的人
$iszi = $Proxy->where("uid = {$v2['uid']} and (type = 0 or type = 3) and path like '%{$touid}%'")->count();
//var_dump($Proxy->getLastSql());
if($iszi){//自客自销
$solt1 += $v2['totalcoin'];
}else{//自客他销
$solt2 += $v2['totalcoin'];
}
}
$v1['solt1'] = $solt1;
$v1['solt2'] = $solt2;
} }
//他客自销
}elseif($v['tg_type'] == 4){//主播 $solt3 = 0;
$map3['touid'] = $v['id']; $map3 = $amap;
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//主播收的礼物 if($v1['tg_type'] == 2 || $v1['tg_type'] == 3){//如果是代理
$touid = str_pad($v['id'],8,"0",STR_PAD_LEFT);//收礼的人
foreach ($expends1 as $k3 => $v3) { $uids2 = $Proxy->where("type = 3 and path like '%{$path1}%'")->getField('uid',true);//相关的主播
//$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人 if(!$uids2){
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count(); $uids2=[];
if(!$iszi){ array_push($uids2,'0');
$solt3 += $v3['totalcoin']; }
$map3['touid'] = array('in',$uids2);
$expends1 = $coin->where("type='expend' and action='sendgift' and uid not in (".implode(",", $fuchi).")")->where($map3)->select();//当前列管理相关的所有主播收的礼物
//$v1['test2'] = $coin->getLastSql();
foreach ($expends1 as $k3 => $v3) {
//$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人
//$touid = str_pad($v3['touid'],8,"0",STR_PAD_LEFT);//收礼的人
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$path1}%'")->count();//如果送礼的人和当前代理有关系
if(!$iszi){
$solt3 += $v3['totalcoin'];
}
}
}elseif($v1['tg_type'] == 4){//主播
$map3['touid'] = $v1['id'];
$expends1 = $coin->where("type='expend' and action='sendgift' and uid not in (".implode(",", $fuchi).")")->where($map3)->select();//主播收的礼物
//$v1['test2'] = $coin->getLastSql();
$touid = str_pad($v1['id'],8,"0",STR_PAD_LEFT);//收礼的人
foreach ($expends1 as $k3 => $v3) {
//$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count();
if(!$iszi){
$solt3 += $v3['totalcoin'];
}
} }
} }
}elseif($v['tg_type'] == 5){//业务员 $v1['solt3'] = $solt3;
//业务员没有 //业务员没有
$users[$k1]=$v1;
} }
$v['solt3'] = $solt3;
$users[$k]=$v;
} }
$this->assign('mysolt1',$mysolt1); $this->assign('mysolt1',$mysolt1);
$this->assign('mysolt2',$mysolt2); $this->assign('mysolt2',$mysolt2);
$this->assign('mysolt3',$mysolt3); $this->assign('mysolt3',$mysolt3);
$this->assign('date',$date); $this->assign('date',$date);
$this->assign('isshow',$isshow);
$this->assign('formget', $_GET); $this->assign('formget', $_GET);
$this->assign("page", $page->show('Admin')); $this->assign("page", $page->show('Admin'));
$this->assign("_total_charge",$_total_charge); $this->assign("_total_charge",$_total_charge);
...@@ -335,4 +479,4 @@ class GatherController extends AdminbaseController{ ...@@ -335,4 +479,4 @@ class GatherController extends AdminbaseController{
$this->assign("users",$users); $this->assign("users",$users);
$this->display(); $this->display();
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment