diff --git a/Addons/SiteStat/info.html b/Addons/SiteStat/info.html index 9b92ecb22..840ef2248 100644 --- a/Addons/SiteStat/info.html +++ b/Addons/SiteStat/info.html @@ -96,7 +96,7 @@ $(document).ready(function () { 【游戏充值】 游戏充值待补单数 - {$daiban['spenc']} + {$daiban['spenc']} 【APP安卓分包】 diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 14903a25e..93520cd73 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -254,13 +254,15 @@ function all_pay_way($type=false) $pay_way[1]=array('key'=>-1,'value'=>"绑币"); $pay_way[2]=array('key'=>1,'value'=>"支付宝"); $pay_way[3]=array('key'=>2,'value'=>"微信"); + $pay_way[7]=array('key'=>8,'value'=>'金猪'); + $pay_way[9]=array('key'=>9,'value'=>"双乾支付-支付宝"); + $pay_way[10]=array('key'=>10,'value'=>"双乾支付-银联"); // $pay_way[3]=array('key'=>3,'value'=>'微信APP'); // $pay_way[4]=array('key'=>4,'value'=>'威富通'); /* $pay_way[4]=array('key'=>5,'value'=>'聚宝云'); */ // $pay_way[5]=array('key'=>6,'value'=>'汇付宝'); /* $pay_way[6]=array('key'=>7,'value'=>"苹果支付"); */ - $pay_way[7]=array('key'=>8,'value'=>'金猪'); $pay_way[15]=array('key'=>15,'value'=>'双乾支付-快捷'); return $pay_way; } @@ -1446,6 +1448,8 @@ function cash_pay_way() /* $pay_way[6]=array('key'=>7,'value'=>"苹果支付"); */ $pay_way[7]=array('key'=>8,'value'=>'金猪'); + $pay_way[9]=array('key'=>9,'value'=>"双乾支付-支付宝"); + $pay_way[10]=array('key'=>10,'value'=>"双乾支付-银联"); $pay_way[15]=array('key'=>15,'value'=>'双乾支付-快捷'); return $pay_way; } @@ -1493,6 +1497,18 @@ function getPayType($type) { case 6: $return = '竣付通'; break; + case 7: + $return = '金猪'; + break; + case 9: + $return = '双乾支付-支付宝'; + break; + case 10: + $return = '双乾支付-银联'; + break; + case 15: + $return = '双乾支付-快捷'; + break; default: $return = '未知'; break; diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php index 8bdd063ae..21da2b965 100644 --- a/Application/Admin/Controller/AutoController.class.php +++ b/Application/Admin/Controller/AutoController.class.php @@ -907,6 +907,7 @@ public function auto_rrdae(){ { $res = M('user_play_data_count', 'tab_')->order('id asc')->find(); if (empty($res)) { + ini_set('memory_limit','500M'); $time = strtotime(date('Y-m-d 00:00:00', time())); $map['pay_time'] = ['lt', $time]; @@ -923,23 +924,29 @@ public function auto_rrdae(){ $map['pay_status'] = 1; $map['pay_game_status'] = 1; $map['game_player_id'] = ['gt', 0]; - $field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count'; + $map['server_id'] = ['gt', 0]; + $field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,promote_id,user_id,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count'; $spendData = M('spend', 'tab_')->field($field) ->where($map) - ->group('day,game_player_id,server_id,game_id') + ->group('day,game_player_id,server_id,game_id,user_id,promote_id') ->select(); if (!empty($spendData)) { $data = []; - foreach ($spendData as $list) { - $save['game_id'] = $list['game_id']; - $save['server_id'] = $list['server_id']; - $save['role_id'] = $list['game_player_id']; - $save['recharge_cost'] = $list['recharge_cost']; - $save['recharge_count'] = $list['recharge_count']; - $save['create_time'] = strtotime($list['day']); - $data[] = $save; + foreach ($spendData as &$list) { + $data[] = [ + 'promote_id' => $list['promote_id'], + 'user_id' => $list['user_id'], + 'game_id' => $list['game_id'], + 'server_id' => $list['server_id'], + 'role_id' => $list['game_player_id'], + 'recharge_cost' => $list['recharge_cost'], + 'recharge_count' => $list['recharge_count'], + 'create_time' => strtotime($list['day']), + ]; + unset($list); } + unset($spendData); M('user_play_data_count', 'tab_')->addAll($data); } } diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index ef8cbb65f..71ff3486e 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -89,12 +89,22 @@ class ConsoleController extends Think { } } + public function modifyLoginRepair() + { + $this->modifyLogin(1569686400); + } + + public function modifyLoginGenerate() + { + $this->modifyLogin(strtotime(date("Y-m-d"))-86400); + } + /** * 登录校验 */ - public function modifyLogin() + private function modifyLogin($start_time=0) { - $start_time = $current_time = strtotime(date("Y-m-d")); + $current_time = strtotime(date("Y-m-d"))-86400; for ($i=$start_time; $i<=$current_time; $i+=86400) { $end_time = $i+86400; $result = M()->query("SELECT @@ -129,29 +139,14 @@ class ConsoleController extends Think { public function deleteRepeatUserPlayInfo() { - /* INSERT INTO `tab_server`(`game_id`, `game_name`, `server_name`, `server_num`, `recommend_status`, `show_status`, `stop_status`, `server_status`, `icon`, `start_time`, `desride`, `prompt`, `parent_id`, `create_time`, `server_version`, `developers`, `server_id`) VALUES - (148, '王者纷争(安卓版)', 'O3-潜龙于渊', 3294, 1, 1, 0, 0, NULL, 1571399818, NULL, NULL, NULL, 1571399818, 1, 0, '3294'), - (148, '王者纷争(安卓版)', 'O4-攻心为上', 3301, 1, 1, 0, 0, NULL, 1571399818, NULL, NULL, NULL, 1571399818, 1, 0, '3301'), - (148, '王者纷争(安卓版)', 'O5-知人善用', 3311, 1, 1, 0, 0, NULL, 1571399818, NULL, NULL, NULL, 1571399818, 1, 0, '3311'), - (148, '王者纷争(安卓版)', 'O8-剑拔弩张', 3332, 1, 1, 0, 0, NULL, 1571399818, NULL, NULL, NULL, 1571399818, 1, 0, '3332'), - (148, '王者纷争(安卓版)', 'O12-七擒七纵', 3336, 1, 1, 0, 0, NULL, 1571399818, NULL, NULL, NULL, 1571399818, 1, 0, '3336'), - (148, '王者纷争(安卓版)', 'O15-遮空蔽日', 3375, 1, 1, 0, 0, NULL, 1571399818, NULL, NULL, NULL, 1571399818, 1, 0, '3375'); */ + $gameIds = [157, 155, 153, 150, 151, 148, 175, 142, 143, 172, 173, 155, 154]; + foreach($gameIds as $gameId) { + $this->doDeleteRepeatUserPlayInfo($gameId); + } + } - // $gameId = 157; - // $gameId = 155; - // $gameId = 153; - // $gameId = 150; - // $gameId = 151; - // 需要先执行上面sql插入区服才能清理干净 - // $gameId = 148; - // $gameId = 175; - // $gameId = 142; - // $gameId = 143; - // $gameId = 172; - // $gameId = 173; - // $gameId = 155; - // $gameId = 154; - $gameId = 153; + public function doDeleteRepeatUserPlayInfo($gameId) + { $sql = 'select id from tab_user_play_info a left join ( select role_id, server_id, game_id, count(1) from tab_user_play_info where server_id="' . $serverId . '" and game_id = ' . $gameId . ' GROUP BY role_id, server_id, game_id, server_name having count(1) > 1 ) b on a.role_id=b.role_id where a.server_id=b.server_id and a.game_id=b.game_id and a.server_id="' . $serverId . '" and a.game_id = ' . $gameId . ' order by a.role_id, a.server_id, a.game_id'; @@ -198,24 +193,14 @@ class ConsoleController extends Think { public function deleteRepeatUserPlayInfo2() { - // $gameId = 157; - // $gameId = 148; - // $gameId = 150; - // $gameId = 151; - // $gameId = 158; - // $gameId = 175; - // $gameId = 142; - // $gameId = 143; - // $gameId = 172; - // $gameId = 173; - // $gameId = 154; - // $gameId = 155; - // $gameId = 176; - // $gameId = 165; - // $gameId = 164; - // $gameId = 179; - // $gameId = 156; - $gameId = 153; + $gameIds = [157, 148, 150, 151, 158, 175, 142, 143, 172, 173, 154, 155, 176, 165, 164, 179, 156, 153]; + foreach ($gameIds as $gameId) { + $this->doDeleteRepeatUserPlayInfo2($gameId); + } + } + + public function doDeleteRepeatUserPlayInfo2($gameId) + { $sql = 'select id from tab_user_play_info a left join ( select role_id, server_id, game_id, count(1) from tab_user_play_info where server_id="' . $serverId . '" and game_id = ' . $gameId . ' GROUP BY role_id, server_id, game_id, server_name having count(1) > 1 ) b on a.role_id=b.role_id where a.server_id=b.server_id and a.game_id=b.game_id and a.server_id="' . $serverId . '" and a.game_id = ' . $gameId . ' order by a.role_id, a.server_id, a.game_id'; diff --git a/Application/Admin/Controller/DepositController.class.php b/Application/Admin/Controller/DepositController.class.php index 0be20b08f..11bf889df 100644 --- a/Application/Admin/Controller/DepositController.class.php +++ b/Application/Admin/Controller/DepositController.class.php @@ -67,6 +67,7 @@ class DepositController extends ThinkController { unset($_REQUEST['pay_way']); } + if(isset($_REQUEST['pay_status'])){ $map['pay_status']=$_REQUEST['pay_status']; unset($_REQUEST['pay_status']); diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 15e65f361..6c3984da0 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -98,7 +98,7 @@ class ExportController extends Controller } $xlsData = M('user_play_info', 'tab_') ->where($map) - ->order('id desc') + ->order('play_time desc') ->select(); break; case 2: @@ -196,52 +196,65 @@ class ExportController extends Controller } break; case 3: - if($_REQUEST['type']==2){ - $xlsCell = array( - array('id', L('Account_number_ID')), - array('register_type', L('Third_party_source'), "get_registertype", '*'), - array('account', "玩家账号"), - array('promote_account', L('Subordinate_channel')), - array('balance', "账户平台币"), - array('recharge_total', "累计充值"), - array('gold_coin', "金币"), - array('alipay', "绑定支付宝"), - array('small_count', "小号"), - array('vip_level', "VIP等级"), - array('register_time', L('Registration_time'), 'time_format', '*'), - array('login_time', "最后登录时间", 'time_format', '*'), - array('register_ip', L('Register_iP')), - array('lock_status', L('Account_status'), 'get_info_status', '*', '4'), - ); - $map['tab_user.register_type']= ['in','3,4,5,6']; - }else{ - $xlsCell = array( - array('id', L('Account_number_ID')), - array('account', "玩家账号"), - array('promote_account', L('Subordinate_channel')), - array('balance', "账户平台币"), - array('recharge_total', "累计充值"), - array('gold_coin', "金币"), - array('alipay', "绑定支付宝"), - array('small_count', "小号"), - array('vip_level', "VIP等级"), - array('register_type', "注册方式"), - array('register_time', L('Registration_time'), 'time_format', '*'), - array('login_time', "最后登录时间", 'time_format', '*'), - array('register_ip', L('Register_iP')), - array('lock_status', L('Account_status'), 'get_info_status', '*', '4'), - ); - $map['tab_user.register_type']=['in','1,2']; - $map['tab_user.register_type']=['in','0,1,2,7']; - - } - - if (isset($_REQUEST['user_id'])) { + if($_REQUEST['type']==2){ +// $xlsCell = array( +// array('id', L('Account_number_ID')), +// array('register_type', L('Third_party_source'), "get_registertype", '*'), +// array('account', "玩家账号"), +// array('promote_account', L('Subordinate_channel')), +// array('balance', "账户平台币"), +// array('recharge_total', "累计充值"), +// array('gold_coin', "金币"), +// array('alipay', "绑定支付宝"), +// array('small_count', "小号"), +// array('vip_level', "VIP等级"), +// array('register_time', L('Registration_time'), 'time_format', '*'), +// array('login_time', "最后登录时间", 'time_format', '*'), +// array('register_ip', L('Register_iP')), +// array('lock_status', L('Account_status'), 'get_info_status', '*', '4'), +// ); + $field = 'tab_user.id,tab_user.register_type,tab_user.account,tab_user.promote_account,tab_user.balance + ,IFNULL(sum(ss.pay_amount),0) AS recharge_total,tab_user.gold_coin,tab_user.alipay,tab_user.id as small_count, + tab_user.id as vip_level,register_time,tab_user.login_time,tab_user.register_ip,tab_user.lock_status, + tab_user.age_status,tab_user.register_way'; + $xlsCell = [L('Account_number_ID'),L('Third_party_source'),"玩家账号",L('Subordinate_channel'), "账户平台币" + , "累计充值", "金币", "绑定支付宝", "小号", "VIP等级", L('Registration_time'), "最后登录时间", L('Register_iP'), L('Account_status')]; + $map['tab_user.register_type']= ['in','3,4,5,6']; + }else{ +// $xlsCell = array( +// array('id', L('Account_number_ID')), +// array('account', "玩家账号"), +// array('promote_account', L('Subordinate_channel')), +// array('balance', "账户平台币"), +// array('recharge_total', "累计充值"), +// array('gold_coin', "金币"), +// array('alipay', "绑定支付宝"), +// array('small_count', "小号"), +// array('vip_level', "VIP等级"), +// array('register_type', "注册方式"), +// array('register_time', L('Registration_time'), 'time_format', '*'), +// array('login_time', "最后登录时间", 'time_format', '*'), +// array('register_ip', L('Register_iP')), +// array('lock_status', L('Account_status'), 'get_info_status', '*', '4'), +// ); + $field = 'tab_user.id,tab_user.account,tab_user.promote_account,tab_user.balance, + IFNULL(sum(ss.pay_amount),0) AS recharge_total,tab_user.gold_coin,tab_user.alipay + ,tab_user.id as small_count,tab_user.id as vip_level,tab_user.register_type,register_time,tab_user.login_time + ,tab_user.register_ip,tab_user.lock_status,tab_user.age_status,tab_user.register_way'; + $xlsCell = [L('Account_number_ID'),"玩家账号",L('Subordinate_channel'), "账户平台币" + , "累计充值", "金币", "绑定支付宝", "小号", "VIP等级", "注册方式", L('Registration_time'), + "最后登录时间", L('Register_iP'), L('Account_status')]; + $map['tab_user.register_type']=['in','1,2']; + $map['tab_user.register_type']=['in','0,1,2,7']; + + } + + if (isset($_REQUEST['user_id'])) { $map['tab_user.id'] = $_REQUEST['user_id']; unset($_REQUEST['user_id']); } - if (isset($_REQUEST['device_number'])) { + if (isset($_REQUEST['device_number'])) { $map['tab_user.device_number'] = $_REQUEST['device_number']; unset($_REQUEST['device_number']); } @@ -273,19 +286,21 @@ class ExportController extends Controller if (isset($_REQUEST['register_way'])) { if($_REQUEST['type']==1) { if ($_GET['register_way'] == 1) { - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type in (0,1)'; - $maps['tab_user.register_type'] = ['in',[0,1]]; + empty($hav) || $hav .= ' AND '; + $hav .= ' tab_user.register_type in (0,1)'; + $maps['tab_user.register_type'] = ['in',[0,1]]; } elseif($_GET['register_way'] == 7){ - empty($hav) || $hav .= ' AND '; - $hav .= ' tab_user.register_type in(7)'; - $maps['tab_user.register_type'] = 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; + empty($hav) || $hav .= ' AND '; + $hav .= ' tab_user.register_type in(2)'; + $maps['tab_user.register_type'] = 2; } } else { + + $map['register_way'] = I('register_way'); unset($_REQUEST['register_way']); } @@ -320,62 +335,141 @@ class ExportController extends Controller $map['puid'] = array('eq',0); $map['is_platform'] = 0; + + set_time_limit(0); +// $columns = [ +// '序号ID', '姓名', '电话', +// ]; + + $fileName = '导出.xlsx'; + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('GBK', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + + $accessNum = '100000';//从数据库获取总量,假设是十万 if($_REQUEST['promote_id'] && $_REQUEST['promote_id'] > -1){ - $xlsData = M('user', 'tab_')->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,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') - ->order($order) - ->having($havs) - ->select(); + $accessNum = M('user', 'tab_') + ->field('IFNULL(sum(ss.pay_amount),0) AS recharge_total,count(tab_user.id) as count') +// ->field($field) + ->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') + ->having($havs) + ->select(false); + $sql = "select count(t.count) as count from ({$accessNum}) as t "; + $accessNum = M('user', 'tab_')->query($sql); }else{ - $xlsData = M('user', 'tab_')->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,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') - ->order($order) - ->having($havs) - ->select(); + $accessNum = M('user', 'tab_') +// ->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,IFNULL(sum(ss.pay_amount),0) AS recharge_total') + ->field('IFNULL(sum(ss.pay_amount),0) AS recharge_total,count(tab_user.id) as count') + ->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') + ->having($havs) + ->select(false); + + $sql = "select count(t.count) as count from ({$accessNum}) as t "; + $accessNum = M('user', 'tab_')->query($sql); } - //数据 - - - if($xlsData) { - $ids = array_column($xlsData,'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($xlsData as $k => $v) { - - - $xlsData[$k]['vip_level'] = get_vip_level($v['recharge_total']); - if(empty($v['alipay'])){ - $xlsData[$k]['alipay'] = '--'; - } - $xlsData[$k]['register_type'] = $v['register_type'] == 2?'手机号':($v['register_type']==7?'邮箱':'账号'); + $accessNum = $accessNum[0]['count']; + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + $lastId = 0; + for($i = 1; $i <= $pages; $i++) { + + if($_REQUEST['promote_id'] && $_REQUEST['promote_id'] > -1){ + $xlsData = M('user', 'tab_') +// ->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,IFNULL(sum(ss.pay_amount),0) AS recharge_total') + ->field($field) + ->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) + ->limit(($i-1)*$perSize ,$perSize) + ->group('tab_user.id') + ->order($order) + ->having($havs) + ->select(); + }else{ + $xlsData = M('user', 'tab_') +// ->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,IFNULL(sum(ss.pay_amount),0) AS recharge_total') + ->field($field) + ->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) + ->limit(($i-1)*$perSize ,$perSize) + ->group('tab_user.id') + ->order($order) + ->having($havs) + ->select(); + } + //数据 + + + if($xlsData) { + $ids = array_column($xlsData,'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($xlsData as $k => $v) { + - $xlsData[$k]['small_count'] = 0; - foreach($small as $s) { - if($s['puid'] == $v['id']) { - $xlsData[$k]['small_count'] += $s['count'];break; + $xlsData[$k]['vip_level'] = get_vip_level($v['recharge_total']); + if(empty($v['alipay'])){ + $xlsData[$k]['alipay'] = '--'; } - } - foreach($small2 as $s) { - if($s['source_puid'] == $v['id']) { - $xlsData[$k]['small_count'] += $s['count'];break; + + $xlsData[$k]['register_time'] = date('Y-m-d H:i:s',$xlsData[$k]['register_time']); + $xlsData[$k]['login_time'] = date('Y-m-d H:i:s',$xlsData[$k]['login_time']); + $xlsData[$k]['lock_status'] = $xlsData[$k]['lock_status']==1?'正常':'锁定'; + + $xlsData[$k]['register_type'] = $v['register_type'] == 2?'手机号':($v['register_type']==7?'邮箱':'账号'); + + $xlsData[$k]['small_count'] = 0; + foreach($small as $s) { + if($s['puid'] == $v['id']) { + $xlsData[$k]['small_count'] += $s['count'];break; + } + } + foreach($small2 as $s) { + if($s['source_puid'] == $v['id']) { + $xlsData[$k]['small_count'] += $s['count'];break; + } } + unset($xlsData[$k]['age_status']); + unset($xlsData[$k]['register_way']); } } + foreach($xlsData as $value) { + mb_convert_variables('GBK', 'UTF-8', $value); + fputcsv($fp, $value); + $lastId = $value['id']; + } + unset($xlsData);//释放变量的内存 + //刷新输出缓冲到浏览器 + ob_flush(); + flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 } + fclose($fp); + exit(); break; case 4: @@ -1551,11 +1645,18 @@ class ExportController extends Controller $arraypage=$page; $row = 10; $user=M('User','tab_'); - $map['fgame_id']=array('gt',0);$map['puid'] = 0; + $map['fgame_id']=array('egt',0);$map['puid'] = 0; if(isset($_REQUEST['timestart'])&&isset($_REQUEST['timeend'])){ $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+24*60*60-1)); unset($_REQUEST['timestart']);unset($_REQUEST['timeend']); + } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { + $map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; + unset($_REQUEST['timestart']); + } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['register_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; + unset($_REQUEST['timeend']); } + if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){ $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); unset($_REQUEST['start']);unset($_REQUEST['end']); @@ -1574,13 +1675,18 @@ class ExportController extends Controller count(IF(register_time '.$mounth.',1,null)) as mounth') ->where($map) ->group('fgame_id') - ->order('count desc') + ->order('count desc,register_time') ->select(); + $count=count($data); foreach ($data as $key => $value) { static $i=0; $i++; $data[$key]['rand']=$i; + + if ($data[$key]['fgame_id'] == 0) { + $data[$key]['fgame_name'] = '其他注册'; + } } $total=A('Platform')->data_total($data); if($_REQUEST['data_order']!=''){ @@ -1872,11 +1978,18 @@ class ExportController extends Controller if(isset($_REQUEST['timestart'])&&isset($_REQUEST['timeend'])){ $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+24*60*60-1)); unset($_REQUEST['timestart']);unset($_REQUEST['timeend']); + } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { + $map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; + unset($_REQUEST['timestart']); + } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['register_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; + unset($_REQUEST['timeend']); } - if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){ - $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); - unset($_REQUEST['start']);unset($_REQUEST['end']); - } + +// if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){ +// $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); +// unset($_REQUEST['start']);unset($_REQUEST['end']); +// } $play_info_map = ''; if (isset($_REQUEST['game_name'])) { @@ -1896,28 +2009,51 @@ class ExportController extends Controller $map['tp1.chain'] = '/'; } - $data = M('promote', 'tab_')->alias('tp1')->field('tp1.account as promote_account,tp1.id as promote_id, date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(u.id) as count, + $data = M('promote', 'tab_')->alias('tp1')->field('tp1.account as promote_account,tp1.id, date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(u.id) as count, count(IF(register_time ' . $today . ',1,null)) as today, count(IF(register_time ' . $week . ',1,null)) as week, count(IF(register_time ' . $mounth . ',1,null)) as mounth') - ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%')", 'left') + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') ->join("tab_user as u on tp2.id = u.promote_id", 'left') ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) ->where($map) ->group('tp1.id') ->order('count desc, register_time') ->select(); + unset($map['tp1.id']); + unset($map['tp1.chain']); + $map['promote_id'] = 0; + //官方渠道数据添加 + $authorityData = M('user', 'tab_')->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(id) as count, + count(IF(register_time ' . $today . ',1,null)) as today, + count(IF(register_time ' . $week . ',1,null)) as week, + count(IF(register_time ' . $mounth . ',1,null)) as mounth') + ->where($map) + ->find(); + $authorityData['promote_account'] = "官方渠道"; + $authorityData['id'] = "1"; + if (isset($_REQUEST['promote_id'])||$authorityData['count']==0) { + $authorityData = []; + } else { + array_push($data, $authorityData); + } + +//数据排序 + $last_names = array_column($data,'count'); + array_multisort($last_names,SORT_DESC,$data); +// var_dump($data);die(); + $count=count($data); foreach ($data as $key => $value) { static $i=0; $i++; $data[$key]['rand']=$i; } - foreach ($data as $key => $value) { - if($data[$key]['promote_id']==0){ - unset($data[$key]); - } - } +// foreach ($data as $key => $value) { +// if($data[$key]['promote_id']==0){ +// unset($data[$key]); +// } +// } $total=A('Platform')->data_total($data); if($_REQUEST['data_order']!=''){ @@ -1933,24 +2069,27 @@ class ExportController extends Controller } $data=my_sort($data,$data_order_type,(int)$data_order); $size=$row;//每页显示的记录数 + $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 //用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度) - $data = array_slice($data, ($arraypage-1)*$size, $size); +// $data = array_slice($data, ($arraypage-1)*$size, $size); $xlsName = $_REQUEST['xlsname']?$_REQUEST['xlsname']:'推广员注册统计'; $xlsCell = array( - array('promote_id', "推广员账号"), + array('promote_account', "推广员账号"), array('count' , "累计注册"), array('rand' , "排行榜"), array('today' , "今日注册"), array('week' , "本周注册"), array('mounth' , "本月注册"), ); - foreach ($data as $key => $value) { - $data[$key]['promote_id'] = get_promote_account($data[$key]['promote_id']); - } +// foreach ($data as $key => $value) { +// $data[$key]['promote_id'] = get_promote_account($data[$key]['promote_id']); +// } +// var_dump($data);die(); + $length = count($data); $data[$length] = array( - 'promote_id'=>'汇总', + 'promote_account'=>'汇总', 'count'=>$total['sum_count'], 'rand'=>'---', 'today'=>$total['sum_today'], @@ -1958,6 +2097,7 @@ class ExportController extends Controller 'mounth'=>$total['sum_mounth'] ); $xlsData = $data; +// var_dump($xlsData);die(); $this->exportExcel($xlsName, $xlsCell, $xlsData); } @@ -1971,7 +2111,18 @@ class ExportController extends Controller if(isset($_REQUEST['timestart'])&&isset($_REQUEST['timeend'])){ $map['pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+24*60*60-1)); unset($_REQUEST['timestart']);unset($_REQUEST['timeend']); + } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { + $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; + $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " "; + unset($_REQUEST['timestart']); + } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; + $pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + unset($_REQUEST['timeend']); + } else { + $pay_time = " between 0 and " . time(); } + if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){ $map['pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); unset($_REQUEST['start']);unset($_REQUEST['end']); @@ -1981,82 +2132,82 @@ class ExportController extends Controller // unset($_REQUEST['promote_id']); // } $map1['pay_status'] = $map['pay_status']=1; - $map1['pay_way'] = $map['pay_way'] = array('gt', 0); +// $map1['pay_way'] = $map['pay_way'] = array('gt', 0); $today=total(1); $week=total(2); $mounth=total(3); - $map1['pay_way'] = $map['pay_way'] = array('gt',0); - $bindrecharge_data = M('bind_recharge','tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, sum(real_amount) as count, - sum(IF(create_time '.$today.',real_amount,0)) as today, - sum(IF(create_time '.$week.',real_amount,0)) as week, - sum(IF(create_time '.$mounth.',real_amount,0)) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - - $deposit_data = M('deposit','tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, sum(pay_amount) as count, - sum(IF(create_time '.$today.',pay_amount,0)) as today, - sum(IF(create_time '.$week.',pay_amount,0)) as week, - sum(IF(create_time '.$mounth.',pay_amount,0)) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - if(isset($_REQUEST['game_name'])){ - $map['game_name'] = $_REQUEST['game_name']; - if(isset($_REQUEST['server_id'])){ - $map['server_name'] = $_REQUEST['server_id']; - unset($_REQUEST['server_id']); - } - $data=$spend - ->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count, - sum(IF(pay_time '.$today.',pay_amount,0)) as today, - sum(IF(pay_time '.$week.',pay_amount,0)) as week, - sum(IF(pay_time '.$mounth.',pay_amount,0)) as mounth') - ->where($map) - ->group('promote_id') - ->select(false); - }else{ - $data=$spend - ->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count, - sum(IF(pay_time '.$today.',pay_amount,0)) as today, - sum(IF(pay_time '.$week.',pay_amount,0)) as week, - sum(IF(pay_time '.$mounth.',pay_amount,0)) as mounth') - ->where($map) - ->union(' ('.$bindrecharge_data.') ') - ->union(' ('.$deposit_data.') ') - ->group('promote_id') - ->select(false); - } - $promote_map = "tp1.`chain` = '/'"; + unset( $map['create_time']); + + //获取所有会长 + $promote_map = "`chain` = '/'"; if (isset($_REQUEST['promote_id'])) { - $promote_map = "tp1.`id` = {$_REQUEST['promote_id']}"; - unset($_REQUEST['promote_id']); + $promote_map = "`chain` = '%/{$_REQUEST['promote_id']}/%' OR id = {$_REQUEST['promote_id']}"; } - $data = $spend->field('t.pid as promote_id,t.promote_account,sum(a.count) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') - ->join("INNER JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') where $promote_map ) AS t ON promote_id = t.id") - ->where($condition)->table('(' . $data . ') as a')->group('t.pid')->order('count desc,a.ordertime')->select(); - $count=count($data); - foreach ($data as $key => $value) { - static $i=0; - $i++; - $data[$key]['rand']=$i; - if($data[$key]['promote_id']=='0'){ - unset($data[$key]); + + $promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->select(); + $pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->find()['acount']; + + // var_dump( $promote); + $data =array(); + for ($i=0; $i < count($promote); $i++) { + # code... + $proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select(); + $str = ''; + for($k=0; $kfield(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + $dbdata['promote_id'] = $promote[$i]['id']; + } else { + $dbdata = $spend + ->field(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + $dbdata['promote_id'] = $promote[$i]['id']; + } + $data[] = $dbdata; } - $total=A('Platform')->data_total($data); - if($_REQUEST['data_order']!=''){ - $data_order=reset(explode(',',$_REQUEST['data_order'])); - $data_order_type=end(explode(',',$_REQUEST['data_order'])); + $count = count($data); + foreach ($data as $key => $value) { + $value['count'] ?: 0; + $value['today'] ?: 0; + $value['week'] ?: 0; + $value['mounth'] ?: 0; + static $i = 0; + $i++; + $data[$key]['rand'] = $i; + $data[$key]['count'] = $value['count'] / 100; + $data[$key]['today'] = $value['today'] / 100; + $data[$key]['week'] = $value['week'] / 100; + $data[$key]['mounth'] = $value['mounth'] / 100; } - $data=my_sort($data,$data_order_type,(int)$data_order); - $size=$row;//每页显示的记录数 - $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 - //用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度) - $data = array_slice($data, ($arraypage-1)*$size, $size); + $total = $this->data_total($data); + $xlsName = $_REQUEST['xlsname']?$_REQUEST['xlsname']:'推广员充值统计'; $xlsCell = array( array('promote_id', "推广员账号"), @@ -2082,6 +2233,15 @@ class ExportController extends Controller $this->exportExcel($xlsName, $xlsCell, $xlsData); } + public function data_total($data) + { + $total['sum_count'] = array_sum(array_column($data, 'count')); + $total['sum_today'] = array_sum(array_column($data, 'today')); + $total['sum_week'] = array_sum(array_column($data, 'week')); + $total['sum_mounth'] = array_sum(array_column($data, 'mounth')); + return $total; + } + public function userretention_export($p = 0) { $request=$_REQUEST; @@ -4580,6 +4740,9 @@ if ($key == 'model'){ $map['id']=array('in',$zid); } $map['level'] = I('promote_level'); + if(I('oa_associated',-1) != -1) { + $map['oa_associated'] = I('oa_associated'); + } } diff --git a/Application/Admin/Controller/GameTypeController.class.php b/Application/Admin/Controller/GameTypeController.class.php index 8094c4cc2..8b6a0f7ab 100644 --- a/Application/Admin/Controller/GameTypeController.class.php +++ b/Application/Admin/Controller/GameTypeController.class.php @@ -25,8 +25,12 @@ class GameTypeController extends ThinkController { if(isset($request['status_show'])){ if($request['status_show']!='all'){ $extend['status_show'] = $request['status_show']; + } else { + unset($extend['status_show']); } unset($request['status_show']); + } else { + unset($extend['status_show']); } $this->m_title = '游戏类型'; @@ -40,6 +44,8 @@ class GameTypeController extends ThinkController { if(isset($request['status_show'])){ if($request['status_show']!='all'){ $extend['status'] = $request['status_show']; + } else { + unset($extend['status']); } unset($request['status_show']); } diff --git a/Application/Admin/Controller/GiftbagController.class.php b/Application/Admin/Controller/GiftbagController.class.php index 47842dc2f..10f854751 100644 --- a/Application/Admin/Controller/GiftbagController.class.php +++ b/Application/Admin/Controller/GiftbagController.class.php @@ -88,7 +88,7 @@ class GiftbagController extends ThinkController { $map['sdk_version'] = $_REQUEST['sdk_version']; $game_ids = M('game','tab_')->field('id')->where($map)->select(); $game_ids = array_column($game_ids,'id'); - $extend['sdk_version'] = ['in',$game_ids]; + $extend['game_id'] = ['in',$game_ids]; unset($_REQUEST['sdk_version']); } } diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 7d0a4cb7e..0d6029bf6 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -123,13 +123,14 @@ 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')).")"; + 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'])) { - $map['server_name'] = ['like', "{$_REQUEST['server_name']}%"]; + $game_play_map .= " and tab_user_play_info.server_name = '{$_REQUEST['server_name']}' "; } if (isset($_REQUEST['viplevel'])) { @@ -188,6 +189,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 +200,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') @@ -207,7 +212,9 @@ 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('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) @@ -222,6 +229,8 @@ class MemberController extends ThinkController 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) diff --git a/Application/Admin/Controller/PromoteCoinController.class.php b/Application/Admin/Controller/PromoteCoinController.class.php index 8bd39244f..a45cb9087 100644 --- a/Application/Admin/Controller/PromoteCoinController.class.php +++ b/Application/Admin/Controller/PromoteCoinController.class.php @@ -22,6 +22,7 @@ class PromoteCoinController extends ThinkController $extend['source_id'] = 0; $map = $extend; } else { + $extend['type'] = 1; $extend['promote_id'] = $_GET['promote_id']; $extend['promote_type'] = $_GET['promote_type']; diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index 56b360a3e..f7424d0c0 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -63,16 +63,90 @@ unset($_REQUEST['parent_id']); $map['ba_id']=$_REQUEST['admin_id']; } } + if (I('status') || I('status', -1) == 0) { + $map['status'] = I('status'); + } + + if (I('ver_status') || I('ver_status', -1) == 0) { + $map['ver_status'] = I('ver_status'); + } if (I("promote_level")) { $map['level'] = I("promote_level"); } - $this->m_title = '推广员列表'; $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Promote/lists/type/1','status'=>1])->find()); + if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} + + if(I('oa_associated',-1) != -1) { + $map['oa_associated'] = I('oa_associated'); + $oa_data = []; + for($i = 1; $i > 0; $i++) { + $arr['time'] = time(); + $arr['page'] = $i; + $arr['pageSize'] = 1000; + ksort($arr); + reset($arr); + $sign = md5(http_build_query($arr) . 'wmkjtx_kj213'); + $arr['sign'] = $sign; + $re_data = curl_post('http://oa.76ba.com/api/wanmeng/platformAccount',$arr); + $re_data = json_decode($re_data,true); + if($re_data['code'] == 1) { + $oa = $re_data['data']; + $oa_data = array_merge($oa_data,$oa); + + } else { + break; + } + } + + // $promote = D(self::model_name)->field('id,account')->where(['oa_associated' => 0])->order('id DESC')->select(); //只获取之前未关联 + $promote = D(self::model_name)->field('id,account')->order('id DESC')->select(); //全部重新获取 + $oa_data = array_column($oa_data, 'platform_account'); + foreach($promote as $k => $v) { + $v['account'] = trim($v['account']); + if(in_array($v['account'], $oa_data)) { + M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => 1]); + } + } + } + $list_data = D(self::model_name)->where($map)->order('id DESC')->page($p,$row)->select(); + $oa_data = []; + if(I('oa_associated',-1) == -1) { + foreach($list_data as $k => $v) + { + // $list_data[$k]['account'] = trim($v['account']); + // if($v['oa_associated'] != 1) { + $oa_data[] = trim($v['account']); + // } + } + if(!empty($oa_data)) + { + $arr['time'] = time(); + $arr['account'] = implode(",", $oa_data); + ksort($arr); + reset($arr); + $sign = md5(http_build_query($arr) . 'wmkjtx_kj213'); + $arr['sign'] = $sign; + $re_data = curl_post('http://oa.76ba.com/api/wanmeng/verifyBind',$arr); + $re_data = json_decode($re_data,true)['data']; + foreach($list_data as $k => $v) + { + if(array_key_exists($v['account'], $re_data)) + { + $list_data[$k]['oa_associated'] = $re_data[$v['account']]; + M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $re_data[$v['account']]]); + } + } + } + } + $count = D(self::model_name)->where($map)->count(); + $page = set_pagination($count,$row); + if($page) {$this->assign('_page', $page);} + $this->assign('list_data', $list_data); + $this->display(); - parent::order_lists(self::model_name,$p,$map); } private function siteApplyList($p){ diff --git a/Application/Admin/Controller/RechargeSumController.class.php b/Application/Admin/Controller/RechargeSumController.class.php index 3c6b68fa8..a39b95b79 100644 --- a/Application/Admin/Controller/RechargeSumController.class.php +++ b/Application/Admin/Controller/RechargeSumController.class.php @@ -105,7 +105,7 @@ class RechargeSumController extends ThinkController } $count = count($data); - + $export_data = $data; $page = set_pagination($count, $row); if ($page) { $this->assign('_page', $page); @@ -122,7 +122,7 @@ class RechargeSumController extends ThinkController //判断是否执行导出 if (I('export') == 1) { - $this->exportSum($data); + $this->exportSum($export_data); } $this->assign('meta_title', "充值汇总"); $this->assign('list_data', $data); diff --git a/Application/Admin/Controller/access_data_foldline.txt b/Application/Admin/Controller/access_data_foldline.txt index f2bc7fb38..6dc2f6e59 100644 --- a/Application/Admin/Controller/access_data_foldline.txt +++ b/Application/Admin/Controller/access_data_foldline.txt @@ -1 +1 @@ -{"news":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"sum":{"news":0,"active":0,"player":0,"money":0},"active":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"player":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}],"money":[{"time":"0:00","count":0},{"time":"1:00","count":0},{"time":"2:00","count":0},{"time":"3:00","count":0},{"time":"4:00","count":0},{"time":"5:00","count":0},{"time":"6:00","count":0},{"time":"7:00","count":0},{"time":"8:00","count":0},{"time":"9:00","count":0},{"time":"10:00","count":0},{"time":"11:00","count":0},{"time":"12:00","count":0},{"time":"13:00","count":0},{"time":"14:00","count":0},{"time":"15:00","count":0},{"time":"16:00","count":0},{"time":"17:00","count":0},{"time":"18:00","count":0},{"time":"19:00","count":0},{"time":"20:00","count":0},{"time":"21:00","count":0},{"time":"22:00","count":0},{"time":"23:00","count":0}]} \ No newline at end of file +{"news":[{"time":"0:00","count":6},{"time":"1:00","count":9},{"time":"2:00","count":7},{"time":"3:00","count":11},{"time":"4:00","count":16},{"time":"5:00","count":7},{"time":"6:00","count":9},{"time":"7:00","count":11},{"time":"8:00","count":14},{"time":"9:00","count":40},{"time":"10:00","count":58},{"time":"11:00","count":86},{"time":"12:00","count":41},{"time":"13:00","count":55},{"time":"14:00","count":194},{"time":"15:00","count":180},{"time":"16:00","count":121},{"time":"17:00","count":98},{"time":"18:00","count":120},{"time":"19:00","count":147},{"time":"20:00","count":146},{"time":"21:00","count":124},{"time":"22:00","count":93},{"time":"23:00","count":56}],"sum":{"news":1649,"active":8210,"player":1715,"money":226618},"active":[{"time":"0:00","count":967},{"time":"1:00","count":343},{"time":"2:00","count":176},{"time":"3:00","count":135},{"time":"4:00","count":118},{"time":"5:00","count":177},{"time":"6:00","count":465},{"time":"7:00","count":661},{"time":"8:00","count":622},{"time":"9:00","count":547},{"time":"10:00","count":480},{"time":"11:00","count":414},{"time":"12:00","count":326},{"time":"13:00","count":237},{"time":"14:00","count":354},{"time":"15:00","count":328},{"time":"16:00","count":215},{"time":"17:00","count":219},{"time":"18:00","count":256},{"time":"19:00","count":335},{"time":"20:00","count":274},{"time":"21:00","count":244},{"time":"22:00","count":197},{"time":"23:00","count":120}],"player":[{"time":"0:00","count":211},{"time":"1:00","count":84},{"time":"2:00","count":29},{"time":"3:00","count":25},{"time":"4:00","count":16},{"time":"5:00","count":24},{"time":"6:00","count":32},{"time":"7:00","count":56},{"time":"8:00","count":71},{"time":"9:00","count":66},{"time":"10:00","count":63},{"time":"11:00","count":69},{"time":"12:00","count":58},{"time":"13:00","count":62},{"time":"14:00","count":50},{"time":"15:00","count":99},{"time":"16:00","count":68},{"time":"17:00","count":61},{"time":"18:00","count":77},{"time":"19:00","count":157},{"time":"20:00","count":107},{"time":"21:00","count":101},{"time":"22:00","count":74},{"time":"23:00","count":55}],"money":[{"time":"0:00","count":"31554.00"},{"time":"1:00","count":"4117.00"},{"time":"2:00","count":"1839.00"},{"time":"3:00","count":"4513.00"},{"time":"4:00","count":"1008.00"},{"time":"5:00","count":"1981.00"},{"time":"6:00","count":"1270.00"},{"time":"7:00","count":"1906.00"},{"time":"8:00","count":"6683.00"},{"time":"9:00","count":"6119.00"},{"time":"10:00","count":"8974.00"},{"time":"11:00","count":"14147.00"},{"time":"12:00","count":"9775.00"},{"time":"13:00","count":"11908.00"},{"time":"14:00","count":"6781.00"},{"time":"15:00","count":"12626.00"},{"time":"16:00","count":"6742.00"},{"time":"17:00","count":"8303.00"},{"time":"18:00","count":"8804.00"},{"time":"19:00","count":"23476.00"},{"time":"20:00","count":"17464.00"},{"time":"21:00","count":"16899.00"},{"time":"22:00","count":"13143.00"},{"time":"23:00","count":"6586.00"}]} diff --git a/Application/Admin/Model/GameModel.class.php b/Application/Admin/Model/GameModel.class.php index 2b4c3d92a..a83665f45 100644 --- a/Application/Admin/Model/GameModel.class.php +++ b/Application/Admin/Model/GameModel.class.php @@ -38,8 +38,8 @@ class GameModel extends Model{ array('support_quota', '/^[0-9]*$/', '请输入正确的扶持额度', self::VALUE_VALIDATE, 'regex', self::MODEL_BOTH), array('game_score', '/^(\d(\.\d)?|10)$/', '游戏评分输入格式不正确', self::VALUE_VALIDATE, 'regex', self::MODEL_BOTH), array('recommend_level', '/^(\d(\.\d)?|10)$/', '推荐指数输入格式不正确', self::VALUE_VALIDATE, 'regex', self::MODEL_BOTH), - array('discount',[1,10],'代充折扣错误', self::MUST_VALIDATE, 'between', self::MODEL_BOTH), - array('bind_recharge_discount',[1,10],'绑币充值折扣错误',self::MUST_VALIDATE, 'between', self::MODEL_BOTH), + // array('discount',[1,10],'代充折扣错误', self::MUST_VALIDATE, 'between', self::MODEL_BOTH), + // array('bind_recharge_discount',[1,10],'绑币充值折扣错误',self::MUST_VALIDATE, 'between', self::MODEL_BOTH), array('dratio','/^(((\d|[1-9]\d)(\.\d{1,2})?)|100|100.0|100.00)$/','开发者分成比例错误',self::VALUE_VALIDATE, 'regex', self::MODEL_BOTH), array('support_ratio','/^100$|^(\d|[1-9]\d)$/','请输入正确的扶持比例',self::VALUE_VALIDATE, 'regex', self::MODEL_BOTH), diff --git a/Application/Admin/View/Deposit/lists.html b/Application/Admin/View/Deposit/lists.html index 86eb58abe..7fe8954f1 100644 --- a/Application/Admin/View/Deposit/lists.html +++ b/Application/Admin/View/Deposit/lists.html @@ -48,15 +48,16 @@ placeholder="订单号"/>
- -
-
+
@@ -328,12 +329,12 @@ $(document).ready(function () { function initSelect2WithSearch() { - $("#sel_order").select2({ - tags: true, - placeholder: '订单状态', - allowClear: false, //清空 - minimumResultsForSearch: Infinity, // 永久隐藏搜索框 - }); + // $("#sel_order").select2({ + // tags: true, + // placeholder: '订单状态', + // allowClear: false, //清空 + // minimumResultsForSearch: Infinity, // 永久隐藏搜索框 + // }); } diff --git a/Application/Admin/View/GameType/lists.html b/Application/Admin/View/GameType/lists.html index 09a1bb77b..311902c52 100644 --- a/Application/Admin/View/GameType/lists.html +++ b/Application/Admin/View/GameType/lists.html @@ -39,7 +39,7 @@
diff --git a/Application/Admin/View/Promote/lists.html b/Application/Admin/View/Promote/lists.html index 49a901191..13cadf0aa 100644 --- a/Application/Admin/View/Promote/lists.html +++ b/Application/Admin/View/Promote/lists.html @@ -126,7 +126,14 @@ -
+
+
+ +
+
+ +
@@ -172,7 +186,8 @@ 所属会长 商务专员 状态 - 身份状态> + 身份状态 + oa关联 可申请游戏 操作 @@ -225,6 +240,11 @@ 未认证 + + 已关联 + + 未关联 + 查看 编辑 diff --git a/Application/Admin/View/RechargeSum/summation.html b/Application/Admin/View/RechargeSum/summation.html index c86300fc8..9be1f5bfc 100644 --- a/Application/Admin/View/RechargeSum/summation.html +++ b/Application/Admin/View/RechargeSum/summation.html @@ -66,23 +66,23 @@ -->
- + + + +
- + + +
- +
diff --git a/Application/Admin/View/User/rolelist.html b/Application/Admin/View/User/rolelist.html index bad81eab1..e565a8218 100644 --- a/Application/Admin/View/User/rolelist.html +++ b/Application/Admin/View/User/rolelist.html @@ -279,23 +279,30 @@ $(".select_gallery").select2(); }) }); $("#promote_level").change(); - var game_server = "{:I('server_name')}"; + var game_id = "{:I('server_id')}"; $("#game_type").change(function(){ - $.ajax({ - url:"{:U('Ajax/getGmeServer')}", - type:"post", - data:{sdk_version:$("#game_type option:selected").val(), game_name:$("#game_name option:selected").val()}, - dataType:'json', - success:function(data){ - str = ""; - for (var i in data){ - str += "" + var game_name = $("#game_name option:selected").val(); + if(game_name != ''){ + $.ajax({ + url:"{:U('Ajax/getGmeServer')}", + type:"post", + data:{sdk_version:$("#game_type option:selected").val(), game_name:$("#game_name option:selected").val()}, + dataType:'json', + success:function(data){ + str = ""; + for (var i in data){ + str += "" + } + $("#server_id").empty(); + $("#server_id").append(str); + $("#server_id").select2(); } - $("#server_name").empty(); - $("#server_name").append(str); - $("#server_name").select2(); - } - }) + }) + }else{ + $("#server_id").html(""); + $("#server_id").append(""); + } + }); $("#game_name").change(function(){ diff --git a/Application/Base/Service/GameSourceService.class.php b/Application/Base/Service/GameSourceService.class.php index 007c8793f..eb9ade9aa 100644 --- a/Application/Base/Service/GameSourceService.class.php +++ b/Application/Base/Service/GameSourceService.class.php @@ -322,15 +322,14 @@ class GameSourceService { ]; } - public function uploadPackage($localFilePath, $distFilePath, $isDeleteLocal = false) + public function uploadPackage($localFilePath, $distFilePath, $isDeleteLocal = false, $isChunk = false) { if (get_tool_status('oss_storage') == 1) { - $ossService = new OssService(); - $result = $ossService->upload($localFilePath, $distFilePath); - if ($isDeleteLocal && file_exists($localFilePath)) { - @unlink($localFilePath); + if ($isChunk) { + return $this->uploadPackageChunk($localFilePath, $distFilePath, $isDeleteLocal); + } else { + return $this->uploadPackageOnce($localFilePath, $distFilePath, $isDeleteLocal); } - return $result; } else { // 不上传OSS等第三方服务器 return [ @@ -342,6 +341,40 @@ class GameSourceService { ]; } } + public function uploadPackageChunk($localFilePath, $distFilePath, $isDeleteLocal = false) + { + $client = new Client([ + 'base_uri' => C('UPLOAD_SERVER_URL'), + 'timeout' => 10.0, + ]); + $response = $client->post('/upload', [ + 'verify' => false, + 'form_params' => [ + 'file' => $gameId, + 'dist' => $distFilePath, + 'is_delete_local' => 0, + ] + ]); + $result = (string)$response->getBody(); + $result = json_decode($result, true); + if (!$result) { + return [ + 'status' => false, + 'message' => '请求打包失败', + ]; + } + return $result; + } + + public function uploadPackageOnce($localFilePath, $distFilePath, $isDeleteLocal = false) + { + $ossService = new OssService(); + $result = $ossService->upload($localFilePath, $distFilePath); + if ($isDeleteLocal && file_exists($localFilePath)) { + @unlink($localFilePath); + } + return $result; + } //生成游戏渠道plist文件 public function createPlist($params) diff --git a/Application/Home/Controller/CoinOrderController.class.php b/Application/Home/Controller/CoinOrderController.class.php index 16a086223..652bb5556 100644 --- a/Application/Home/Controller/CoinOrderController.class.php +++ b/Application/Home/Controller/CoinOrderController.class.php @@ -10,6 +10,7 @@ use QRcode; */ class CoinOrderController extends BaseController { + const LV = 2;//平台币充值手续费 public function page_show($model,$map,$p=1) { if (isset($_REQUEST['row'])) { @@ -89,7 +90,7 @@ class CoinOrderController extends BaseController //创建订单 public function order_add(){ - + $status = promoteCan(session('promote_auth.pid'), function($level) { if ($level == 1) { return true; @@ -104,7 +105,7 @@ class CoinOrderController extends BaseController $this->error('无权限操作'); } } - + $this->assign("LV",self::LV); if(IS_POST){ SafeFilter($_POST); $coin_num = I("coin_num"); @@ -122,7 +123,7 @@ class CoinOrderController extends BaseController $data['create_time'] = time(); $data['discount'] = "0"; if($pay_type==1){ // 在线转账 - $free = sprintf("%.2f",$coin_num*(0.2/100)); + $free = sprintf("%.2f",$coin_num*(self::LV/100)); $free = $free<'0.1' ? '0.1':$free; $data['pay_amount'] = bcadd($coin_num,$free,2); $data['order_status'] = 0; diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index a88cc4292..43de91eaa 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -48,6 +48,7 @@ class DownloadController extends BaseController { $cellNum = count($expCellName); $dataNum = count($expTableData); Vendor("PHPExcel.PHPExcel"); + $objPHPExcel = new \PHPExcel(); $cellName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ'); $objPHPExcel->getActiveSheet(0)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1');//合并单元格 @@ -57,10 +58,11 @@ class DownloadController extends BaseController { $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellName[$i] . '2', $expCellName[$i][1]); } for ($i = 0; $i < $dataNum; $i++) { - for ($j = 0; $j < $cellNum; $j++) { - $objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j] . ($i + 3), $expTableData[$i][$expCellName[$j][0]]); - } + for ($j = 0; $j < $cellNum; $j++) { + $objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j] . ($i + 3), $expTableData[$i][$expCellName[$j][0]]); + } } + ob_end_clean();//清除缓冲区,避免乱码 header('pragma:public'); header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $xlsTitle . '.xls"'); @@ -1161,9 +1163,6 @@ class DownloadController extends BaseController { * @author sunke */ public function recharge_data_export() { - if (empty(I('begtime')) || empty(I('endtime'))) { - $this->error('请选择起止时间'); - } $beginTime = strtotime(I('begtime') . ' 00:00:00'); $endtime = strtotime(I('endtime') . ' 23:59:59'); if (($endtime - $beginTime) > 31 * 24 * 3600) { @@ -1253,7 +1252,7 @@ class DownloadController extends BaseController { } public function userRecharge_data_export() { - $gameId = I('game_id', 0); + $gameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $isSelf = I('is_self', 0); $roleName = I('role_name', ''); @@ -1289,28 +1288,23 @@ class DownloadController extends BaseController { $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - $map2[] = [ - '_logic' => 'or', - 'id' => $queryPromote['id'], - 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] - ]; + $map2['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; $ids = M('promote', 'tab_')->where($map2)->getField('id', true); - if(empty($ids)) { - $ids = array(); - } - if(empty($levelPromote)) { - array_push($ids,PID); - } - // array_push($ids,$queryPromote['id']); - if (!empty($ids)) { - $map['promote_id'] = ['in',$ids]; - - }else { - $map['_string'] = '1<>1'; - } + $ids[] = $queryPromote['id']; + + $map = ['promote_id' => ['in', $ids]]; + $subMap = ['promote_id' => ['in', $ids]]; - if ($gameId != 0) { - $map['game_id'] = $gameId; + if ($gameId != 0 || $sdkVersion != 0) { + if ($gameId != 0) { + $gameMap['relation_game_id'] = $gameId; + } + if ($sdkVersion != 0) { + $gameMap['sdk_version'] = $sdkVersion; + } + $gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true); + $map['game_id'] = ['in', $gameId1]; + $subMap['game_id'] = ['in', $gameId1]; } if ($serverId != 0) { $map['server_id'] = $serverId; @@ -1371,7 +1365,7 @@ class DownloadController extends BaseController { public function achievement_data_export() { $time = I('time', date('Y-m-d')); $sdkVersion = I('sdk_version', 0); - $gameId = I('game_id', 0); + $gameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $parentId = I('parent_id', 0); $promoteId = I('promote_id', 0); @@ -1423,17 +1417,24 @@ class DownloadController extends BaseController { $map['parentsinfo'] = json_encode($parent,FALSE);; $map['currentDisplay'] = $currentDisplay; $map['ids'] = $ids; - if ($gameId > 0) { - $params['game_id'] = $gameId; + if ($gameId != 0 || $sdkVersion != 0) { + if ($gameId != 0) { + $gameMap['relation_game_id'] = $gameId; + } + if ($sdkVersion != 0) { + $gameMap['sdk_version'] = $sdkVersion; + } + $gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true); + $map['game_id'] = ['in', $gameId1]; } if ($serverId > 0) { - $params['server_id'] = $serverId; + $map['server_id'] = $serverId; } if ($sdkVersion > 0) { - $params['sdk_version'] = $sdkVersion; + $map['sdk_version'] = $sdkVersion; } if ($status > 0) { - $params['lock_status'] = $status; + $map['lock_status'] = $status; } list($beginTime, $endTime) = $this->getBetweenTime($time); $map['begin_time'] = $beginTime; @@ -1461,7 +1462,7 @@ class DownloadController extends BaseController { } //玩家角色 public function userRoles_data_export() { - $gameId = I('game_id', 0); + $gameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $isSelf = I('is_self', 0); $roleName = I('role_name', ''); @@ -1515,9 +1516,15 @@ class DownloadController extends BaseController { $map['_string'] = '1<>1'; } - - if ($gameId != 0) { - $map['game_id'] = $gameId; + if ($gameId != 0 || $sdkVersion != 0) { + if ($gameId != 0) { + $gameMap['relation_game_id'] = $gameId; + } + if ($sdkVersion != 0) { + $gameMap['sdk_version'] = $sdkVersion; + } + $gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true); + $map['game_id'] = ['in', $gameId1]; } if ($serverId != 0) { $map['serverId'] = $serverId; @@ -1630,7 +1637,7 @@ class DownloadController extends BaseController { array_push($ids,PID); } - array_push($ids,$queryPromote['id']); + // array_push($ids,$queryPromote['id']); if (!empty($ids)) { $map['tab_apply.promote_id'] = ['in',$ids]; @@ -1658,7 +1665,7 @@ class DownloadController extends BaseController { $map["apply_time"] = ["between",[strtotime($begtime1),strtotime($endtime1)]]; } if(!empty($begtime) && !empty($endtime)) { - $map["apply_time"] = ["between",[strtotime($begtime),strtotime($endtime)]]; + $map["apply_time"] = ["between",[strtotime($begtime),strtotime($endtime) + 3600 * 24 -1]]; } $serverField = ''; $serverJoin = ''; @@ -1857,12 +1864,12 @@ class DownloadController extends BaseController { $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); $params['begin_time'] = $begTime; - $params['end_time'] = $endTime -1; + $params['end_time'] = $endTime +3600 * 24 -1; if(!empty($map['apply_time'][1])) { $begTime = $map['apply_time'][1][0]; $endTime = $map['apply_time'][1][1]; $params['begin_time'] = $begTime; - $params['end_time'] = $endTime; + $params['end_time'] = $endTime + 3600 * 24 -1; unset($map['apply_time']); } if(!empty($map['tab_server.server_id'])) { @@ -1877,6 +1884,7 @@ class DownloadController extends BaseController { ->group('tab_apply.game_id') ->order('g.sort desc,g.id desc') ->select(); + $records = []; if (!empty($data)) { if (intval($endTime - $begTime) / (24 * 3600) <= 30) { @@ -1885,7 +1893,6 @@ class DownloadController extends BaseController { $gameIds[] = $list['game_id']; } $params['game_ids'] = $gameIds; - $userRepository = new UserRepository(); $spendRepository = new SpendRepository(); $roleNumList = $userRepository->getCreateRoleCountByGame($params);//创角数 @@ -2352,34 +2359,34 @@ class DownloadController extends BaseController { } public function withdrawDtlExcelInfo($id,$map) { - $xlsName = "提现记录"; - $xlsCell = array( - array('pay_order_number','充值订单号'), - array('game_name','游戏'), - array('sdk_version','平台'), - array('user_account','玩家账号'), - array('pay_amount','订单总额'), - array('cash_base','现金分成基数'), - array('selle_ratio','现金分成比例'), - array('platform_base','平台币分成基数'), - array('selle_ratio','平台币分成比例'), - array('bind_base','绑定币分成基数'), - array('selle_ratio','绑定币分成比例'), - array('pay_way_name','现金支付通道'), - array('income','收益'), - array('status','订单状态'), - array('pay_time','充值时间'), - ); - $spendModel = M('spend', 'tab_'); - $withdrawId = $map['withdraw_id']; - $withdraw = M('withdraw', 'tab_')->field('promote_id,status')->where(array('id' => $withdrawId))->find(); + $xlsName = "提现记录"; + $xlsCell = array( + '充值订单号', + '游戏', + '平台', + '玩家账号', + '订单总额', + '充值时间', + '收益', + '现金支付通道', + '现金分成基数', + '现金分成比例', + '平台币分成基数', + '平台币分成比例', + '绑定币分成基数', + '绑定币分成比例', + '订单状态', + ); + $spendModel = M('spend', 'tab_'); + $withdrawId = $map['withdraw_id']; + $withdraw = M('withdraw', 'tab_')->field('promote_id,status')->where(array('id' => $withdrawId))->find(); $data = $spendModel - ->field('id,pay_order_number,game_name,sdk_version,user_account,pay_amount,pay_way,selle_ratio,pay_time') + ->field('pay_order_number,game_name,sdk_version,user_account,pay_amount,pay_way,selle_ratio,pay_time') ->where($map) ->order('id desc') ->select(); - if (!empty($data)) { - foreach ($data as &$list) { + if (!empty($data)) { + foreach ($data as $key => &$list) { $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); switch ($list['pay_way']) { @@ -2397,27 +2404,55 @@ class DownloadController extends BaseController { }else { $list['cash_base'] = 0; } - + $list['cash_selle_ratio'] = $list['selle_ratio']; if($list['pay_way'] == 0) { - $list['platform_base'] = $list['pay_amount']; + $list['platform_base'] = $list['pay_amount']; }else { $list['platform_base'] = 0; } - - if($list['pay_way'] == -1) { - $list['bind_base'] = $list['pay_amount']; + $list['platform_selle_ratio'] = $list['selle_ratio']; + + if($list['pay_way'] == -1) { + $list['bind_base'] = $list['pay_amount']; }else { $list['bind_base'] = 0; } - + $list['bind_selle_ratio'] = $list['selle_ratio']; + $list['status'] = FinanceController::$withdrawStatus[$withdraw['status']]; - - - } - } - $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } + unset($list['pay_way']); + unset($list['selle_ratio']); + } + } + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('gb2312', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + $accessNum = '100000';//从数据库获取总量,假设是十万 + $accessNum = count($data)?:0 ; + + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + for($i = 1; $i <= $pages; $i++) { + foreach($data as $value) { + mb_convert_variables('GBK', 'UTF-8', $value); + fputcsv($fp, $value); + } + unset($data); + ob_flush(); + flush(); + } + fclose($fp); + $this->backSuccessExport($id); + + } public function withdrawRecordExcelInfo($id,$map) { $xlsName = "提现记录"; @@ -2801,21 +2836,33 @@ class DownloadController extends BaseController { $subMap = []; if(!empty($map['game_id'])) { $subMap['game_id'] = $map['game_id']; + $map['uc.game_id'] = $map['game_id']; + unset($map['game_id']); } if(!empty($map['server_id'])) { $subMap['server_id'] = $map['server_id']; + $map['ui.server_id'] = $map['server_id']; + unset($map['server_id']); + } + if(!empty($map['role_name'])) { + $map['ui.role_name'] = $map['role_name']; + unset($map['role_name']); + } + + if(!empty($map['user_account'])) { + $map['ui.user_account'] = $map['user_account']; + unset($map['user_account']); + } + if(!empty($map['promote_id'])) { + $map['uc.promote_id'] = $map['promote_id']; + unset($map['promote_id']); } $costBegin = $map['costbegin']; $costEnd = $map['costend']; unset($map['costbegin']); unset($map['costend']); - + $nowTime = strtotime(date('Y-m-d 00:00:00', time())); $subMap['create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; - $roleIdMap = $subMap; - $roleIds = M('user_play_data_count', 'tab_')->where($roleIdMap)->group('role_id')->getField('role_id', true); - if (count($roleIds) > 0) { - $map['role_id'] = ['in', $roleIds]; - } if ($costBegin != '' || $costEnd != '') { $having = ''; if ($costBegin != '' && $costEnd != '') { @@ -2830,40 +2877,24 @@ class DownloadController extends BaseController { ->group('game_id,server_id,role_id') ->having($having) ->buildSql(); - $map['_string'] = 'role_id in (' . $subQuery . ')'; - } - $spendMap['uc.create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; - $spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; - // $map['create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')) - 6*24*3600, strtotime(date('Y-m-d 23:59:59'))]]; - $sqlCost = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_cost) cost') - ->where($spendMap) - ->buildSql(); - - $sqlCount = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_count) count') - ->where($spendMap) - ->buildSql(); - - $spendMap['uc.create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; - - $sqlTodayCost = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_count) count') - ->where($spendMap) - ->buildSql(); + $map['_string'] = 'ui.role_id in (' . $subQuery . ')'; + } + $map['uc.create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; unset($map['begintime']); unset($map['endtime']); - $subQuery = M('user_play_info', 'tab_') - ->field("*,$sqlCost as recharge_cost,$sqlCount as recharge_count,$sqlTodayCost as recharge_cost_today") - ->where($map) - ->having('recharge_cost > 0') - ->order('play_time desc') - ->buildSql(); - $roles = M()->field(' * ') - ->table($subQuery) - ->alias('a') - ->order('play_time desc') - ->select(); + //$spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; + $fieldUC = "sum(uc.recharge_cost) recharge_cost,sum(uc.recharge_count) recharge_count,sum(if(uc.create_time = {$nowTime},uc.recharge_cost,0)) as recharge_cost_today"; + $fieldUI = "ui.user_account,ui.game_name,ui.role_name,ui.role_level,ui.server_name,ui.play_time,ui.play_ip,ui.promote_account,ui.sdk_version"; + $field = $fieldUC . ',' . $fieldUI; + $subQuery = M('user_play_data_count', 'tab_')->alias('uc') + ->field($field) + ->join('tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') + ->where($map) + ->group('uc.role_id,uc.server_id,uc.game_id') + ->buildSql(); + $roles = M()->alias('record') + ->table($subQuery) + ->select(); foreach ($roles as $role) { $records[] = [ 'user_account' => encryption($role['user_account']), @@ -2889,6 +2920,11 @@ class DownloadController extends BaseController { foreach ($records as $key1 => $value1) { $value1['user_account'] = $this->encryption($value1['user_account']); $value1['play_time'] = date('Y-m-d H:i:s',$value1['play_time']); + if($value1['sdk_version'] == 1) { + $value1['sdk_version'] = "Android"; + }else { + $value1['sdk_version'] = "ios"; + } $xlsData[] = $value1; } $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); @@ -2897,28 +2933,53 @@ class DownloadController extends BaseController { public function rechargeExcelInfo($id,$map) { $xlsName = "订单查询"; $xlsCell = array( - array('user_account','玩家账号'), - array('order_number','游戏订单'), - array('pay_amount','订单金额'), - array('pay_way','支付方式'), - array('game_name','游戏名称'), - array('server_name','区服'), - array('game_player_name','角色名'), - array('p_p_proinfo','部门长'), - array('p_proinfo','组长'), - array('proinfo','推广员'), - array('pay_time','付款时间'), + '玩家账号', + '游戏订单', + '订单金额', + '支付方式', + '游戏名称', + '区服', + '角色名', + '部门长', + '组长', + '推广员', + '付款时间', ); $model = M('spend','tab_'); - $data = $model - ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain') + $data1 = $model + ->field('tab_spend.id') ->join('tab_game on tab_spend.game_id = tab_game.id') ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') ->where($map) ->order('tab_spend.id desc') ->select(); - $xlsData = []; - foreach ($data as $key1 => $value1) { + + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('gb2312', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + $accessNum = count($data1)?:0 ; + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + + for($i = 1; $i <= $pages; $i++) { + $model = M('spend','tab_'); + $data = $model + ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain') + ->join('tab_game on tab_spend.game_id = tab_game.id') + ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') + ->where($map) + ->limit(($i-1)*$perSize ,$perSize) + ->order('tab_spend.id desc') + ->select(); + foreach ($data as $key1 => $value1) { $value1['pay_way'] = $this->payWay[$value1['pay_way']]; $value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']); $value1['p_p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; @@ -2947,9 +3008,27 @@ class DownloadController extends BaseController { } - $xlsData[] = $value1; - } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + $csvData["user_account"] = $value1["user_account"]; + $csvData["order_number"] = $value1["order_number"]; + $csvData["pay_amount"] = $value1["pay_amount"]; + $csvData["pay_way"] = $value1["pay_way"]; + $csvData["game_name"] = $value1["game_name"]; + $csvData["server_name"] = $value1["server_name"]; + $csvData["game_player_name"] = $value1["game_player_name"]; + $csvData["p_p_proinfo"] = $value1["p_p_proinfo"]; + $csvData["p_proinfo"] = $value1["p_proinfo"]; + $csvData["proinfo"] = $value1["proinfo"]; + $csvData["pay_time"] = $value1["pay_time"]; + mb_convert_variables('GBK', 'UTF-8', $csvData); + fputcsv($fp, $csvData); + $xlsData[] = $csvData; + } + unset($xlsData); + ob_flush(); + flush(); + } + fclose($fp); + $this->backSuccessExport($id); } public function backSuccessExport($id) { //导出成功后 diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 8b2338baa..bfa3f4c86 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1308,15 +1308,15 @@ class QueryController extends BaseController $allData['spend_user_num'] = $spendRepository->getPayUserCountByGame($params);//充值人数 $allData['spend_num'] = $spendRepository->getPayCountByGame($params);//充值次数 unset($params['pay_way']); - $allData['spend_all_amount'] = $spendRepository->getPayAmountByGameAndType($params);//充值总额 + $allData['spend_all_amount'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//充值总额 $params['pay_way'] = ['in', '1,2,3,4,5,6']; - $allData['spend_cash'] = $spendRepository->getPayAmountByGameAndType($params);//现金充值 + $allData['spend_cash'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//现金充值 $params['pay_way'] = 0; - $allData['spend_generic'] = $spendRepository->getPayAmountByGameAndType($params);//通用币充值 + $allData['spend_generic'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//通用币充值 $params['pay_way'] = -1; - $allData['spend_binding'] = $spendRepository->getPayAmountByGameAndType($params);//绑定币充值 - $allData['spend_discount'] = 0; - $allData['spend_voucher'] = 0; + $allData['spend_binding'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//绑定币充值 + $allData['spend_discount'] = '0.00'; + $allData['spend_voucher'] = '0.00'; } } @@ -1603,7 +1603,7 @@ class QueryController extends BaseController public function userRoles() { - $gameId = I('game_id', 0); + $relationGameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $isSelf = I('is_self', 0); $roleName = I('role_name', ''); @@ -1633,8 +1633,15 @@ class QueryController extends BaseController $map['_string'] = '1<>1'; } - if ($gameId != 0) { - $map['game_id'] = $gameId; + if ($relationGameId != 0 || $sdkVersion != 0) { + if ($relationGameId != 0) { + $gameMap['relation_game_id'] = $relationGameId; + } + if ($sdkVersion != 0) { + $gameMap['sdk_version'] = $sdkVersion; + } + $gameId = M('game', 'tab_')->where($gameMap)->getField('id', true); + $map['game_id'] = ['in', $gameId]; } if ($serverId != 0) { $map['server_id'] = $serverId; @@ -1645,9 +1652,6 @@ class QueryController extends BaseController if ($userAccount != '') { $map['user_account'] = ['like', '%' . $userAccount . '%']; } - if ($sdkVersion != 0) { - $map['sdk_version'] = $sdkVersion; - } if ($roleLevelBegin != 0 && $roleLevelEnd == 0) { $map['role_level'] = ['egt', $roleLevelBegin]; } elseif ($roleLevelEnd != 0 && $roleLevelBegin == 0) { @@ -1693,7 +1697,7 @@ class QueryController extends BaseController } - $games = $this->getGamesByPromote($promote); + $games = get_promote_serach_game(); $this->assign('games', $games); $this->assign('records', $records); @@ -1704,7 +1708,7 @@ class QueryController extends BaseController public function userRecharges() { - $gameId = I('game_id', 0); + $relationGameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $isSelf = I('is_self', 0); $roleName = I('role_name', ''); @@ -1724,6 +1728,7 @@ class QueryController extends BaseController $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); $endTime += 3600 * 24; + $nowTime = strtotime(date('Y-m-d 00:00:00', time())); $promote = $this->getLoginPromote(); $levelPromote = $this->getLevelPromote(); @@ -1733,48 +1738,40 @@ class QueryController extends BaseController $pagination = ''; $count = 0; if (intval($endTime - $begTime) / (24 * 3600) <= 31) { - $map = [ - '_logic' => 'or', - 'id' => $queryPromote['id'], - 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] - ]; + $map['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; $ids = M('promote', 'tab_')->where($map)->getField('id', true); + $ids[] = $queryPromote['id']; - $map = []; - if (count($ids) > 0) { - $map = ['promote_id' => ['in', $ids]]; - } else { - $map['_string'] = '1<>1'; - } + $map = ['uc.promote_id' => ['in', $ids]]; + $subMap = ['promote_id' => ['in', $ids]]; + + if ($relationGameId != 0 || $sdkVersion != 0) { + if ($relationGameId != 0) { + $gameMap['relation_game_id'] = $relationGameId; + } + if ($sdkVersion != 0) { + $gameMap['sdk_version'] = $sdkVersion; + } + $gameId = M('game', 'tab_')->where($gameMap)->getField('id', true); - $subMap = []; - if ($gameId != 0) { - $map['game_id'] = $gameId; - $subMap['game_id'] = $gameId; + $map['uc.game_id'] = ['in', $gameId]; + $subMap['game_id'] = ['in', $gameId]; } if ($serverId != 0) { - $map['server_id'] = $serverId; + $map['uc.server_id'] = $serverId; $subMap['server_id'] = $serverId; } if ($roleName != '') { - $map['role_name'] = ['like', '%' . $roleName . '%']; + $map['ui.role_name'] = ['like', $roleName . '%']; } if ($userAccount != '') { - $map['user_account'] = ['like', '%' . $userAccount . '%']; - } - if ($sdkVersion != 0) { - $map['sdk_version'] = $sdkVersion; + $map['ui.user_account'] = ['like', $userAccount . '%']; } if ($isSelf) { - $map['promote_id'] = $queryPromote['id']; + $map['uc.promote_id'] = $queryPromote['id']; } $subMap['create_time'] = ['between', [$begTime, $endTime - 1]]; - $roleIdMap = $subMap; - $roleIds = M('user_play_data_count', 'tab_')->where($roleIdMap)->group('role_id')->getField('role_id', true); - if (count($roleIds) > 0) { - $map['role_id'] = ['in', $roleIds]; - } if ($costBegin != '' || $costEnd != '') { $having = ''; if ($costBegin != '' && $costEnd != '') { @@ -1789,7 +1786,7 @@ class QueryController extends BaseController ->group('game_id,server_id,role_id') ->having($having) ->buildSql(); - $map['_string'] = 'role_id in(' . $subQuery . ')'; + $map['_string'] = 'ui.role_id in(' . $subQuery . ')'; } $orderBy = 'play_time desc'; @@ -1815,57 +1812,29 @@ class QueryController extends BaseController } } - $spendMap['uc.create_time'] = ['between', [$begTime, $endTime - 1]]; - $spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; - $sqlCost = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_cost) cost') - ->where($spendMap) - ->buildSql(); - $sqlCount = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_count) count') - ->where($spendMap) - ->buildSql(); - $spendMap['uc.create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; - $sqlTodayCost = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_count) count') - ->where($spendMap) - ->buildSql(); - $subQuery = M('user_play_info', 'tab_') - ->field("*,$sqlCost as recharge_cost,$sqlCount as recharge_count,$sqlTodayCost as recharge_cost_today") + $map['uc.create_time'] = ['between', [$begTime, $endTime - 1]]; + $fieldUC = "sum(uc.recharge_cost) recharge_cost,sum(uc.recharge_count) recharge_count,sum(if(uc.create_time = {$nowTime},uc.recharge_cost,0)) as recharge_cost_today"; + $fieldUI = "ui.user_account,ui.game_name,ui.role_name,ui.role_level,ui.server_name,ui.play_time,ui.play_ip,ui.promote_account,ui.sdk_version"; + $field = $fieldUC . ',' . $fieldUI; + $subQuery = M('user_play_data_count', 'tab_')->alias('uc') + ->field($field) + ->join('tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') ->where($map) - ->having('recharge_cost > 0') - ->order('play_time desc') + ->group('uc.role_id,uc.server_id,uc.game_id') ->buildSql(); - $query = M()->field('*') + $query = M()->alias('record') ->table($subQuery) - ->alias('a') ->order($orderBy); - list($roles, $pagination, $count) = $this->paginate($query); + list($records, $pagination, $count) = $this->paginate($query); - foreach ($roles as $role) { - $records[] = [ - 'user_account' => encryption($role['user_account']), - 'game_name' => $role['game_name'], - 'role_name' => $role['role_name'], - 'role_id' => $role['role_id'], - 'role_level' => $role['role_level'], - 'server_id' => $role['server_id'], - 'server_name' => $role['server_name'], - 'recharge_cost' => empty($role['recharge_cost']) ? 0 : $role['recharge_cost'], - 'recharge_count' => empty($role['recharge_count']) ? 0 : $role['recharge_count'], - 'recharge_cost_today' => empty($role['recharge_cost_today']) ? 0 : $role['recharge_cost_today'], - 'play_time' => $role['play_time'], - 'play_ip' => $role['play_ip'], - 'promote_id' => $role['promote_id'], - 'promote_account' => $role['promote_account'], - 'sdk_version' => $role['sdk_version'], - 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) - ]; + foreach ($records as &$list) { + $list['user_account'] = encryption($list['user_account']); + $list['unlogin_day'] = intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['play_time']))) / (24 * 3600)); } } - $games = $this->getGamesByPromote($promote); + $games = get_promote_serach_game(); $this->assign('games', $games); $this->assign('records', $records); @@ -1894,7 +1863,16 @@ class QueryController extends BaseController public function getGameServers() { $gameId = I('game_id', 0); - $servers = M('server', 'tab_')->field(['id', 'server_id', 'server_name'])->where(['game_id' => $gameId])->order('server_id asc')->select(); + $sdkVersion = I('sdk_version', 0); + $servers = []; + if (!empty($gameId)) { + $map['relation_game_id'] = $gameId; + if (in_array($sdkVersion, [1, 2])) { + $map['sdk_version'] = $sdkVersion; + } + $gameIds = M('game', 'tab_')->where($map)->getField('id', true); + $servers = M('server', 'tab_')->field(['id', 'server_id', 'server_name'])->where(['game_id' => ['in', $gameIds]])->order('server_id asc')->select(); + } $this->ajaxReturn([ 'status' => 1, 'msg' => '成功', @@ -1965,7 +1943,7 @@ class QueryController extends BaseController $defaultTime = date('Y-m-d', time()); } $sdkVersion = I('sdk_version', 0); - $gameId = I('game_id', 0); + $relationGameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $parentId = I('parent_id', 0); $promoteId = I('promote_id', 0); @@ -1990,7 +1968,7 @@ class QueryController extends BaseController $searchLevel = $parent['level'] + 1; $searchLevelName = $promoteService->getLevelName($searchLevel); - $games = $this->getGamesByPromote($parent); + $games = get_promote_serach_game(); $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $parent['id']])->select(); @@ -2024,15 +2002,19 @@ class QueryController extends BaseController 'isContainSubs' => true, 'basicPromotes' => $basicPromotes, ]; - if ($gameId > 0) { - $params['game_id'] = $gameId; + if ($relationGameId != 0 || $sdkVersion != 0) { + if ($relationGameId != 0) { + $gameMap['relation_game_id'] = $relationGameId; + } + if ($sdkVersion != 0) { + $gameMap['sdk_version'] = $sdkVersion; + } + $gameId = M('game', 'tab_')->where($gameMap)->getField('id', true); + $params['game_id'] = ['in', $gameId]; } if ($serverId > 0) { $params['server_id'] = $serverId; } - if ($sdkVersion > 0) { - $params['sdk_version'] = $sdkVersion; - } if ($status > 0) { $params['lock_status'] = $status; } diff --git a/Application/Home/View/default/Apply/index.html b/Application/Home/View/default/Apply/index.html index 2a243b9a2..d678b6753 100644 --- a/Application/Home/View/default/Apply/index.html +++ b/Application/Home/View/default/Apply/index.html @@ -4,7 +4,7 @@ - +