diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 7d0a4cb7e..a516e315f 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -123,13 +123,16 @@ class MemberController extends ThinkController 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')) . ")"; - // } - $spendprom = " and ss.game_id in (".implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')).")"; + $game_map .= " and tab_user_play.game_id in (" . implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) . ")"; + $spendprom .= " and ss.game_id in (".implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')).")"; if (isset($_REQUEST['server_name'])) { - $map['server_name'] = ['like', "{$_REQUEST['server_name']}%"]; + $spendprom .= " and ss.server_name like '{$_REQUEST['server_name']}%' "; + } + $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'])) { @@ -188,6 +191,8 @@ class MemberController extends ThinkController 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') @@ -197,6 +202,8 @@ class MemberController extends ThinkController }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') @@ -208,20 +215,22 @@ class MemberController extends ThinkController //计数 $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); - - $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); + $allcount = M()->field('count(a.id) as count,sum(a.recharge_total) recharge_total')->table('(' . $sql . ') as a')->select(); + $this->assign('history_count', $allcount[0]['recharge_total']); //替换为新表 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) @@ -229,10 +238,10 @@ class MemberController extends ThinkController } $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 ; + $count = $jcount[0]['count']; + //var_dump(M('User', 'tab_')->getLastSql());die(); $this->assign('user_count', $count); - // var_dump($jcount);die(); - $this->assign('now_count', $jcount[0]['recharge_total']?:0); + $this->assign('now_count', $jcount[0]['recharge_total']); $model = M('Model')->getByName('user');