|
|
|
@ -296,31 +296,41 @@ class StatisticsController extends ThinkController {
|
|
|
|
|
|
|
|
|
|
//活跃排行
|
|
|
|
|
//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();
|
|
|
|
|
if(count($new_active_count) > 0){
|
|
|
|
|
$listarr = array();
|
|
|
|
|
$promote_id_str = '';
|
|
|
|
|
for ($i=0; $i < count($new_active_count); $i++) {
|
|
|
|
|
# code...
|
|
|
|
|
$promote_id_str .= ($new_active_count[$i]['promote_id'].",");
|
|
|
|
|
$new_active_count[$i]["active_user_list"] = [];
|
|
|
|
|
$listarr[$new_active_count[$i]['promote_id']] = $new_active_count[$i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promote_id_str = \rtrim($promote_id_str,",");
|
|
|
|
|
//查询
|
|
|
|
|
$active_user_list = $PromoteCount->field("active_user_list,promote_id")->where("`date` {$starttime} AND promote_id in ({$promote_id_str})")->select();
|
|
|
|
|
for ($i=0; $i < count($active_user_list); $i++) {
|
|
|
|
|
$listarr[$active_user_list[$i]["promote_id"]]["active_user_list"] += json_decode($active_user_list[$i]["active_user_list"],true);
|
|
|
|
|
}
|
|
|
|
|
foreach ($listarr as $key => $value) {
|
|
|
|
|
$value['cg'] = count(array_flip(array_flip($value['active_user_list'])));
|
|
|
|
|
unset($value['active_user_list']);
|
|
|
|
|
$listarr[$key] = $value;
|
|
|
|
|
if($today){
|
|
|
|
|
$map = ["l.promote_id"=>["gt",0]];//0不是小号
|
|
|
|
|
$new_active_count = M()->table("tab_user_login_record l")->field('COUNT(DISTINCT user_id) AS cg,l.promote_id,p.account promote_account')
|
|
|
|
|
->where($map)->where("l.login_time {$starttime}")
|
|
|
|
|
->group("promote_id")
|
|
|
|
|
->join("tab_promote p ON l.promote_id = p.id")
|
|
|
|
|
->order("cg desc")
|
|
|
|
|
->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
}else{
|
|
|
|
|
$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();
|
|
|
|
|
if(count($new_active_count) > 0){
|
|
|
|
|
$listarr = array();
|
|
|
|
|
$promote_id_str = '';
|
|
|
|
|
for ($i=0; $i < count($new_active_count); $i++) {
|
|
|
|
|
# code...
|
|
|
|
|
$promote_id_str .= ($new_active_count[$i]['promote_id'].",");
|
|
|
|
|
$new_active_count[$i]["active_user_list"] = [];
|
|
|
|
|
$listarr[$new_active_count[$i]['promote_id']] = $new_active_count[$i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promote_id_str = \rtrim($promote_id_str,",");
|
|
|
|
|
//查询
|
|
|
|
|
$active_user_list = $PromoteCount->field("active_user_list,promote_id")->where("`date` {$starttime} AND promote_id in ({$promote_id_str})")->select();
|
|
|
|
|
for ($i=0; $i < count($active_user_list); $i++) {
|
|
|
|
|
$listarr[$active_user_list[$i]["promote_id"]]["active_user_list"] += json_decode($active_user_list[$i]["active_user_list"],true);
|
|
|
|
|
}
|
|
|
|
|
foreach ($listarr as $key => $value) {
|
|
|
|
|
$value['cg'] = count(array_flip(array_flip($value['active_user_list'])));
|
|
|
|
|
unset($value['active_user_list']);
|
|
|
|
|
$listarr[$key] = $value;
|
|
|
|
|
}
|
|
|
|
|
$last_names = array_column($listarr,'cg');
|
|
|
|
|
array_multisort($last_names,SORT_DESC,$listarr);
|
|
|
|
|
$new_active_count = $listarr;
|
|
|
|
|
}
|
|
|
|
|
$last_names = array_column($listarr,'cg');
|
|
|
|
|
array_multisort($last_names,SORT_DESC,$listarr);
|
|
|
|
|
$new_active_count = $listarr;
|
|
|
|
|
}
|
|
|
|
|
//获取活跃总量排行
|
|
|
|
|
$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();
|
|
|
|
@ -329,7 +339,13 @@ class StatisticsController extends ThinkController {
|
|
|
|
|
|
|
|
|
|
//支付排行
|
|
|
|
|
//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();
|
|
|
|
|
if($today){
|
|
|
|
|
$map = ["pay_status"=>1,"promote_id"=>["gt",0]];
|
|
|
|
|
$new_money_count = M("Spend","tab_")->field('sum(pay_amount) AS cg,promote_id,promote_account')->where($map)->where("pay_time {$starttime}")->group("promote_id")->order("cg desc")->limit(self::COUNTLIMIT)->select();
|
|
|
|
|
}else{
|
|
|
|
|
$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);
|
|
|
|
|