diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index f49ea9d77..1680e8213 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -6,7 +6,6 @@ use Sdk\Controller\AgeController; use Think\Log; use User\Api\MemberApi as MemberApi; use Org\WeixinSDK\Weixin; - class MemberController extends ThinkController { @@ -118,8 +117,6 @@ class MemberController extends ThinkController if ($promoteRoot!='all') { $promoteRoot = ''; } - - $promoter_ids = D("Promote")->where("(chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']})".$promoteRoot)->field('id')->select(); if ($promoter_ids) { $map['tab_user.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))]; @@ -132,10 +129,9 @@ class MemberController extends ThinkController //计算用户列表 $data = M("user","tab_") - ->field("tab_user.id,`device_number`,count(`device_number`) as device_count,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(sum(ss.pay_amount), 0) AS recharge_total") + ->field("tab_user.id,`device_number`,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(ss.pay_amount,0) AS recharge_total") ->where($map) - ->group("device_number,tab_user.register_ip") - // ->page($page, $row) + ->group("tab_user.id") ->order($order); if($havs){ @@ -151,54 +147,13 @@ class MemberController extends ThinkController (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id "); } - if($promoterSelect){ - $data->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left"); - }else{ - $data->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left"); - } - - $data = $data->select(false); - - $data = M()->table('(' . $data . ') as a '); + $data->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left"); if(!isset($_REQUEST['export'])){ $data ->page($page, $row); } $data = $data->select(); -// var_dump($data);die(); - - //计算用户列表重复数量 - $userRepeat = M("user","tab_") - ->field("count(`device_number`) as device_count") - ->where($map) - ->group("device_number,tab_user.register_ip") - // ->page($page, $row) - ->order($order); - - if($havs){ - $userRepeat->having($havs); - } - if($gameplay){ - $userRepeat->join(" - (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id - "); - } - if($game_map){ - $userRepeat->join(" - (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id - "); - } - if($promoterSelect){ - $userRepeat->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left"); - }else{ - $userRepeat->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left"); - } - - $userRepeat = $userRepeat->select(false); - $userRepeat = M()->table('(' . $userRepeat . ') as a ')->count(); - - if(isset($_REQUEST['export'])){ $isadmin = is_administrator(); //获取等级 @@ -238,7 +193,6 @@ class MemberController extends ThinkController $v['login_time'] = date('Y-m-d H:i:s',$v['login_time']); $v['lock_status'] = get_info_status($v['lock_status'],4); $v['check_status'] = $v['check_status']==1 ? "正常" :"拉黑"; - // $data[$k] = $v; } $field = array( @@ -274,11 +228,8 @@ class MemberController extends ThinkController (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id "); } - if($promoterSelect){ - $user_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left"); - }else{ - $user_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left"); - } + $user_count->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left"); + $user_count = $user_count->select(false); $count = M()->table('(' . $user_count . ') as a ')->field("count(*) user_count,sum(a.recharge_total) recharge_total")->find(); $user_count = $count['user_count']; @@ -300,347 +251,40 @@ class MemberController extends ThinkController "); } $user_count = $user_count->find()['user_count']; - //计算累计充值总额 - $now_count = M("user","tab_") - ->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total") + + //累计充值统计 + $user_sql = M("user","tab_") + ->field('id') ->where($map); if($game_map){ - $now_count->join(" + $user_sql->join(" (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id "); } if($gameplay){ - $now_count->join(" + $user_sql->join(" (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id "); } - if($promoterSelect){ - $now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left"); - }else{ - $now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left"); - } - // dump($now_count->select(false));die(); - $now_count = $now_count->find()['recharge_total']; - } - + $user_sql = $user_sql->select(false); - //如果存在推广员只计算所属的推广员充值记录 - if($promoterSelect){ - $maps = $map; - unset($maps['tab_user.promote_id']); - $history_count = M("user","tab_") + $now_count = M("UserData","tab_") + ->alias('ss') ->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total") - ->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left") - ->where($maps); - if($havs){ - $history_count->having($havs); - } - if($game_map){ - $history_count->join("(select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id"); - } - if($gameplay){ - $history_count->join(" - (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id - "); - } - $history_count = $history_count->find()['recharge_total']; - $this->assign('history_count', $history_count?:0); + ->where("user_id in (".$user_sql.")")->find()['recharge_total']; } $this->assign('user_count',$user_count); $this->assign('now_count', $now_count?:0); - $page = set_pagination($userRepeat, $row); - - $this->assign('device_count',$user_count-$userRepeat); - + $page = set_pagination($user_count, $row); if ($page) { $this->assign('_page', $page); } $this->assign('list_data', $data); - //$this->assign("is_admin",is_administrator()); $show_data_power = (is_administrator()|| session('user_auth')['show_data']); $this->assign('show_data_power', $show_data_power); $this->display(); } - - /** - * 用户列表旧版 - */ - public function user_info2($p = 0) - { - $hav = ''; - if ($_REQUEST['promote_id'] != '') { - if ($_REQUEST['promote_id'] == 'UC') { - $maps['tab_user.promote_account'] = 'UC用户'; - $hav .= "tab_user.promote_account = 'UC用户' "; - } else if ($_REQUEST['promote_id'] == 0) { - $maps['tab_user.promote_id'] = 0; - $hav .= "tab_user.promote_id = 0"; - } else { - $promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select(); - if ($promoter_ids) { - $maps['tab_user.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))]; - $hav .= "tab_user.promote_id in (" . implode(',', array_column($promoter_ids, 'id')) . ") "; - $spendprom = " AND ss.promote_id IN (" . implode(',', array_column($promoter_ids, 'id')) . ") "; - } - } - } - if (I('type', 1) == 1) { - if (isset($_GET['register_way'])) { - if ($_GET['register_way'] == 1) { - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type in (1)'; - $maps['tab_user.register_type'] = 1; - } elseif ($_GET['register_way'] == 7) { - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type in(7)'; - $maps['tab_user.register_type'] = 7; - } else { - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type in(2)'; - $maps['tab_user.register_type'] = 2; - } - } else { - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type in (1,2,7)'; - $maps['tab_user.register_type'] = ['in', [1, 2, 7]]; - } - } else { - if (isset($_GET['register_type'])) { - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type = ' . $_GET['register_type']; - $maps['tab_user.register_type'] = $_GET['register_type']; - - } else { - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type in (0,3,4,5,6)'; - $maps['tab_user.register_type'] = ['in', [0, 3, 4, 5, 6]]; - } - } - - if (isset($_REQUEST['user_id'])) { - empty($hav) || $hav .= ' AND '; - $hav .= "tab_user.id = '{$_REQUEST['user_id']}'"; - $maps['tab_user.id'] = $_REQUEST['user_id']; - unset($_REQUEST['user_id']); - } - - if (isset($_REQUEST['account'])) { - empty($hav) || $hav .= ' AND '; - $hav .= "tab_user.account like '%" . I('account') . "%'"; - $maps['tab_user.account'] = ['like', "%" . I('account') . "%"]; - unset($_REQUEST['account']); - } - if (isset($_REQUEST['device_number'])) { - empty($hav) || $hav .= ' AND '; - $hav .= "tab_user.device_number = '{$_REQUEST['device_number']}'"; - $maps['tab_user.device_number'] = $_REQUEST['device_number']; - unset($_REQUEST['device_number']); - } - if (isset($_REQUEST['age_status'])) { - empty($hav) || $hav .= ' AND '; - $hav .= 'tab_user.age_status =' . I('age_status'); - $maps['tab_user.age_status'] = I('age_status'); - unset($_REQUEST['age_status']); - } - if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { - empty($hav) || $hav .= ' AND '; - $hav .= 'tab_user.register_time BETWEEN ' . strtotime(I('time_start')) . ' AND ' . (strtotime(I('time_end')) + 24 * 60 * 60 - 1); - $maps['tab_user.register_time'] = ['between', [strtotime(I('time_start')), strtotime(I('time_end')) + 86399]]; - unset($_REQUEST['time_start']); - unset($_REQUEST['time_end']); - } elseif (isset($_REQUEST['time_start'])) { - empty($hav) || $hav .= ' AND '; - $hav .= 'tab_user.register_time > ' . strtotime(I('time_start')); - $maps['tab_user.register_time'] = ['GT', strtotime(I('time_start'))]; - unset($_REQUEST['time_start']); - } elseif (isset($_REQUEST['time_end'])) { - empty($hav) || $hav .= ' AND '; - $hav .= 'tab_user.register_time < ' . (strtotime(I('time_end')) + 86399); - $maps['tab_user.register_time'] = ['LT', strtotime(I('time_end')) + 86399]; - unset($_REQUEST['time_end']); - } - if (isset($_REQUEST['start']) && isset($_REQUEST['end'])) { - empty($hav) || $hav .= ' AND '; - $hav .= 'tab_user.register_time BETWEEN ' . strtotime(I('start')) . ' AND ' . strtotime(I('end')); - $maps['tab_user.register_time'] = array('between', [strtotime(I('start')), strtotime(I('end'))]); - unset($_REQUEST['start']); - unset($_REQUEST['end']); - } - if (!empty(I('line_day'))) { - $day = strtotime(date('Y-m-d')) - intval(I('line_day')) * 86400; - empty($hav) || $hav .= ' AND '; - $hav .= $day . '> tab_user.login_time'; - $maps['tab_user.login_time'] = ['lt', $day]; - } - if (isset($_REQUEST['status'])) { - $map['lock_status'] = $_REQUEST['status']; - unset($_REQUEST['status']); - } - - $game_map = ""; - - if (isset($_REQUEST['game_name'])) { - $game_map .= " and tab_user_play.game_id in (" . implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) . ")"; - } - $game_play_map = ''; - if (isset($_REQUEST['server_name'])) { - $game_play_map .= " and tab_user_play_info.server_name = '{$_REQUEST['server_name']}' "; - } - - if (isset($_REQUEST['viplevel'])) { - - $havs = get_vip_level_limit('recharge_total', $_REQUEST['viplevel']); - } - - $page = intval($p); - $page = $page ? $page : 1; //默认显示第一页数据 - - if (isset($_REQUEST['row'])) { - $row = $_REQUEST['row']; - } else { - $row = 10; - } - - //排序 - $order = ''; - if (I('key') == 1) { - if (I('balance_status') == 1) { - $order = 'balance,'; - } elseif (I('balance_status') == 2) { - $order = 'balance desc,'; - } - } else { - if (I('recharge_status') == 1) { - $order .= 'recharge_total,'; - } elseif (I('recharge_status') == 2) { - $order .= 'recharge_total desc,'; - } - } - $order .= 'a.id desc'; - - $user = M('user', 'tab_'); - $map['puid'] = array('eq', 0); - $map['is_platform'] = 0; - //数据 - $usermodel = M('user', 'tab_'); - - $userField = "tab_user.id,device_number,age_status,account,balance,gold_coin,alipay,tab_user.promote_id,register_type,tab_user.promote_account,register_time,lock_status,register_way,register_ip,login_time,check_status"; - - $sql1 = $usermodel->field("{$userField},IFNULL(sum(b.pay_amount),0) as deposit_total") - ->join('left join tab_deposit AS b ON tab_user.id = b.user_id AND b.pay_status = 1') - ->where($map) - ->group('tab_user.id') - ->where($hav) - // ->order($order) - ->select(false); - // $data = $usermodel->table('(' . $sql1 . ') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,IFNULL(sum(ss.pay_amount),0) as recharge_total,check_status') - // ->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1') - // ->join($game_map ? "tab_user_play on tab_user_play.user_id = a.id $game_map" : false) - // ->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = a.id $game_play_map" : false) - // ->page($page, $row) - // ->having($havs) - // ->group('a.id') - // ->order($order) - // ->select(); - if($_REQUEST['promote_id'] && $_REQUEST['promote_id'] > -1){ - $data = $usermodel->table('(' . $sql1 . ') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,IFNULL(sum(ss.pay_amount),0) as recharge_total,check_status') - ->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1'.$spendprom) - ->join($game_map ? "tab_user_play on tab_user_play.user_id = a.id $game_map" : false) - ->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = a.id $game_play_map" : false) - ->page($page, $row) - ->having($havs) - ->group('a.id') - ->order($order) - ->select(); - // echo $data;die(); - }else{ - $data = $usermodel->table('(' . $sql1 . ') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,IFNULL(sum(ss.pay_amount),0) as recharge_total,check_status') - ->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1') - ->join($game_map ? "tab_user_play on tab_user_play.user_id = a.id $game_map" : false) - ->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = a.id $game_play_map" : false) - ->page($page, $row) - ->having($havs) - ->group('a.id') - ->order($order) - ->select(); - } - - //计数 - $sql = M('user', 'tab_')->field('tab_user.id,IFNULL(sum(ss.pay_amount),0) AS recharge_total') - ->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1') - ->join($game_map ? "tab_user_play on tab_user_play.user_id = tab_user.id $game_map" : false) - ->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = tab_user.id $game_play_map" : false) - ->where($map) - ->group('tab_user.id') - ->where($hav) - ->having($havs)->select(false); - - $allcountsql = str_replace("tab_user.promote_id","ss.promote_id",$sql); - //获取总额 - $allcount = M()->field('count(a.id) as count,sum(a.recharge_total) recharge_total')->table('(' . $allcountsql . ') as a')->select(); - $this->assign('history_count', $allcount[0]['recharge_total']?:0); - - //替换为新表 - if($_REQUEST['promote_id'] && $_REQUEST['promote_id'] > -1){ - $sql = M('user', 'tab_')->field('tab_user.id,IFNULL(sum(ss.pay_amount),0) AS recharge_total') - ->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1'.$spendprom) - ->join($game_map ? "tab_user_play on tab_user_play.user_id = tab_user.id $game_map" : false) - ->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = tab_user.id $game_play_map" : false) - ->where($map) - ->group('tab_user.id') - ->where($hav) - ->having($havs)->select(false); - } - - $jcount = M('User', 'tab_')->field('count(a.id) as count,sum(a.recharge_total) recharge_total')->table('(' . $sql . ') as a')->select(); - $count = $jcount[0]['count'] ?:0 ; - $this->assign('user_count', $count); - // var_dump($jcount);die(); - $this->assign('now_count', $jcount[0]['recharge_total']?:0); - - $model = M('Model')->getByName('user'); - - if ($data) { - - $ids = array_column($data, 'id'); - /* 在手里 */ - $small = M('user', 'tab_')->field('count(id) as count,puid')->where(['puid' => array('in', $ids)])->group('puid')->select(); - /* 出售中 */ - $small2 = M('user', 'tab_')->field('count(id) as count,source_puid')->where(['source_puid' => array('in', $ids), 'source_time' => 0])->group('source_puid')->select(); - - foreach ($data as $k => $v) { - $data[$k]['small_count'] = 0; - foreach ($small as $s) { - if ($s['puid'] == $v['id']) { - $data[$k]['small_count'] += $s['count']; - break; - } - } - foreach ($small2 as $s) { - if ($s['source_puid'] == $v['id']) { - $data[$k]['small_count'] += $s['count']; - break; - } - } - } - - } - - $page = set_pagination($count, $row); - if ($page) { - $this->assign('_page', $page); - } - $this->assign('list_data', $data); - $this->assign('model', $model); - $this->meta_title = "用户信息"; - - $this->m_title = '玩家列表'; - $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Member/user_info', 'status' => 1])->find()); - - $this->display(); - } - /** * 小号列表 * @author 鹿文学 diff --git a/Application/Admin/View/Member/user_info.html b/Application/Admin/View/Member/user_info.html index 3929848e2..663496c7a 100644 --- a/Application/Admin/View/Member/user_info.html +++ b/Application/Admin/View/Member/user_info.html @@ -315,11 +315,11 @@ - + {$data.lock_remark} - + 已{:get_info_status($data['lock_status'],4)} {:get_info_status($data['lock_status'],4)} @@ -344,26 +344,13 @@ 汇总: - - 当前用户累计充值:{$now_count}    - 历史累计充值:{$history_count}   + 用户累计充值:{$now_count}    用户数:{$user_count}   - 去重用户数:{$device_count} - 当前用户累计充值: 当前属于该推广员的用户的充值累计(不含用户换绑前记录)  /   - 历史累计充值: 历史中属于该推广员的用户的充值累计(含用户换绑前记录)   - 去重用户数:{$device_count} - - - - 当前用户累计充值:{$now_count}  用户数:{$user_count}   - 去重用户数:{$device_count} + 用户累计充值:仅表示符合筛选条件下的所有用户的充值总额,因为存在换绑等原因,所以不作为推广员充值总额的依据。 - - -