Merge branch 'fix/company_20201111' of wmtx/platform into release

优化游戏汇总
master
陈志 4 years ago committed by Gogs
commit 08068c6349

@ -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'];
}
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;
}
}
// $substract = 0;
foreach($handle_data as $hk => $hv) {
$substract = 1;
}else {
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']);
// }
$week_line++;
$substract++;
} else {
break;
}
}
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'])-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 + 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:[];
}

@ -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);
$isOffice = true;
if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id'])) {
$isOffice = false;
$pwhere = "1";
if(isset($_REQUEST['promote_id'])){
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
$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);
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,17 +1023,32 @@ class PlatformController extends ThinkController
}else{
$tmin = $tmonth[1][0];
}
$isOffice = true;
if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id']) ) {
$isOffice = false;
$pwhere = "1";
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) {
$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']}%"];
@ -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,11 +1131,12 @@ class PlatformController extends ThinkController
foreach($tmdata as $k => $v){
$data[] = $v;
}
if ($isOffice) {
//dd($data);
unset($map['tp1.id'], $map['tp2.id'], $map['tp2.admin_id']);
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']);
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;
@ -844,14 +1160,14 @@ class PlatformController extends ThinkController
$authorityData['week'] = $tauthorityData['week'];
$authorityData['mounth'] = $tauthorityData['mounth'];
}
$authorityData['promote_account'] = "官方渠道";
$authorityData['id'] = "1";
$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; $k<count($proid); $k++){
# code...
$str .= ($proid[$k]['id'].",");
}
$str .= "{$promote[$i]['id']}";
$map['promote_id'] = array("in",$str);
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']);
}
}
$dbdata = $spend
->field('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)
{

@ -0,0 +1,188 @@
<extend name="Public/base"/>
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<style>
.select2-container--default .select2-selection--single {
color: #000;
resize: none;
border-width: 1px;
border-style: solid;
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
height:28px;border-radius:3px;font-size:12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height:35px;
line-height:28px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height:26px;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
height:26px;line-height:26px;font-size:12px;
}
.select2-results__option[aria-selected] {font-size:12px;}
th{
border-right: 1px solid #b6cad2;
}
.gotoinfo{
color: #056dae;cursor:pointer;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="tabchose" href="javascript:;">游戏汇总</a>
<a class="" href="{:U('Platform/game_statistics')}">游戏注册统计</a>
<a class="" href="{:U('Platform/gamepay_statistics')}">游戏充值统计</a>
<a class="" href="{:U('Platform/resway_statistics')}">注册方式统计</a>
<a class="" href="{:U('Platform/payway_statistics')}">充值方式统计</a>
</div>
<h3 class="page_title">游戏汇总</h3>
<p class="description_text">说明:统计各游戏每月注册及充值总额(注册数:以玩家在游戏内注册的数据为依据)</p>
</div>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
<div class="jssearch fl cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<!--游戏类型搜索END-->
<div class="input-list input-list-resway search_label_rehab">
<select id="year" name="year" class="select_gallery" style="width:150px;">
<volist name="YearList" id="vo">
<option value="{$vo.value}" <if condition="I('year') && $vo.value eq I('year')">selected</if> >{$vo.name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="relation_game_id" name="relation_game_id" class="select_gallery" >
<option value="">游戏名称</option>
<volist name=":getAllGame()" id="vo">
<option value="{$vo.game_id}" <if condition="$vo.game_id eq I('relation_game_id')">selected</if> >{$vo.game_name}</option>
</volist>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Platform/game_pool','model='.$model['name'].'&row='.I('row'),false)}">搜索</a>
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th rowspan="2">游戏名称</th>
<foreach name="th" item="vo">
<th colspan="2">{$vo}</th>
</foreach>
</tr>
<tr>
<foreach name="th" item="vo">
<th>注册数</th>
<th>充值流水</th>
</foreach>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<style>
.data-table thead th, .data-table tbody td{text-align:center}
.data-table tbody td{border-right:1px solid #DDDDDD;}
.d_list .drop-down ul {z-index:999;}
</style>
<empty name="list_data" >
<tr>
<td colspan="9" class="text-center">aOh! 暂时还没有内容!</td>
</tr>
<else />
<volist name="list_data" id="data">
<tr>
<td>{$data['relation_game_name']}</td>
<foreach name="data.list" item="item" key="date">
<foreach name="item" item="it" key="type">
<td <if condition="$it GT 0">class="gotoinfo"</if> data-id="{$data.relation_game_id}" data-type="{$type}" data-date="{$date}">{$it}</td>
</foreach>
</foreach>
</tr>
</volist>
</empty>
</tbody>
</table>
</div>
</div>
<div class="page">
<a class="sch-btn" href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
{$_page|default=''}
</div>
</block>
<block name="script">
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('Platform/game_statistics')}");
var registerUrl = "{:U('Platform/game_statistics')}";
var payamountrUrl = "{:U('Platform/gamepay_statistics')}";
$(function(){
//搜索功能
$("#search").click(function(){
var url = $(this).attr('url');
var query = $('.jssearch').find('input').serialize();
query += "&" + $('.jssearch').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){
if(event.keyCode===13){
$("#search").click();
}
});
$(".gotoinfo").on("click",function(){
var data = $(this).data();
var date = data.date.split('-');
var timestart =data.date+'-' + new Date(date[0],date[1],1).getDate();
var timeend = data.date+'-' +new Date(date[0],date[1],0).getDate();
var str = "&timestart="+timestart+"&timeend="+timeend+"&game_id="+data.id;
if(data.type == "register"){
window.location.href = registerUrl+str;
}else{
window.location.href = payamountrUrl+str;
}
})
})
</script>
</block>

@ -30,6 +30,7 @@
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="" href="{:U('Platform/game_pool')}">游戏汇总</a>
<a class="tabchose" href="javascript:;">游戏注册统计</a>
<a class="" href="{:U('Platform/gamepay_statistics')}">游戏充值统计</a>
<a class="" href="{:U('Platform/resway_statistics')}">注册方式统计</a>

@ -29,6 +29,7 @@
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="" href="{:U('Platform/game_pool')}">游戏汇总</a>
<a class="" href="{:U('Platform/game_statistics')}">游戏注册统计</a>
<a class="tabchose" href="">游戏充值统计</a>
<a class="" href="{:U('Platform/resway_statistics')}">注册方式统计</a>

@ -29,6 +29,7 @@
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="" href="{:U('Platform/game_pool')}">游戏汇总</a>
<a class="" href="{:U('Platform/game_statistics')}">游戏注册统计</a>
<a class="" href="{:U('Platform/gamepay_statistics')}">游戏充值统计</a>
<a class="" href="{:U('Platform/resway_statistics')}">注册方式统计</a>

@ -0,0 +1,197 @@
<extend name="Public/base"/>
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<style>
.select2-container--default .select2-selection--single {
color: #000;
resize: none;
border-width: 1px;
border-style: solid;
border-color: #a7b5bc #ced9df #ced9df #a7b5bc;
box-shadow: 0px 3px 3px #F7F8F9 inset;height:35px;
height:28px;border-radius:3px;font-size:12px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height:35px;
line-height:28px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height:26px;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
height:26px;line-height:26px;font-size:12px;
}
.select2-results__option[aria-selected] {font-size:12px;}
th{
border-right: 1px solid #b6cad2;
}
.gotoinfo{
color: #056dae;cursor:pointer;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="tabchose" href="javascript:;">推广员汇总</a>
<a class="" href="{:U('Platform/promote_statistics')}">推广员注册统计</a>
<a class="" href="{:U('Platform/promotepay_statistics')}">推广员充值统计</a>
</div>
<h3 class="page_title">推广员汇总</h3>
<p class="description_text">说明:统计各工会每月注册及充值总额(注册数:以玩家最后归属的公会为准,非去重)</p>
</div>
<div class="cf top_nav_list">
<!-- 高级搜索 -->
<div class="jssearch fl cf search_list">
<div class="input-list search-title-box">
<label>搜索:</label>
</div>
<!--游戏类型搜索END-->
<div class="input-list input-list-resway search_label_rehab">
<select id="year" name="year" class="select_gallery" style="width:150px;">
<volist name="YearList" id="vo">
<option value="{$vo.value}" <if condition="I('year') && $vo.value eq I('year')">selected</if> >{$vo.name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<label>团体归属</label>
<select id="company_belong" name="company_belong" class="select_gallery" style="width:150px;">
<volist name=":getCompanyBlong()" id="vo">
<option value="{$vo.id}" <if condition="isset($_GET['company_belong']) && $key eq I('company_belong')">selected</if> >{$vo.name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="company_id" name="company_id" class="select_gallery" >
<option value="">请选择公司</option>
<volist name="companyList" id="vo">
<option value="{$vo.id}" <if condition="$vo.id eq I('company_id')">selected</if> >{$vo.company_name}</option>
</volist>
</select>
</div>
<input type="hidden" name="" value="" class="sortBy">
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('Platform/promote_pool','model='.$model['name'].'&row='.I('row'),false)}">搜索</a>
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data_list">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th rowspan="2">推广公司</th>
<th rowspan="2">内外团归属</th>
<foreach name="th" item="vo">
<th colspan="2">{$vo}</th>
</foreach>
</tr>
<tr>
<foreach name="th" item="vo">
<th>注册数</th>
<th>充值流水</th>
</foreach>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<style>
.data-table thead th, .data-table tbody td{text-align:center}
.data-table tbody td{border-right:1px solid #DDDDDD;}
.d_list .drop-down ul {z-index:999;}
</style>
<empty name="list_data" >
<tr>
<td colspan="9" class="text-center">aOh! 暂时还没有内容!</td>
</tr>
<else />
<volist name="list_data" id="data">
<tr>
<td>{$data['company_name']}</td>
<td>{$data['company_belong']}</td>
<foreach name="data.list" item="item" key="date">
<foreach name="item" item="it" key="type">
<td <if condition="$it GT 0">class="gotoinfo"</if> data-id="{$data.id}" data-type="{$type}" data-date="{$date}" style="">{$it}</td>
</foreach>
</foreach>
</tr>
</volist>
</empty>
</tbody>
</table>
</div>
</div>
<div class="page">
<a class="sch-btn" href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
{$_page|default=''}
</div>
</block>
<block name="script">
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js" ></script>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('Platform/promote_statistics')}");
var registerUrl = "{:U('Platform/promote_statistics')}";
var payamountrUrl = "{:U('Platform/promotepay_statistics')}";
$(function(){
//搜索功能
$("#search").click(function(){
var url = $(this).attr('url');
var query = $('.jssearch').find('input').serialize();
query += "&" + $('.jssearch').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
//回车自动提交
$('.jssearch').find('input').keyup(function(event){
if(event.keyCode===13){
$("#search").click();
}
});
$(".gotoinfo").on("click",function(){
var data = $(this).data();
var date = data.date.split('-');
var timestart =data.date+'-' + new Date(date[0],date[1],1).getDate();
var timeend = data.date+'-' +new Date(date[0],date[1],0).getDate();
var str = "&timestart="+timestart+"&timeend="+timeend+"&company_id="+data.id;
if(data.type == "register"){
window.location.href = registerUrl+str;
}else{
window.location.href = payamountrUrl+str;
}
})
})
</script>
</block>

@ -29,6 +29,7 @@
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="" href="{:U('Platform/promote_pool')}">推广员汇总</a>
<a class="tabchose" href="javascript:;">推广员注册统计</a>
<a class="" href="{:U('Platform/promotepay_statistics')}">推广员充值统计</a>
</div>
@ -53,7 +54,22 @@
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<label>会长账号</label>
<select id="company_id" name="company_id" class="select_gallery" >
<option value="">请选择公司</option>
<volist name="companyList" id="vo">
<option value="{$vo.id}" <if condition="$vo.id eq I('company_id')">selected</if> >{$vo.company_name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="company_belong" name="company_belong" class="select_gallery" >
<option value="">请选择内外团</option>
<volist name=":getCompanyBlong()" id="vo">
<option value="{$vo.id}" <if condition="isset($_GET['company_belong']) && $vo.company_belong eq I('company_belong')">selected</if> >下游{$vo.name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" style="width:150px;">
<option value="">会长账号</option>
<volist name=":get_all_toppromote()" id="vo">
@ -90,6 +106,7 @@
<option value="">区服名称</option>
</select>
</div>
<br>
<input type="hidden" name="" value="" class="sortBy">
<div class="input-list">
@ -192,9 +209,7 @@
</div>
<div class="page">
<if condition="$role_export_check eq true ">
<a class="sch-btn" href="{:U('Export/promote_statistics',
array('timestart'=>$_GET['timestart'],'timeend'=>$_GET['timeend'],'admin_id'=>$_GET['admin_id'],'promote_id'=>$_GET['promote_id'],p=>$_GET['p'],'game_name'=>$_GET['game_name'], 'game_type'=>$_GET['game_type'],'server_id'=>$_GET['server_id'],'xlsname'=>'统计_推广员统计_推广员注册统计',)
,false)}">导出</a>
<a class="sch-btn" href="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}" target="_blank">导出</a>
</if>
{$_page|default=''}
</div>

@ -30,6 +30,7 @@
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="" href="{:U('Platform/promote_pool')}">推广员汇总</a>
<a class="" href="{:U('Platform/promote_statistics')}">推广员注册统计</a>
<a class="tabchose" href="javascript:;">推广员充值统计</a>
</div>
@ -51,6 +52,22 @@
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="company_id" name="company_id" class="select_gallery" >
<option value="">请选择公司</option>
<volist name="companyList" id="vo">
<option value="{$vo.id}" <if condition="$vo.id eq I('company_id')">selected</if> >{$vo.company_name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-game search_label_rehab">
<select id="company_belong" name="company_belong" class="select_gallery" >
<option value="">请选择内外团</option>
<volist name=":getCompanyBlong()" id="vo">
<option value="{$vo.id}" <if condition="isset($_GET['company_belong']) && $vo.company_belong eq I('company_belong')">selected</if> >下游{$vo.name}</option>
</volist>
</select>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" style="width:150px;">

@ -30,6 +30,7 @@
<div class="cf main-place top_nav_list navtab_list">
<div class="fr">
<a class="" href="{:U('Platform/game_pool')}">游戏汇总</a>
<a class="" href="{:U('Platform/game_statistics')}">游戏注册统计</a>
<a class="" href="{:U('Platform/gamepay_statistics')}">游戏充值统计</a>
<a class="tabchose" href="javascript:;">注册方式统计</a>

Loading…
Cancel
Save