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">
...@@ -9,32 +9,25 @@ ...@@ -9,32 +9,25 @@
</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">
<volist name="types" id="v">
<option value="{$v['type']}" <if condition="$formget.type eq $v['type']">selected</if>>{$v['name']}</option>
</volist>
</select>
时间段: 时间段:
<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" 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="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="搜索"> <input type="submit" class="btn btn-primary" value="搜索">
<div style="margin-top:10px"> <div style="margin-top:10px">
{$date}数据统计 (根据筛选条件统计) {$date}月数据统计 (根据筛选条件统计)
<span style="color:red;font-size: 17px;"> <span style="color:red;font-size: 17px;">
普客总充值:¥{$_total_charge} 普客总充值:¥{$_total_charge}
普客刷礼(钻石):{$total_coin} 普客刷礼(萌豆):{$total_coin}
</span> </span>
</div> </div>
<if condition="$my eq 1">
<div style="margin-top:10px">
注册人数:{$my_total_reg}
充值金额:{$my_total_charge}
充值人数:{$my_total_charge_num}
自客自销(钻石):{$mysolt1}
他客自销(钻石):{$mysolt3}
自客他销(钻石):{$mysolt2}
</div>
</if>
</form> </form>
<table class="table table-hover table-bordered"> <table class="table table-hover table-bordered">
<thead> <thead>
...@@ -47,11 +40,11 @@ ...@@ -47,11 +40,11 @@
<th>注册人数</th> <th>注册人数</th>
<th>充值金额</th> <th>充值金额</th>
<th>充值人数</th> <th>充值人数</th>
<th>守护金额(钻石</th> <th>守护金额(萌币</th>
<th>商城消费(钻石</th> <th>商城消费(萌币</th>
<th>自客自销(钻石</th> <th>自客自销(萌币</th>
<th>他客自销(钻石</th> <th>他客自销(萌币</th>
<th>自客他销(钻石</th> <th>自客他销(萌币</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -66,19 +59,22 @@ ...@@ -66,19 +59,22 @@
<td>{$vo.total_reg}</td> <td>{$vo.total_reg}</td>
<td>{$vo.total_charge}</td> <td>{$vo.total_charge}</td>
<td>{$vo.total_charge_num}</td> <td>{$vo.total_charge_num}</td>
<td>{$vo.total_coin}</td> <td>{$vo.guardcoin}</td>
<td>{$vo.total_votes}</td> <td>{$vo.mallcoin}</td>
<td>{$vo.solt1}</td> <td>{$vo.solt1}</td>
<td>{$vo.solt3}</td> <td>{$vo.solt3}</td>
<td>{$vo.solt2}</td> <td>{$vo.solt2}</td>
<!-- <td>{$vo.test}</td> --> <!-- <td>{$vo.test}</td>
<td>{$vo.test2}</td> -->
</tr> </tr>
</foreach> </foreach>
</tbody> </tbody>
</table> </table>
<div class="pagination">{$page}</div> <div class="pagination">{$page}</div>
</div> </div>
<script src="__PUBLIC__/js/common.js"></script> <script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript">
</script>
</body> </body>
</html> </html>
...@@ -11,7 +11,12 @@ class GatherController extends AdminbaseController{ ...@@ -11,7 +11,12 @@ class GatherController extends AdminbaseController{
$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';//默认当月一号开始
...@@ -20,271 +25,410 @@ class GatherController extends AdminbaseController{ ...@@ -20,271 +25,410 @@ class GatherController extends AdminbaseController{
//默认时间搜索条件 //默认时间搜索条件
$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=[];
if($_REQUEST['keyword']!=''){ $mysolt1 = 0;
$where['user_login|user_nicename']=array("like","%{$_REQUEST['keyword']}%"); $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;
// }
$_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($_REQUEST['type'] == 1){
$where['tg_type'] = 2;
$_GET['type'] = 1;
}
if($_REQUEST['type'] == 2){
$where['tg_type'] = 3;
$_GET['type'] = 2;
}
if($_REQUEST['type'] == 3){
$where['tg_type'] = 4;
$_GET['type'] = 3;
}
if($_REQUEST['type'] == 4){
$where['tg_type'] = 5;
$_GET['type'] = 4;
}
$this->assign('types',array(
array(
'type' => 0,
'name' => "总数据"
),
array(
'type' => 1,
'name' => "一级推广"
),
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');
}
$where1['uid'] = array('in',$uids0);
if($user['tg_type'] == 2){//一级代理 if($user['tg_type'] == 2){//一级代理
$where['tg_type'] = array('in',array('3','4','5'));//查看自己下面的和二级代理,主播,业务员 if($_REQUEST['type'] == 0){
$where['id'] = $adminid;//默认自己
}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;
}
$path=setpath($user['id']);
$uids=$Proxy->where("path like '%{$path}%'")->getField('uid',true);//与当前管理员,代理,主播,业务员有关的所有用户
if($uids){
$where["id"] = array('in',$uids);
$where1["uid"] = array('in',$uids);
}else{ }else{
$where["id"] = array('in',array('0')); $where['tg_type'] = array('in',array('3','4','5'));//查看自己下面的和二级代理,主播,业务员
$where1["uid"] = array('in',array('0'));
} }
//充值金额
$map=$amap;
$map['uid'] = array('in',$uids);
$my_total_charge=$Charge->where("status=1")->where($map)->sum('money'); if($_REQUEST['type'] == 2){
if(!$my_total_charge){ $where['tg_type'] = 3;
$my_total_charge='0'; $_GET['type'] = 2;
//和自己有关的二级代理
$path1=setpath($adminid);
$uids1=$Proxy->where("path like '%{$path1}%' and type = 2")->getField('uid',true);
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
} }
$this->assign('my_total_charge',$my_total_charge); $where['id'] = array('in',$uids1);
//充值人数 //和二级代理有关的
$my_total_charge_num=count($Charge->where("status=1")->where($map)->group('uid')->select());
//$v['sql'] = $Charge->getLastSql();
if(!$my_total_charge_num){
$my_total_charge_num='0';
} }
$this->assign('my_total_charge_num',$my_total_charge_num); if($_REQUEST['type'] == 3){
// $v['total_charge_num']=$total_charge_num; $where['tg_type'] = 4;
// $v['total_charge']=$total_charge; $_GET['type'] = 3;
//和自己有关的主播
$path1=setpath($adminid);
//注册人数 $uids1=$Proxy->where("path like '%{$path1}%' and type = 3")->getField('uid',true);
$map2=$bmap; if(!$uids1){
$map2['id'] = array('in',$uids); $uids1=[];
$my_total_reg=$User->where("user_type=2")->where($map2)->count(); array_push($uids1,'0');
if(!$my_total_reg){
$my_total_reg='0';
} }
$this->assign('my_total_reg',$my_total_reg); $where['id'] = array('in',$uids1);
//$v['total_reg']=$total_reg; }
if($_REQUEST['type'] == 4){
//自客自销,他客自销,自客他销 $where['tg_type'] = 5;
$mysolt1 = 0; $_GET['type'] = 4;
$mysolt2 = 0; //和自己有关的业务员
$map1=$amap; $path1=setpath($adminid);
$map1['uid'] = array('in',$uids);
$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(); $uids1=$Proxy->where("path like '%{$path1}%' and type = -1")->getField('uid',true);
//var_dump($Proxy->getLastSql()); if(!$uids1){
if($iszi){//自客自销 $uids1=[];
$mysolt1 += $v1['totalcoin']; array_push($uids1,'0');
}else{//自客他销
$mysolt2 += $v1['totalcoin'];
} }
$where['id'] = array('in',$uids1);
}
$this->assign('type',$_REQUEST['type']);
$this->assign('types',array(
array(
'type' => 0,
'name' => "我的数据"
),
array(
'type' => 2,
'name' => "二级推广"
),
array(
'type' => 3,
'name' => "主播"
),
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'));//查看自己下面的,主播,业务员
} }
// $v['solt1'] = $solt1; if($_REQUEST['type'] == 3){
// $v['solt2'] = $solt2; $where['tg_type'] = 4;
$_GET['type'] = 3;
//和自己有关的主播
$path1=setpath($adminid);
$uids1=$Proxy->where("path like '%{$path1}%' and type = 3")->getField('uid',true);
//他客自销 if(!$uids1){
$mysolt3 = 0; $uids1=[];
$map3 = $amap; array_push($uids1,'0');
if($user['tg_type'] == 2 || $user['tg_type'] == 3){//如果是代理
$uids2 = $Proxy->where("type = 3 and path like '%{$path}%'")->getField('uid',true);//相关的主播
if(!$uids2){
$uids2=[];
array_push($uids2,'0');
}
$map3['touid'] = array('in',$uids2);
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//当前列管理相关的主播所收的礼物
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 '%{$touid}%'")->count();
if(!$iszi){
$mysolt3 += $v3['totalcoin'];
} }
$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){
$mysolt3 += $v3['totalcoin'];
} }
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');
} }
}elseif($user['tg_type'] == 5){//业务员 $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' => "我的数据"
),
));
} }
} }
/* 展示列表 */ /* 展示列表 */
$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 $k1 => $v1) {
foreach($users as $k=>$v){ if($v1['tg_type'] == 2){
if($v['tg_type'] == 2){ $v1['rbac'] = '一级代理';
$v['rbac'] = '一级代理'; }elseif($v1['tg_type'] == 3){
}elseif($v['tg_type'] == 3){ $v1['rbac'] = '二级代理';
$v['rbac'] = '二级代理'; }elseif($v1['tg_type'] == 4){
}elseif($v['tg_type'] == 4){ $v1['rbac'] = '主播';
$v['rbac'] = '主播'; }elseif($v1['tg_type'] == 5){
}elseif($v['tg_type'] == 5){ $v1['rbac'] = '业务员';
$v['rbac'] = '业务员';
} }
$path1=setpath($v1['id']);
$path1=setpath($v['id']); $uids1=$Proxy->where("path like '%{$path1}%' and (type = 0 or type = 3)")->getField('uid',true);//和当前列管理员有关的所有普通用户或者主播
$uids1=$Proxy->where("path like '%{$path1}%'")->getField('uid',true);//和当前列管理员有关的所有用户
if(!$uids1){ if(!$uids1){
$uids1=[]; $uids1=[];
array_push($uids1,'0'); array_push($uids1,'0');
} }
//$v['test'] = implode("--", $uids1);
//充值金额 //充值金额
$map=$amap; $map=$amap;
$map['uid'] = array('in',$uids1); $map['uid'] = array('in',$uids1);
$total_charge=$Charge->where("status=1")->where($map)->where($amap)->sum('money'); $total_charge=$Charge->where("status=1 and uid not in (".implode(",", $fuchi).")")->where($map)->sum('money');
if(!$total_charge){ if(!$total_charge){
$total_charge='0'; $total_charge='0';
} }
//充值人数 //充值人数
$total_charge_num=count($Charge->where("status=1")->where($map)->where($amap)->group('uid')->select()); $total_charge_num=count($Charge->where("status=1 and uid not in (".implode(",", $fuchi).")")->where($map)->group('uid')->select());
//$v['sql'] = $Charge->getLastSql(); //$v1['sql'] = $Charge->getLastSql();
if(!$total_charge_num){ if(!$total_charge_num){
$total_charge_num='0'; $total_charge_num='0';
} }
$v['total_charge_num']=$total_charge_num; $v1['total_charge_num']=$total_charge_num;
$v['total_charge']=$total_charge; $v1['total_charge']=$total_charge;
//注册人数 //注册人数
$map2=$bmap; $map2=$bmap;
$map2['id'] = array('in',$uids1); $map2['id'] = array('in',$uids1);
$total_reg=$User->where("user_type=2")->where($map2)->count(); $total_reg=$User->where("user_type=2 and id not in (".implode(",", $fuchi).")")->where($map2)->count();
if(!$total_reg){ if(!$total_reg){
$total_reg='0'; $total_reg='0';
} }
$v['total_reg']=$total_reg; $v1['total_reg']=$total_reg;
//自客自销,他客自销,自客他销
$solt1 = 0;
$solt2 = 0;
$map1=$amap; $map1=$amap;
$map1['uid'] = array('in',$uids1); $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;
$expends = $coin->where("type='expend' and action='sendgift'")->where($map1)->select();//当前列管理相关的所有送的礼物 //自客自销,他客自销,自客他销
$solt1 = 0;
$solt2 = 0;
foreach ($expends as $k1 => $v1) { $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) {
$uid = str_pad($v1['uid'],8,"0",STR_PAD_LEFT);//送礼的人 if(!empty($fuchi) && in_array($v2['uid'], $fuchi)){//排除扶持账户
$touid = str_pad($v1['touid'],8,"0",STR_PAD_LEFT);//收礼的人 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 = {$v1['uid']} and (type = 0 or type = 3) and path like '%{$touid}%'")->count(); $iszi = $Proxy->where("uid = {$v2['touid']} and (type = 0 or type = 3) and path like '%{$path1}%'")->count();
//var_dump($Proxy->getLastSql()); //var_dump($Proxy->getLastSql());
if($iszi){//自客自销 if($iszi){//自客自销
$solt1 += $v1['totalcoin']; $solt1 += $v2['totalcoin'];
}else{//自客他销 }else{//自客他销
$solt2 += $v1['totalcoin']; $solt2 += $v2['totalcoin'];
} }
} }
$v['solt1'] = $solt1; $v1['solt1'] = $solt1;
$v['solt2'] = $solt2; $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;
}
//他客自销 //他客自销
$solt3 = 0; $solt3 = 0;
$map3 = $amap; $map3 = $amap;
if($v['tg_type'] == 2 || $v['tg_type'] == 3){//如果是代理 if($v1['tg_type'] == 2 || $v1['tg_type'] == 3){//如果是代理
$uids2 = $Proxy->where("type = 3 and path like '%{$path1}%'")->getField('uid',true);//相关的主播 $uids2 = $Proxy->where("type = 3 and path like '%{$path1}%'")->getField('uid',true);//相关的主播
if(!$uids2){ if(!$uids2){
...@@ -292,21 +436,22 @@ class GatherController extends AdminbaseController{ ...@@ -292,21 +436,22 @@ class GatherController extends AdminbaseController{
array_push($uids2,'0'); array_push($uids2,'0');
} }
$map3['touid'] = array('in',$uids2); $map3['touid'] = array('in',$uids2);
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//当前列管理相关的所有主播收的礼物 $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) { foreach ($expends1 as $k3 => $v3) {
//$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人 //$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人
$touid = str_pad($v3['touid'],8,"0",STR_PAD_LEFT);//收礼的人 //$touid = str_pad($v3['touid'],8,"0",STR_PAD_LEFT);//收礼的人
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count(); $iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$path1}%'")->count();//如果送礼的人和当前代理有关系
if(!$iszi){ if(!$iszi){
$solt3 += $v3['totalcoin']; $solt3 += $v3['totalcoin'];
} }
} }
}elseif($v['tg_type'] == 4){//主播 }elseif($v1['tg_type'] == 4){//主播
$map3['touid'] = $v['id']; $map3['touid'] = $v1['id'];
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//主播收的礼物 $expends1 = $coin->where("type='expend' and action='sendgift' and uid not in (".implode(",", $fuchi).")")->where($map3)->select();//主播收的礼物
$touid = str_pad($v['id'],8,"0",STR_PAD_LEFT);//收礼的人 //$v1['test2'] = $coin->getLastSql();
$touid = str_pad($v1['id'],8,"0",STR_PAD_LEFT);//收礼的人
foreach ($expends1 as $k3 => $v3) { foreach ($expends1 as $k3 => $v3) {
//$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人 //$uid = str_pad($v3['uid'],8,"0",STR_PAD_LEFT);//送礼的人
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count(); $iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count();
...@@ -314,12 +459,11 @@ class GatherController extends AdminbaseController{ ...@@ -314,12 +459,11 @@ class GatherController extends AdminbaseController{
$solt3 += $v3['totalcoin']; $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);
...@@ -327,7 +471,7 @@ class GatherController extends AdminbaseController{ ...@@ -327,7 +471,7 @@ class GatherController extends AdminbaseController{
$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);
......
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