|
|
|
@ -8,6 +8,7 @@ use User\Api\UserApi as UserApi;
|
|
|
|
|
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
|
|
|
|
*/
|
|
|
|
|
class StatisticsController extends ThinkController {
|
|
|
|
|
const COUNTLIMIT = 15;
|
|
|
|
|
public function overview(){
|
|
|
|
|
$shuju = json_decode(M('IndexChart','tab_')->field("all_count")->order('`date` desc')->find()["all_count"],true);
|
|
|
|
|
$this->assign('shuju',$shuju);
|
|
|
|
@ -40,7 +41,7 @@ class StatisticsController extends ThinkController {
|
|
|
|
|
case 3:{$promote_data = $this->promote_data_order($thismounth,$lastmounth);};break;
|
|
|
|
|
case 4:{$promote_data = $this->promote_data_order($thisyear,$lastyear);};break;
|
|
|
|
|
default:
|
|
|
|
|
$promote_data = $this->promote_data_order($today,$yesterday);
|
|
|
|
|
$promote_data = $this->promote_data_order2($today,$yesterday);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assign('zhuce',$list_data['zhuce']);
|
|
|
|
@ -272,18 +273,106 @@ class StatisticsController extends ThinkController {
|
|
|
|
|
}
|
|
|
|
|
# code...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取推广员排行
|
|
|
|
|
* @param [type] $starttime 当前时间
|
|
|
|
|
* @param [type] $endtime 比较时间
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
private function promote_data_order($starttime,$endtime){
|
|
|
|
|
//注册排行
|
|
|
|
|
|
|
|
|
|
$PromoteCount = M("PromoteCount","tab_");
|
|
|
|
|
$data = array();
|
|
|
|
|
//注册排行
|
|
|
|
|
//1.获取注册前十名
|
|
|
|
|
$new_user_count = $PromoteCount->field("promote_id,promote_account,sum(new_user_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
$old_user_count = $PromoteCount->field("promote_id,promote_account,sum(new_user_count) cg")->where("`date` {$endtime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
//2.设置排名
|
|
|
|
|
$data["reg"] = $this->setRand($new_user_count,$old_user_count);
|
|
|
|
|
|
|
|
|
|
//活跃排行
|
|
|
|
|
//1.获取注册前十名
|
|
|
|
|
$new_active_count = $PromoteCount->field("promote_id,promote_account,sum(active_user_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
$old_active_count = $PromoteCount->field("promote_id,promote_account,sum(active_user_count) cg")->where("`date` {$endtime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
//2.设置排名
|
|
|
|
|
$data["active"] = $this->setRand($new_active_count,$old_active_count);
|
|
|
|
|
|
|
|
|
|
//支付排行
|
|
|
|
|
//1.获取注册前十名
|
|
|
|
|
$new_money_count = $PromoteCount->field("promote_id,promote_account,sum(pay_money_count) cg")->where("`date` {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
$old_money_count = $PromoteCount->field("promote_id,promote_account,sum(pay_money_count) cg")->where("`date` {$endtime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
//2.设置排名
|
|
|
|
|
$data["pay"] = $this->setRand($new_money_count,$old_money_count);
|
|
|
|
|
|
|
|
|
|
//设置chart
|
|
|
|
|
$char = array();
|
|
|
|
|
|
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
|
for ($i=0; $i < count($value); $i++) {
|
|
|
|
|
$t = $value[$i];
|
|
|
|
|
if(empty($char[$t['promote_id']])){
|
|
|
|
|
//不存在
|
|
|
|
|
$char[$t['promote_id']] = array(
|
|
|
|
|
// "promote_id" =>$t['promote_id'],
|
|
|
|
|
"promote_account" =>$t['promote_account'],
|
|
|
|
|
"reg" => 0,
|
|
|
|
|
"active"=>0,
|
|
|
|
|
"pay"=>0
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$char[$t['promote_id']][$key] = $t['cg'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach ($char as $key => $value) {
|
|
|
|
|
$data["chart"]["promote"] .= ("\"".$value['promote_account']."\",");
|
|
|
|
|
$data["chart"]["reg"] .= ( $value['reg'].",");
|
|
|
|
|
$data["chart"]["active"] .= ( $value['active'].",");
|
|
|
|
|
$data["chart"]["pay"] .= ( $value['pay'].",");
|
|
|
|
|
}
|
|
|
|
|
$data["chart"]["promote"] = \rtrim($data["chart"]["promote"],",");
|
|
|
|
|
$data["chart"]["reg"] = \rtrim($data["chart"]["reg"],",");
|
|
|
|
|
$data["chart"]["active"] = \rtrim($data["chart"]["active"],",");
|
|
|
|
|
$data["chart"]["pay"] = \rtrim($data["chart"]["pay"],",");
|
|
|
|
|
return $data;
|
|
|
|
|
|
|
|
|
|
//获取当前注册前十名
|
|
|
|
|
$new_user_count = $PromoteCount->field("promote_account,new_user_count")->where("`date` {$starttime}")->order("new_user_count desc")->limit(10)->select(false);
|
|
|
|
|
echo "<pre>";dump($new_user_count);die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//设置排名
|
|
|
|
|
public function setRand($randdata,$oldrand)
|
|
|
|
|
{
|
|
|
|
|
//数据是否为空
|
|
|
|
|
$rcount = count($randdata);
|
|
|
|
|
if($rcount < 1){return [];}
|
|
|
|
|
//判断是否有旧排名
|
|
|
|
|
$isold = true;
|
|
|
|
|
$ocount = count($oldrand);
|
|
|
|
|
if($ocount < 1){
|
|
|
|
|
$isold = false;
|
|
|
|
|
}else{
|
|
|
|
|
$oldrand = array_column($oldrand,"promote_id");
|
|
|
|
|
$oldrand=array_flip($oldrand);//反转数组
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ($i=0; $i <$rcount; $i++) {
|
|
|
|
|
$rand = $i+1;
|
|
|
|
|
|
|
|
|
|
$randdata[$i]['rand'] =$rand;
|
|
|
|
|
if($isold){
|
|
|
|
|
if(empty($oldrand[$randdata[$i]['promote_id']])){
|
|
|
|
|
$randdata[$i]['change'] = 0;
|
|
|
|
|
}else{
|
|
|
|
|
$randdata[$i]['change'] = $oldrand[$randdata[$i]['promote_id']] - $rand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
$randdata[$i]['change'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return $randdata;
|
|
|
|
|
# code...
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 排行榜(推广员)
|
|
|
|
|
* @param string $nowtime 现在时间段(between 开始时间戳 and 结束时间戳)
|
|
|
|
@ -409,7 +498,6 @@ if ($payids) {
|
|
|
|
|
else
|
|
|
|
|
$data['chart'][$k] = implode(',',$v);
|
|
|
|
|
}
|
|
|
|
|
echo "<pre>";dump($data);die();
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|