Commit 7280e223 by 冷斌

fix bug

parent 9a960dc0
<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="{:U('Gather/index')}">列表</a></li>
<if condition="$isshow">
<li><a href="{:U('Gather/add')}">添加</a></li>
</if>
</ul>
<form class="well form-search" method="post" action="{:U('Gather/index')}">
代理、推广员、主播:
<input type="text" name="keyword" style="width: 200px;" value="{$formget.keyword}" placeholder="请输入用户名、昵称...">
时间段:
<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;">
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="{:U('Gather/index')}">列表</a></li>
<if condition="$isshow">
<li><a href="{:U('Gather/add')}">添加</a></li>
</if>
</ul>
<form class="well form-search" method="post" action="{:U('Gather/index')}">
类型:
<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" 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_coin}
普客刷礼(萌豆):{$total_coin}
</span>
</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>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th width="50">ID</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>
</thead>
<tbody>
<php>$user_statuses=array("0"=>L('已拉黑'),"1"=>'正常',"2"=>'未验证');</php>
<foreach name="users" item="vo">
<tr>
<td>{$vo.id}</td>
<td>{$vo.rbac}</td>
<td>{$vo.user_login}</td>
<td>{$vo.user_nicename}</td>
<td>{$vo.mobile}</td>
<td>{$vo.total_reg}</td>
<td>{$vo.total_charge}</td>
<td>{$vo.total_charge_num}</td>
<td>{$vo.total_coin}</td>
<td>{$vo.total_votes}</td>
<td>{$vo.solt1}</td>
</div>
</form>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th width="50">ID</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>
</thead>
<tbody>
<php>$user_statuses=array("0"=>L('已拉黑'),"1"=>'正常',"2"=>'未验证');</php>
<foreach name="users" item="vo">
<tr>
<td>{$vo.id}</td>
<td>{$vo.rbac}</td>
<td>{$vo.user_login}</td>
<td>{$vo.user_nicename}</td>
<td>{$vo.mobile}</td>
<td>{$vo.total_reg}</td>
<td>{$vo.total_charge}</td>
<td>{$vo.total_charge_num}</td>
<td>{$vo.guardcoin}</td>
<td>{$vo.mallcoin}</td>
<td>{$vo.solt1}</td>
<td>{$vo.solt3}</td>
<td>{$vo.solt2}</td>
<!-- <td>{$vo.test}</td>
<td>{$vo.test2}</td> -->
</tr>
</foreach>
</tbody>
</table>
<div class="pagination">{$page}</div>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript">
<td>{$vo.solt3}</td>
<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>
</script>
</body>
</html>
......@@ -4,330 +4,474 @@ namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class GatherController extends AdminbaseController{
protected $users_model,$role_model;
function _initialize() {
parent::_initialize();
$this->users_model = D("Common/Users");
$this->role_model = D("Common/Role");
}
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");//默认当月
$stime = $date.'-01 00:00:00';//默认当月一号开始
$etime = $date.date("-d H:i:s");//当前时间
//默认时间搜索条件
$amap['addtime'] = array("between",array(strtotime($stime),strtotime($etime)));
$bmap['create_time'] = array("between",array($stime,$etime));
$Charge=M('users_charge');//充值表
$coin=M("users_coinrecord");//礼物支出
$User=M('users');
$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']!=''){
$amap['addtime']=array("gt",strtotime($_REQUEST['start_time']));
$bmap['create_time']=array("gt",$_REQUEST['start_time']);
$amap['addtime']=array("gt",strtotime($_REQUEST['start_time'].' 00:00:00'));
$bmap['create_time']=array("gt",$_REQUEST['start_time'].' 00:00:00');
$_GET['start_time']=$_REQUEST['start_time'];
}
if($_REQUEST['end_time']!=''){
$amap['addtime']=array("lt",strtotime($_REQUEST['end_time']));
$bmap['create_time']=array("lt",$_REQUEST['end_time']);
$amap['addtime']=array("lt",strtotime($_REQUEST['end_time'].' 23:59:59'));
$bmap['create_time']=array("lt",$_REQUEST['end_time'].' 23:59:59');
$_GET['end_time']=$_REQUEST['end_time'];
}
if($_REQUEST['start_time']!='' && $_REQUEST['end_time']!='' ){
$amap['addtime']=array("between",array(strtotime($_REQUEST['start_time']),strtotime($_REQUEST['end_time'])));
$bmap['create_time']=array("between",array($_REQUEST['start_time'],$_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'].' 00:00:00',$_REQUEST['end_time'].' 23:59:59'));
$_GET['start_time']=$_REQUEST['start_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'));
$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']);
$uids=$Proxy->where("path like '%{$path}%'")->getField('uid',true);//与当前管理员,代理,主播,业务员有关的所有用户
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'] == 2){
$where['tg_type'] = 3;
$_GET['type'] = 2;
}
//充值金额
$map=$amap;
$map['uid'] = array('in',$uids);
$my_total_charge=$Charge->where("status=1")->where($map)->sum('money');
if(!$my_total_charge){
$my_total_charge='0';
if($_REQUEST['type'] == 3){
$where['tg_type'] = 4;
$_GET['type'] = 3;
}
$this->assign('my_total_charge',$my_total_charge);
//充值人数
$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';
if($_REQUEST['type'] == 4){
$where['tg_type'] = 5;
$_GET['type'] = 4;
}
$this->assign('my_total_charge_num',$my_total_charge_num);
// $v['total_charge_num']=$total_charge_num;
// $v['total_charge']=$total_charge;
//注册人数
$map2=$bmap;
$map2['id'] = array('in',$uids);
$my_total_reg=$User->where("user_type=2")->where($map2)->count();
if(!$my_total_reg){
$my_total_reg='0';
$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');
}
$this->assign('my_total_reg',$my_total_reg);
//$v['total_reg']=$total_reg;
$where1['uid'] = array('in',$uids0);
if($user['tg_type'] == 2){//一级代理
if($_REQUEST['type'] == 0){
$where['id'] = $adminid;//默认自己
//自客自销,他客自销,自客他销
$mysolt1 = 0;
$mysolt2 = 0;
$map1=$amap;
}else{
$where['tg_type'] = array('in',array('3','4','5'));//查看自己下面的和二级代理,主播,业务员
}
$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);//送礼的人
$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){//自客自销
$mysolt1 += $v1['totalcoin'];
}else{//自客他销
$mysolt2 += $v1['totalcoin'];
$uids1=$Proxy->where("path like '%{$path1}%' and type = -1")->getField('uid',true);
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
}
$where['id'] = array('in',$uids1);
}
}
// $v['solt1'] = $solt1;
// $v['solt2'] = $solt2;
//他客自销
$mysolt3 = 0;
$map3 = $amap;
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');
$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'));//查看自己下面的,主播,业务员
}
$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'];
if($_REQUEST['type'] == 3){
$where['tg_type'] = 4;
$_GET['type'] = 3;
//和自己有关的主播
$path1=setpath($adminid);
$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);
$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){//主播
$map3['touid'] = $user['id'];
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//主播收的礼物
$touid = str_pad($user['id'],8,"0",STR_PAD_LEFT);//收礼的人
foreach ($expends1 as $k3 => $v3) {
//$uid = str_pad($v1['uid'],8,"0",STR_PAD_LEFT);//送礼的人
$iszi = $Proxy->where("uid = {$v3['uid']} and path like '%{$touid}%'")->count();
if(!$iszi){
$mysolt3 += $v3['totalcoin'];
//$where['tg_type'] = array('in',array('5'));//查看业务员的
if($_REQUEST['type'] == 0){
$where['id'] = $adminid;//默认自己
}else{
$where['tg_type'] = array('in',array('5'));//查看自己下面的,业务员
}
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);
}
}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();
$page = $this->page($count, 20);
$users = $User
->field('*')
->where($where)
->order("create_time DESC")
->limit($page->firstRow . ',' . $page->listRows)
->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());
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($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'] = '业务员';
}
if(!empty($users)){
$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);//和当前列管理员有关的所有用户
if(!$uids1){
$uids1=[];
array_push($uids1,'0');
}
//$v['test'] = implode("--", $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';
}
$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_num=count($Charge->where("status=1")->where($map)->where($amap)->group('uid')->select());
//$v['sql'] = $Charge->getLastSql();
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'];
$total_charge=$Charge->where("status=1 and uid not in (".implode(",", $fuchi).")")->where($map)->sum('money');
if(!$total_charge){
$total_charge='0';
}
}
$v['solt1'] = $solt1;
$v['solt2'] = $solt2;
//他客自销
$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');
//充值人数
$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';
}
$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){
$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();//当前列管理相关的所有用户送的礼物
//$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){//主播
$map3['touid'] = $v['id'];
$expends1 = $coin->where("type='expend' and action='sendgift'")->where($map3)->select();//主播收的礼物
$touid = str_pad($v['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'];
//他客自销
$solt3 = 0;
$map3 = $amap;
if($v1['tg_type'] == 2 || $v1['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);
$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('mysolt2',$mysolt2);
$this->assign('mysolt3',$mysolt3);
$this->assign('date',$date);
$this->assign('isshow',$isshow);
$this->assign('formget', $_GET);
$this->assign("page", $page->show('Admin'));
$this->assign("_total_charge",$_total_charge);
......@@ -335,4 +479,4 @@ class GatherController extends AdminbaseController{
$this->assign("users",$users);
$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