优化推广员充值

master
chenzhi 4 years ago
parent e896f5e649
commit 1f694ef47b

@ -627,60 +627,6 @@ class PlatformController extends ThinkController
$this->assign('list_data', $data); $this->assign('list_data', $data);
$this->assign("is_admin",is_administrator()); $this->assign("is_admin",is_administrator());
$this->display(); $this->display();
}
function promote_statistics1($p = 0)
{
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$arraypage = $page;
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
$user = M('User', 'tab_');
if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)];
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']);
}
$data = M("User u","tab_")
->field("count(u.id) as count,CASE when (fgame_name is null or fgame_name = '') THEN '无' ELSE left(fgame_name,char_length(fgame_name)-5) END fgame_name,promote_id,promote_account,admin_id,company_name,s.real_name")
->join("tab_promote promote ON u.promote_id = promote.id","left")
->join("tab_promote_company pc on promote.company_id = pc.id", 'left')
->join('sys_member s on promote.admin_id = s.uid', 'left')
->where($map)
->group('fgame_name,promote_id')
->page($page,$row)
->order("count desc")
->select();
$sql = M("User u","tab_")->field("count(u.id) as count,CASE when (fgame_name is null or fgame_name = '') THEN '无' ELSE left(fgame_name,char_length(fgame_name)-5) END fgame_name,promote_id")->where($map)->group('fgame_name,promote_id')->select(false);
$count = M()->table("(".$sql.") c")->count();
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('list_data', $data);
$this->display();
// dd($data);
} }
function promote_statistics($p = 0) function promote_statistics($p = 0)
{ {
@ -831,21 +777,6 @@ class PlatformController extends ThinkController
$tmdata[$tag]['id'] = $v['id']; $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); $data = array_values($tmdata);
unset($map['tp1.id']); unset($map['tp1.id']);
@ -957,18 +888,33 @@ class PlatformController extends ThinkController
}else{ }else{
$tmin = $tmonth[1][0]; $tmin = $tmonth[1][0];
} }
$isOffice = true;
if (isset($_REQUEST['promote_id'])) { if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id']) ) {
//$map['tp1.id'] = $_REQUEST['promote_id']; $isOffice = false;
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select(); $pwhere = "1";
if ($promoter_ids) { if(isset($_REQUEST['promote_id'])){
$pwhere .= " and (chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']})";
$map['tp1.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'))]; $map['tp2.id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
} }
} else { } else {
$map['tp1.chain'] = '/'; $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'])) { if (isset($_REQUEST['game_name'])) {
$map['s.game_name'] = ['like', "{$_REQUEST['game_name']}%"]; $map['s.game_name'] = ['like', "{$_REQUEST['game_name']}%"];
if (isset($_REQUEST['server_id'])) { if (isset($_REQUEST['server_id'])) {
@ -992,7 +938,7 @@ class PlatformController extends ThinkController
$data = M('promote', 'tab_')->alias('tp1') $data = M('promote', 'tab_')->alias('tp1')
->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name, ->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_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_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') ->join("tab_game as g on g.id = s.game_id", 'left')
@ -1001,30 +947,6 @@ class PlatformController extends ThinkController
->order('count desc') ->order('count desc')
->select(); ->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; $tmap = $map;
if(isset($map['pay_time'])){ if(isset($map['pay_time'])){
@ -1074,42 +996,43 @@ class PlatformController extends ThinkController
foreach($tmdata as $k => $v){ foreach($tmdata as $k => $v){
$data[] = $v; $data[] = $v;
} }
//dd($data); if ($isOffice) {
unset($map['tp1.id'], $map['tp2.id'], $map['tp2.admin_id']); //dd($data);
unset($map['tp1.chain']); unset($map['tp1.id'], $map['tp2.id'], $map['tp2.admin_id'],$map['tp1.company_id'],$map['tp1.company_belong'],$map['tp1.level']);
unset($tmap['tp1.id']); unset($map['tp1.chain']);
unset($tmap['tp1.chain'], $tmap['tp2.id']); unset($tmap['tp1.id']);
$map['s.promote_id'] = 0; unset($tmap['tp1.chain'], $tmap['tp2.id'],$tmap['tp1.company_id'],$tmap['tp1.company_belong'],$tmap['tp1.level']);
$tmap['s.promote_id'] = 0; $map['s.promote_id'] = 0;
$authorityData['count'] = 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))) { $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') //官方渠道数据添加
$authorityData = M('spend', 'tab_')->alias('s')
->field('floor(sum(pay_amount)*100) as count') ->field('floor(sum(pay_amount)*100) as count')
->where($map) ->where($map)
->find(); ->find();
$tauthorityData = M('spend', 'tab_')->alias('s') $tauthorityData = M('spend', 'tab_')->alias('s')
->field(' ->field('
floor(sum(IF(s.pay_time ' . $today . ',pay_amount,0))*100) as today, 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 ' . $week . ',pay_amount,0))*100) as week,
floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth')
->where($tmap) ->where($tmap)
->find(); ->find();
$authorityData['today'] = $tauthorityData['today']; $authorityData['today'] = $tauthorityData['today'];
$authorityData['week'] = $tauthorityData['week']; $authorityData['week'] = $tauthorityData['week'];
$authorityData['mounth'] = $tauthorityData['mounth']; $authorityData['mounth'] = $tauthorityData['mounth'];
} }
$authorityData['promote_account'] = "官方渠道"; $authorityData['promote_account'] = "江息网络";
$authorityData['id'] = "1"; $authorityData['id'] = "0";
if (isset($_REQUEST['promote_id'])||$authorityData['count']==0) { if (isset($_REQUEST['promote_id'])||$authorityData['count']==0) {
$authorityData = []; $authorityData = [];
} else { } else {
array_push($data, $authorityData); array_push($data, $authorityData);
}
} }
//数据排序 //数据排序
$last_names = array_column($data,'count'); $last_names = array_column($data,'count');
array_multisort($last_names,SORT_DESC,$data); array_multisort($last_names,SORT_DESC,$data);
@ -1183,147 +1106,12 @@ class PlatformController extends ThinkController
$this->meta_title = '渠道充值统计列表'; $this->meta_title = '渠道充值统计列表';
$this->assign('list_data', $data); $this->assign('list_data', $data);
$this->assign('admin_users', M('member')->field('uid,nickname')->select()); $this->assign('admin_users', M('member')->field('uid,nickname')->select());
$this->assign("companyList",D("PromoteCompany")->getList());
$this->assign("is_admin",is_administrator()); $this->assign("is_admin",is_administrator());
$this->display(); $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) public function data_total($data)
{ {

@ -52,7 +52,23 @@
<span class="add-on"><i class="icon-th"></i></span> <span class="add-on"><i class="icon-th"></i></span>
</div> </div>
</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"> <div class="input-list input-list-promote search_label_rehab">
<select id="promote_id" name="promote_id" class="select_gallery" style="width:150px;"> <select id="promote_id" name="promote_id" class="select_gallery" style="width:150px;">
<option value="">会长账号</option> <option value="">会长账号</option>

Loading…
Cancel
Save