diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 66fddd9cb..599f86fee 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -11,6 +11,110 @@ 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)){ @@ -152,9 +256,16 @@ class PlatformController extends ThinkController $this->assign('YearList', $list); } //获取导出头 - private static function setPromotePoolTitle($year) + private static function setPromotePoolTitle($year,$type="promote") { - $range = ["推广公司","内外团归属"]; + if($type =="promote"){ + $range = ["推广公司","内外团归属"]; + $csvFileName = '推广公司汇总.csv'; + }else{ + $range = ["游戏名称"]; + $csvFileName = '游戏汇总.csv'; + } + $i = 1; do { if($i < 10){ @@ -166,8 +277,7 @@ class PlatformController extends ThinkController $range[] = $year."年".$month."月充值流水"; $i++; } while ($i<13); - - $csvFileName = '推广公司汇总.csv'; + //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); diff --git a/Application/Admin/View/Platform/game_pool.html b/Application/Admin/View/Platform/game_pool.html new file mode 100644 index 000000000..3da4ca948 --- /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 @@