diff --git a/Application/Admin/Controller/CompanyStatementPoolController.class.php b/Application/Admin/Controller/CompanyStatementPoolController.class.php index abe12876d..f27fe45e2 100644 --- a/Application/Admin/Controller/CompanyStatementPoolController.class.php +++ b/Application/Admin/Controller/CompanyStatementPoolController.class.php @@ -367,7 +367,9 @@ class CompanyStatementPoolController extends ThinkController if($is_export){ $v['statement_money'] = "=ROUND("; } - + $handle_data = $this->changeDataStruct($v['statement_info'],$is_export,$week_line); + + $v['statement_info'] = $handle_data; $row = 0; foreach($v['statement_info'] as $ke=>&$va){ $va['row'] = count($va['game_list']); @@ -408,9 +410,7 @@ class CompanyStatementPoolController extends ThinkController } } - $handle_data = $this->changeDataStruct($v['statement_info'],$is_export,$week_line); - $v['statement_info'] = $handle_data; $v['row'] = $row; @@ -427,6 +427,7 @@ class CompanyStatementPoolController extends ThinkController } } + if($is_export){ $count["platform_amount"] = "=ROUND(SUM(K2:K".$line."),2)"; $count["week_money"] = "=ROUND(SUM(R2:R".$line."),2)"; @@ -443,7 +444,7 @@ class CompanyStatementPoolController extends ThinkController $game_list = []; $old_line = $week_line; - +// dump($statement_info); //使用时间与会长账号作为键值分离数据 foreach($statement_info as $sk=>$sv){ @@ -455,6 +456,7 @@ class CompanyStatementPoolController extends ThinkController } } +// dump($game_list); $game_data = []; $handle_data = []; @@ -495,6 +497,7 @@ class CompanyStatementPoolController extends ThinkController } } +// dump($handle_data); $substract = 1; // dump($game_list); // dump($handle_data); @@ -503,6 +506,7 @@ class CompanyStatementPoolController extends ThinkController foreach($handle_data as $hk => $hv) { if($hk > 0) { + for (;;) { if (!$handle_data[$hk-$substract]['time']) { @@ -512,64 +516,92 @@ class CompanyStatementPoolController extends ThinkController } } +// if ( +//// $hv['account'] == 'zj9587' || +// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') { +// dump($handle_data); +// } // dump($hv); - if ($hv['time'] == $handle_data[$hk-$substract]['time']&&!$is_export) { + if ($hv['time'] == $handle_data[$hk-$substract]['time']) { $handle_data[$hk-$substract]['time_row'] += $handle_data[$hk]['time_row']; - if ($is_export) { - - $week_line++; - $handle_data[$hk-$substract]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line}),2)"; - $old_line++; - } else { - $handle_data[$hk-$substract]['week_amount'] += $handle_data[$hk]['week_amount']; - } + $handle_data[$hk-$substract]['week_amount'] += $handle_data[$hk]['week_amount']; unset($handle_data[$hk]['time']); unset($handle_data[$hk]['time_row']); unset($handle_data[$hk]['week_amount']); - } else { - if ($is_export) { -// dump($old_line); - if (count($hv['game_list'])>1) { - $week_line += count($hv['game_list'])-1; - } - - $handle_data[$hk]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line}),2)"; - $old_line++; - $week_line++; - } } $substract = 1; - }else { - if ($is_export) { - - if (count($hv['game_list'])>1) { - $week_line += count($hv['game_list'])-1; - } + } - $handle_data[$hk]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line}),2)"; + } +// $substract = 0; + foreach($handle_data as $hk => $hv) { + $substract = 1; + if ($is_export) { +// if ( +//// $hv['account'] == 'zj9587' || +// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') { +// dump($handle_data); +// } + for (;;) { + if (!$handle_data[$hk+$substract]['time']&&$handle_data[$hk+$substract]['account']) { +// if ( +// $hv['account'] == 'zj9587' || +// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') { +// dump($handle_data[$hk]['time']); +// } - if (count($hv['game_list'])>1) { - $old_line += count($hv['game_list'])-1; + $week_line++; + $substract++; } else { - $old_line++; + break; } - if(count($hv['game_list'])>1) { + } - $week_line = $old_line + 1; - } else { - $week_line = $old_line; - } + if (count($hv['game_list'])>1) { + $week_line += count($hv['game_list'])-1; + } +// if ( +//// $hv['account'] == 'zj9587' || +// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') { +// dump($handle_data); +// } + $handle_data[$hk]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line}),2)"; + + + if (count($hv['game_list'])>1) { + + $old_line += count($hv['game_list']); +// if ( +//// $hv['account'] == 'zj9587' || +// $hv['account'] == 'DCX1012' || $hv['account'] == 'chuangshi168') { +// dump($old_line); +// } + } else { + $old_line++; + } + + if(count($hv['game_list'])>1) { + $week_line = $old_line ; + } else { + $week_line = $old_line; } +// if ( +//// $hv['account'] == 'zj9587' || +// $hv['account'] == 'DCX1012' || $hv['account'] == 'chuangshi168') { +// dump($week_line); +// } + } } + // dump($handle_data); return $handle_data?$handle_data:[]; } diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 741948b58..599f86fee 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -11,6 +11,308 @@ use Org\UcenterSDK\Ucservice; */ class PlatformController extends ThinkController { + //游戏汇总 + public function game_pool(){ + if(!array_key_exists("year",$_REQUEST)){ + $this->redirect(ACTION_NAME, array('year' => date('Y',time())) ); + } + $isExport = false; + if(isset($_REQUEST['export']) && $_REQUEST['export'] == 1){ + $isExport = true; + } + $page = intval($_REQUEST['p']); + $page = $page ? $page : 1; //默认显示第一页数据 + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + $year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date("Y",time()); + $yearMap = [strtotime("$year-1-1 00:00:00"),strtotime("$year-12-31 23:59:59")]; + + $gameMap = "1"; + if(isset($_REQUEST['relation_game_id'])){ + $gameId = $_REQUEST['relation_game_id']; + $gameMap .= " AND relation_game_id = '{$gameId}' "; + } + + $gameDb = M("Game","tab_"); + $data = $gameDb + ->field("group_concat(id) game_id,relation_game_id,relation_game_name") + ->where($gameMap) + ->group("relation_game_id"); + if($isExport){ + $data = $data->select(); + //生成头 + $fp = $this->setPromotePoolTitle($year,"game"); + }else{ + $data = $data->page($page,$row)->select(); + $countTable = $gameDb->where($gameMap)->group("relation_game_id")->select(false); + $count = M()->table("(".$countTable.") s")->count(); + } + + //获取游戏累计注册 + $sendData = []; + foreach($data as $k=>$v){ + + $list = self::setYearList($year); + $this->getGameRegisterCount($list,$v['game_id'],$yearMap); + $this->getGamePayamountCount($list,$v['game_id'],$yearMap); + $v["list"] = $list; + $sendData[] = $v; + if($isExport){ + unset($v['game_id'],$v['relation_game_id']); + $fp = $this->setCsvData($fp,$v); + } + } + if($isExport){ + //刷新输出缓冲到浏览器 + fclose($fp); + exit(); + } + + $th = array_keys(self::setYearList($year)); + $this->assign('th', $th); + $this->assign('list_data', $sendData); + $this->assign("companyList",D("PromoteCompany")->getList()); + $this->getYearList(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->display(); + + } + + //获取游戏注册量 + protected function getGameRegisterCount(&$list,$gameids,$yearMap) + { + $map = [ + "fgame_id"=>["in",$gameids], + "register_time"=>["between",$yearMap] + ]; + $Register = M("User","tab_")->field("count(id) count,FROM_UNIXTIME(`register_time`, '%Y-%m') regtime")->where($map)->group("regtime")->select(); + if(empty($Register)) return ; + foreach ($Register as $v) { + $list[$v['regtime']]['register'] = $v['count']; + } + } + //获取游戏注册量 + protected function getGamePayamountCount(&$list,$gameids,$yearMap) + { + $map = [ + "game_id"=>["in",$gameids], + "pay_time"=>["between",$yearMap], + "pay_status"=>1 + ]; + $Payamount = M("Spend","tab_")->field("sum(pay_amount) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select(); + if(empty($Payamount)) return ; + foreach ($Payamount as $v) { + $list[$v['paytime']]['payamount'] = $v['pay_amount']; + } + } + + + //推广员汇总 + public function promote_pool() + { + if(!array_key_exists("year",$_REQUEST) || !array_key_exists("company_belong",$_REQUEST)){ + $this->redirect(ACTION_NAME, array('year' => date('Y',time()),"company_belong"=>0)); + } + $isExport = false; + if(isset($_REQUEST['export']) && $_REQUEST['export'] == 1){ + $isExport = true; + } + + $page = intval($_REQUEST['p']); + $page = $page ? $page : 1; //默认显示第一页数据 + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + $companyBelong = isset($_REQUEST['company_belong']) ? $_REQUEST['company_belong'] : 0; + $year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date("Y",time()); + $yearMap = [strtotime("$year-1-1 00:00:00"),strtotime("$year-12-31 23:59:59")]; + //获取公司数据 tab_promote_company + $companyMap = "1"; + if($companyBelong > -1){ + $companyMap .= " AND company_belong = {$companyBelong}"; + } + if(isset($_REQUEST['company_id'])){ + $companyId = $_REQUEST['company_id']; + $companyMap .= " AND id = '{$companyId}' "; + } + + $promoteCompany = M("promote_company","tab_"); + $data = $promoteCompany + ->field("id,company_name,company_belong") + ->where($companyMap); + if($isExport){ + $data = $data->select(); + //生成头 + $fp = $this->setPromotePoolTitle($year); + }else{ + $data = $data->page($page,$row)->select(); + $count = $promoteCompany->where($companyMap)->count(); + } + + //获取公司累计注册 + $sendData = []; + foreach($data as $k=>$v){ + $promote = getPromoteByLevel(0,$v['id']); + if(empty($promote)){ + $promoteIds = ''; + }else{ + $promoteIds = implode(",",array_column($promote,"id")); + } + $list = self::setYearList($year); + $this->getRegisterCount($list,$promoteIds,$yearMap); + $this->getPayamountCount($list,$promoteIds,$yearMap); + $v["list"] = $list; + $v["company_belong"] = getCompanyBlongOther($v["company_belong"]); + $sendData[] = $v; + if($isExport) $fp = $this->setCsvData($fp,$v); + } + + if($isExport){ + //刷新输出缓冲到浏览器 + fclose($fp); + exit(); + } + + $th = array_keys(self::setYearList($year)); + $this->assign('th', $th); + $this->assign('list_data', $sendData); + $this->assign("companyList",D("PromoteCompany")->getList()); + $this->getYearList(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->display(); + // var_dump($sendData); + + + } + //获取公司每个月的注册及充值金额 + private static function setYearList($year) + { + $range = []; + $i = 1; + do { + if($i < 10){ + $month = "0".$i; + }else{ + $month = $i; + } + $range[$year."-".$month] = ["register"=>0,"payamount"=>0]; + $i++; + } while ($i<13); + return $range; + } + //获取注册量 + protected function getRegisterCount(&$list,$promoteIds,$yearMap) + { + $map = [ + "promote_id"=>["in",$promoteIds], + "register_time"=>["between",$yearMap] + ]; + $Register = M("User","tab_")->field("count(id) count,FROM_UNIXTIME(`register_time`, '%Y-%m') regtime")->where($map)->group("regtime")->select(); + if(empty($Register)) return ; + foreach ($Register as $v) { + $list[$v['regtime']]['register'] = $v['count']; + } + } + //获取支付流水 + protected function getPayamountCount(&$list,$promoteIds,$yearMap) + { + $map = [ + "promote_id"=>["in",$promoteIds], + "pay_time"=>["between",$yearMap], + "pay_status"=>1 + ]; + $Payamount = M("Spend","tab_")->field("sum(pay_amount) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select(); + if(empty($Payamount)) return ; + foreach ($Payamount as $v) { + $list[$v['paytime']]['payamount'] = $v['pay_amount']; + } + } + //获取所有年分 + protected function getYearList() + { + $star = 2019; + $end = date("Y",time()); + $list = []; + for ($i=$star; $i <= $end; $i++) { + $temp = array( + "value"=>$i, + "name"=>"{$i}年" + ); + $list[] = $temp ; + } + $this->assign('YearList', $list); + } + //获取导出头 + private static function setPromotePoolTitle($year,$type="promote") + { + if($type =="promote"){ + $range = ["推广公司","内外团归属"]; + $csvFileName = '推广公司汇总.csv'; + }else{ + $range = ["游戏名称"]; + $csvFileName = '游戏汇总.csv'; + } + + $i = 1; + do { + if($i < 10){ + $month = "0".$i; + }else{ + $month = $i; + } + $range[] = $year."年".$month."月注册数"; + $range[] = $year."年".$month."月充值流水"; + $i++; + } while ($i<13); + + //设置好告诉浏览器要下载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', $range); + fputcsv($fp, $range);//将数据格式化为CSV格式并写入到output流中 + + return $fp; + } + //获取导出头 + private static function setCsvData($fp,$data) + { + unset($data['id']); + $sendData = []; + foreach ($data as $key => $value) { + if($key != "list"){ + $sendData[] = $value; + } + } + foreach ($data['list'] as $key => $value) { + $sendData[] = $value['register']; + $sendData[] = $value['payamount']; + } + mb_convert_variables('GBK', 'UTF-8', $sendData); + fputcsv($fp, $sendData);//将数据格式化为CSV格式并写入到output流中 + ob_flush(); + flush(); + return $fp; + } + + function game_statistics($p = 0) { $page = intval($p); @@ -436,8 +738,6 @@ class PlatformController extends ThinkController $this->assign("is_admin",is_administrator()); $this->display(); } - - function promote_statistics($p = 0) { $page = intval($p); @@ -487,13 +787,32 @@ class PlatformController extends ThinkController $today = total(1); $week = total(2); $mounth = total(3); - - if (isset($_REQUEST['promote_id'])) { - $promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select(); + $isOffice = true; + if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id'])) { + $isOffice = false; + $pwhere = "1"; + if(isset($_REQUEST['promote_id'])){ + $pwhere .= " and (chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']})"; + } + if(isset($_REQUEST['company_id'])){ + $pwhere .= " and company_id={$_REQUEST['company_id']}"; + } + $promoter_ids = D("Promote")->where($pwhere)->field('id')->select(); + if ($promoter_ids) { $map['u.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))]; + }else{ + $map['u.promote_id'] = -999; } } + $promoteTableMap = 'tab_promote promote ON u.promote_id = promote.id'; + if (isset($_REQUEST['company_belong'])){ + $isOffice = false; + $promoteTableMap .= " and promote.company_belong = {$_REQUEST['company_belong']}"; + } + if($isOffice){ + $promoteTableMap = "left join ".$promoteTableMap; + } // 如果是市场专员那么只能看自己的会长信息 @@ -508,15 +827,15 @@ class PlatformController extends ThinkController $data = M("User u","tab_") ->field(" count(u.id) as count, - tab_game.relation_game_id, - tab_game.relation_game_name, + IFNULL(tab_game.relation_game_id,0) relation_game_id, + IFNULL(tab_game.relation_game_name,'其他渠道') relation_game_name, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='', u.promote_id, substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") - ->join("tab_promote promote ON u.promote_id = promote.id","left") - ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) - ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) - ->join('tab_game on u.fgame_id = tab_game.id') + ->join($promoteTableMap) + ->join($play_map ? "left join tab_user_play as up on up.user_id = u.id " . $play_map : false) + ->join($play_info_map ? "left join tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) + ->join('tab_game on u.fgame_id = tab_game.id',"left") ->where($map) ->group('tab_game.relation_game_id, id') ->order('count desc, register_time') @@ -541,9 +860,10 @@ class PlatformController extends ThinkController ->field("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, - tab_game.relation_game_id,tab_game.relation_game_name, + IFNULL(tab_game.relation_game_id,0) relation_game_id, + IFNULL(tab_game.relation_game_name,'其他渠道') relation_game_name, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',u.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") - ->join("tab_promote promote ON u.promote_id = promote.id","left") + ->join($promoteTableMap) ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) ->join('tab_game on u.fgame_id = tab_game.id') @@ -574,21 +894,6 @@ class PlatformController extends ThinkController $tmdata[$tag]['id'] = $v['id']; } } - // if(count($tmdata) >0){ - // //获取推广员 - // $idstr = implode(",",array_keys($tmdata)); - // $promoteRes = M("Promote","tab_")->field("id,account promote_account")->where("id in ({$idstr})")->select(); - // foreach($promoteRes as $k=>$v){ - // $tmdata[$v['id']]['promote_account'] = $v['promote_account']; - // } - // } - // $data = []; - // foreach($tmdata as $k => $v){ - // if($v['id'] == 0){ - // $v['promote_account'] = C('OFFICIEL_CHANNEL'); - // } - // $data[] = $v; - // } $data = array_values($tmdata); unset($map['tp1.id']); @@ -625,7 +930,12 @@ class PlatformController extends ThinkController $this->checkListOrCountAuthRestMap($map,[]); $data = my_sort($data, $data_order_type, (int)$data_order); - $size = $row;//每页显示的记录数 + if(isset($_REQUEST["export"])){ + $size = 999999; + }else{ + $size = $row;//每页显示的记录数 + } + $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 //用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度) $data = array_slice($data, ($arraypage - 1) * $size, $size); @@ -645,10 +955,24 @@ class PlatformController extends ThinkController $item['promote_account'] = $companys[$item['id']]['promote_account']; } } + if(isset($_REQUEST["export"])){ + data2csv($data,'推广员注册统计',array( + 'company_name' => '公司', + "promote_account"=>"推广员账号", + 'admin_username' => '市场专员', + 'relation_game_name' => '游戏', + "count"=>"累计注册", + "rand"=>"排行榜", + "today"=>"今日注册", + "week"=>"本周注册", + "mounth"=>"本月注册", + )); + } $this->meta_title = '渠道注册统计列表'; $this->assign("is_admin",is_administrator()); $this->assign('list_data', $data); $this->assign('admin_users', M('member')->field('uid,nickname')->select()); + $this->assign("companyList",D("PromoteCompany")->getList()); $this->assign('total', $total); $this->display(); } @@ -699,18 +1023,33 @@ class PlatformController extends ThinkController }else{ $tmin = $tmonth[1][0]; } - - if (isset($_REQUEST['promote_id'])) { - //$map['tp1.id'] = $_REQUEST['promote_id']; - $promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select(); - if ($promoter_ids) { + $isOffice = true; + if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id']) ) { + $isOffice = false; + $pwhere = "1"; + if(isset($_REQUEST['promote_id'])){ + $pwhere .= " and (chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']})"; $map['tp1.id'] = $_REQUEST['promote_id']; + } + if(isset($_REQUEST['company_id'])){ + $map['tp1.company_id'] = $_REQUEST['company_id']; + + $pwhere .= " and company_id={$_REQUEST['company_id']}"; + } + $promoter_ids = D("Promote")->where($pwhere)->field('id')->select(); + if ($promoter_ids) { $map['tp2.id'] = ['in', implode(',', array_column($promoter_ids, 'id'))]; } } else { $map['tp1.chain'] = '/'; } - + $map['tp1.level'] = '1'; + + if (isset($_REQUEST['company_belong'])){ + $isOffice = false; + $map['tp1.company_belong'] = $_REQUEST['company_belong']; + } + if (isset($_REQUEST['game_name'])) { $map['s.game_name'] = ['like', "{$_REQUEST['game_name']}%"]; if (isset($_REQUEST['server_id'])) { @@ -734,7 +1073,7 @@ class PlatformController extends ThinkController $data = M('promote', 'tab_')->alias('tp1') ->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name, - floor(sum(pay_amount)*100) as count') + floor(sum(pay_amount)*100) as count') ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') ->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left') ->join("tab_game as g on g.id = s.game_id", 'left') @@ -743,30 +1082,6 @@ class PlatformController extends ThinkController ->order('count desc') ->select(); - // if (isset($_REQUEST['server_id'])||isset($_REQUEST['game_name'])||isset($_REQUEST['promote_id'])||isset($_REQUEST['admin_id'])||isset($_REQUEST['admin_user_id'])) { - // $data = M('promote', 'tab_')->alias('tp1') - // ->field('tp1.account as promote_account,tp1.id, - // floor(sum(pay_amount)*100) as count') - // ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') - // ->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left') - // ->join("tab_game as g on g.id = s.game_id", 'left') - // ->where($map) - // ->group('tp1.id') - // ->order('count desc') - // ->select(); - // } else { - // $statisticsMap['time'] =$map['pay_time']; - // setPowerPromoteIds($statisticsMap, 'tab_promote.id'); - // $data = M('promote_statistics', 'tab_') - // ->field("promote_account,promote_id as id,sum(count) count") - // ->join('tab_promote on tab_promote.id = tab_promote_statistics.promote_id', 'left') - // ->where($statisticsMap) - // ->group("promote_id") - // ->select(); - // } - - -// var_dump($data);die(); //今日/本周/本月不变 $tmap = $map; if(isset($map['pay_time'])){ @@ -816,42 +1131,43 @@ class PlatformController extends ThinkController foreach($tmdata as $k => $v){ $data[] = $v; } - //dd($data); - unset($map['tp1.id'], $map['tp2.id'], $map['tp2.admin_id']); - unset($map['tp1.chain']); - unset($tmap['tp1.id']); - unset($tmap['tp1.chain'], $tmap['tp2.id']); - $map['s.promote_id'] = 0; - $tmap['s.promote_id'] = 0; - $authorityData['count'] = 0; - - //如果有官方渠道权限 - $user_auth_promote_ids = session('user_auth_promote_ids'); - if ($user_auth_promote_ids == 'all' || in_array('0', explode(",", $user_auth_promote_ids))) { - //官方渠道数据添加 - $authorityData = M('spend', 'tab_')->alias('s') + if ($isOffice) { + //dd($data); + unset($map['tp1.id'], $map['tp2.id'], $map['tp2.admin_id'],$map['tp1.company_id'],$map['tp1.company_belong'],$map['tp1.level']); + unset($map['tp1.chain']); + unset($tmap['tp1.id']); + unset($tmap['tp1.chain'], $tmap['tp2.id'],$tmap['tp1.company_id'],$tmap['tp1.company_belong'],$tmap['tp1.level']); + $map['s.promote_id'] = 0; + $tmap['s.promote_id'] = 0; + $authorityData['count'] = 0; + + //如果有官方渠道权限 + $user_auth_promote_ids = session('user_auth_promote_ids'); + if ($user_auth_promote_ids == 'all' || in_array('0', explode(",", $user_auth_promote_ids))) { + //官方渠道数据添加 + $authorityData = M('spend', 'tab_')->alias('s') ->field('floor(sum(pay_amount)*100) as count') ->where($map) ->find(); - $tauthorityData = M('spend', 'tab_')->alias('s') - ->field(' - floor(sum(IF(s.pay_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(s.pay_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($tmap) - ->find(); - $authorityData['today'] = $tauthorityData['today']; - $authorityData['week'] = $tauthorityData['week']; - $authorityData['mounth'] = $tauthorityData['mounth']; - } - $authorityData['promote_account'] = "官方渠道"; - $authorityData['id'] = "1"; - if (isset($_REQUEST['promote_id'])||$authorityData['count']==0) { - $authorityData = []; - } else { - array_push($data, $authorityData); + $tauthorityData = M('spend', 'tab_')->alias('s') + ->field(' + floor(sum(IF(s.pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(s.pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($tmap) + ->find(); + $authorityData['today'] = $tauthorityData['today']; + $authorityData['week'] = $tauthorityData['week']; + $authorityData['mounth'] = $tauthorityData['mounth']; + } + $authorityData['promote_account'] = C('OFFICIEL_CHANNEL'); + $authorityData['id'] = "0"; + 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); @@ -925,147 +1241,12 @@ class PlatformController extends ThinkController $this->meta_title = '渠道充值统计列表'; $this->assign('list_data', $data); $this->assign('admin_users', M('member')->field('uid,nickname')->select()); + $this->assign("companyList",D("PromoteCompany")->getList()); $this->assign("is_admin",is_administrator()); $this->display(); } - public function promotepay_statistics1($p = 0) - { - $page = intval($p); - $page = $page ? $page : 1; //默认显示第一页数据 - $arraypage = $page; - if (isset($_REQUEST['row'])) { - $row = $_REQUEST['row']; - } else { - $row = 10; - } - $map1['promote_id'] = $map['promote_id'] = array('egt', 0); - $spend = M('Spend', 'tab_'); - if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; - unset($_REQUEST['timestart']); - unset($_REQUEST['timeend']); - } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { - $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; - unset($_REQUEST['timestart']); - } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; - unset($_REQUEST['timeend']); - } else { - $map['pay_time'] = ['between', array(0, time())]; - // $pay_time = " between 0 and " . time(); - } - $map1['pay_status'] = $map['pay_status'] = 1; - $today = total(1); - $week = total(2); - $mounth = total(3); - unset( $map['create_time']); - //获取所有会长 - $promote_map = "`chain` = '/'"; - if (isset($_REQUEST['promote_id'])) { - $promote_map = "`chain` = '%/{$_REQUEST['promote_id']}/%' OR id = {$_REQUEST['promote_id']}"; - } - //为数据权限添加 - setPowerPromoteIds($map); - $promote_map2 = array(); - setPowerPromoteIds($promote_map2, 'id'); - $promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->where($promote_map2)->select(); - $pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->where($promote_map2)->find()['acount']; - - // var_dump( $promote); - $tweek = total(2,false); - $tmonth = total(3,false); - //获取最小 - $tmin = 0; - if($tweek[1][0] < $tmonth[1][0]){ - $tmin = $tweek[1][0]; - }else{ - $tmin = $tmonth[1][0]; - } - - - $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') - ->where($map) - ->find(); - $tmap = $map; - if(isset($map['pay_time'])){ - $tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])]; - } - $tdbdata = $spend - ->field(' - 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($tmap) - ->find(); - $dbdata['today']= $tdbdata['today']; - $dbdata['week']= $tdbdata['week']; - $dbdata['mounth']= $tdbdata['mounth']; - - $dbdata['promote_account'] = $promote[$i]['account']; - $dbdata['promote_id'] = $promote[$i]['id']; - - $data[] = $dbdata; - } - $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; - } - - $total = $this->data_total($data); - $this->assign('total', $total); - if ($_REQUEST['data_order'] != '') { - $data_order = reset(explode(',', $_REQUEST['data_order'])); - $data_order_type = end(explode(',', $_REQUEST['data_order'])); - $this->assign('userarpu_order', $data_order); - $this->assign('userarpu_order_type', $data_order_type); - } - - $page = set_pagination($pcount, $row); - if ($page) { - $this->assign('_page', $page); - } - - $data = my_sort($data, $data_order_type, (int)$data_order); - - $size = $row;//每页显示的记录数 - $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 - $this->meta_title = '渠道充值统计列表'; - $this->assign('list_data', $data); - $this->assign("is_admin",is_administrator()); - $this->display(); - - } public function data_total($data) { diff --git a/Application/Admin/View/Platform/game_pool.html b/Application/Admin/View/Platform/game_pool.html new file mode 100644 index 000000000..b2fac6fe1 --- /dev/null +++ b/Application/Admin/View/Platform/game_pool.html @@ -0,0 +1,188 @@ + + + + + + + + + + +
+ + +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ 搜索 +
+
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
游戏名称{$vo}
注册数充值流水
aOh! 暂时还没有内容!
{$data['relation_game_name']}class="gotoinfo" data-id="{$data.relation_game_id}" data-type="{$type}" data-date="{$date}">{$it}
+
+
+
+ 导出 + {$_page|default=''} +
+
+ + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/Platform/game_statistics.html b/Application/Admin/View/Platform/game_statistics.html index b5707b940..63e0c59a5 100644 --- a/Application/Admin/View/Platform/game_statistics.html +++ b/Application/Admin/View/Platform/game_statistics.html @@ -30,6 +30,7 @@