优化统计

master
chenzhi 5 years ago
parent 9962366ab9
commit 1c9ed4b2ba

@ -27,7 +27,7 @@ class StatisticsController extends ThinkController {
// 游戏排行 // 游戏排行
$type=$_REQUEST['type']; $type=$_REQUEST['type'];
if($type==1 || $type==''){ if($type==1 || $type==''){
$list_data=$this->data_order($today,$yesterday); $list_data=$this->data_order2($today,$yesterday);
}elseif($type==2){ }elseif($type==2){
$list_data=$this->data_order($thisweek,$lastweek); $list_data=$this->data_order($thisweek,$lastweek);
}elseif($type==3){ }elseif($type==3){
@ -43,15 +43,14 @@ class StatisticsController extends ThinkController {
default: default:
$promote_data = $this->promote_data_order2($today,$yesterday); $promote_data = $this->promote_data_order2($today,$yesterday);
} }
dump($list_data);die();
$this->assign('zhuce',$list_data['reg']); $this->assign('zhuce',$list_data['reg']);
$this->assign('active',$list_data['active']); $this->assign('active',$list_data['active']);
$this->assign('pay',$list_data['pay']); $this->assign('pay',$list_data['pay']);
$this->assign('game_chart',$list_data['chart']); $this->assign('game_chart',$list_data['chart']);
$this->assign('promotereg',array_slice($promote_data['reg'], 0, 10)); $this->assign('promotereg',$promote_data['reg']);
$this->assign('promoteactive',array_slice($promote_data['active'], 0, 10)); $this->assign('promoteactive',$promote_data['active']);
$this->assign('promotepay',array_slice($promote_data['pay'], 0, 10)); $this->assign('promotepay',$promote_data['pay']);
$this->assign('promote_chart', $promote_data['chart']); $this->assign('promote_chart', $promote_data['chart']);
@ -512,16 +511,16 @@ class StatisticsController extends ThinkController {
"pay"=>0 "pay"=>0
); );
} }
$char[$t['promote_id']][$key] = $t['cg']; $char[$t['game_id']][$key] = $t['cg'];
} }
} }
foreach ($char as $key => $value) { foreach ($char as $key => $value) {
$data["chart"]["game_name"] .= ("\"".$value['game_name']."\","); $data["chart"]["game"] .= ("\"".$value['game_name']."\",");
$data["chart"]["reg"] .= ( $value['reg'].","); $data["chart"]["reg"] .= ( $value['reg'].",");
$data["chart"]["active"] .= ( $value['active'].","); $data["chart"]["active"] .= ( $value['active'].",");
$data["chart"]["pay"] .= ( $value['pay'].","); $data["chart"]["pay"] .= ( $value['pay'].",");
} }
$data["chart"]["game_name"] = \rtrim($data["chart"]["game_name"],","); $data["chart"]["game"] = \rtrim($data["chart"]["game"],",");
$data["chart"]["reg"] = \rtrim($data["chart"]["reg"],","); $data["chart"]["reg"] = \rtrim($data["chart"]["reg"],",");
$data["chart"]["active"] = \rtrim($data["chart"]["active"],","); $data["chart"]["active"] = \rtrim($data["chart"]["active"],",");
$data["chart"]["pay"] = \rtrim($data["chart"]["pay"],","); $data["chart"]["pay"] = \rtrim($data["chart"]["pay"],",");
@ -641,7 +640,6 @@ class StatisticsController extends ThinkController {
else else
$data['chart'][$k] = implode(',',$v); $data['chart'][$k] = implode(',',$v);
} }
echo "<pre>";dump($data);die();
return $data; return $data;
} }
//设置排名 //设置排名
@ -672,7 +670,7 @@ class StatisticsController extends ThinkController {
} }
}else{ }else{
$randdata[$i]['change'] = 0; $randdata[$i]['change'] = $rand-1 - self::COUNTLIMIT;
} }
} }

@ -17,9 +17,11 @@ class StatisticsCountSetController extends Controller {
public $LoginModel; public $LoginModel;
public $SpendModel; public $SpendModel;
public $PromoteModel; public $PromoteModel;
public $GameCountModel;
public $addid; public $addid;
public $adddata; public $adddata;
public $gameid;
public $gamedata;
public $reset=false; public $reset=false;
public function _initialize(){ public function _initialize(){
@ -96,14 +98,16 @@ class StatisticsCountSetController extends Controller {
} }
} }
$this->model->startTrans(); $this->model->startTrans();
$this->addid = [];
$this->adddata = [];
$this->promoteNew(); $this->promoteNew();
$this->promotePayMoeny(); $this->promotePayMoeny();
$this->promoteActive(); $this->promoteActive();
$this->promoteCreateDb(); $this->promoteCreateDb();
unset($this->addid); // unset($this->addid);
unset($this->adddata); // unset($this->adddata);
$this->addid = []; $this->gameid = [];
$this->adddata = []; $this->gamedata = [];
$this->gameNew(); $this->gameNew();
$this->gamePayMoeny(); $this->gamePayMoeny();
$this->gameActive(); $this->gameActive();
@ -202,8 +206,8 @@ class StatisticsCountSetController extends Controller {
->select(); ->select();
$count = count($gameNew); $count = count($gameNew);
for ($i=0; $i < $count; $i++) { for ($i=0; $i < $count; $i++) {
$this->addid[] = $gameNew[$i]["game_id"]; $this->gameid[] = $gameNew[$i]["game_id"];
$this->adddata[$gameNew[$i]["game_id"]] = $gameNew[$i]; $this->gamedata[$gameNew[$i]["game_id"]] = $gameNew[$i];
} }
unset($gameNew); unset($gameNew);
} }
@ -217,12 +221,12 @@ class StatisticsCountSetController extends Controller {
->select(); ->select();
$count = count($gamePayMoeny); $count = count($gamePayMoeny);
for ($i=0; $i < $count; $i++) { for ($i=0; $i < $count; $i++) {
if (in_array($gamePayMoeny[$i]["game_id"],$this->addid)) { if (in_array($gamePayMoeny[$i]["game_id"],$this->gameid)) {
//存在 //存在
$this->adddata[$gamePayMoeny[$i]["game_id"]]["pay_money_count"] = $gamePayMoeny[$i]["pay_money_count"]; $this->gamedata[$gamePayMoeny[$i]["game_id"]]["pay_money_count"] = $gamePayMoeny[$i]["pay_money_count"];
}else{ }else{
$this->addid[] = $gamePayMoeny[$i]["game_id"]; $this->gameid[] = $gamePayMoeny[$i]["game_id"];
$this->adddata[$gamePayMoeny[$i]["game_id"]] = $gamePayMoeny[$i]; $this->gamedata[$gamePayMoeny[$i]["game_id"]] = $gamePayMoeny[$i];
} }
} }
unset($gamePayMoeny); unset($gamePayMoeny);
@ -237,13 +241,13 @@ class StatisticsCountSetController extends Controller {
->select(); ->select();
$count = count($gameActive); $count = count($gameActive);
for ($i=0; $i < $count; $i++) { for ($i=0; $i < $count; $i++) {
if (in_array($gameActive[$i]["game_id"],$this->addid)) { if (in_array($gameActive[$i]["game_id"],$this->gameid)) {
//存在 //存在
$this->adddata[$gameActive[$i]["game_id"]]["active_user_count"] = $gameActive[$i]["active_user_count"]; $this->gamedata[$gameActive[$i]["game_id"]]["active_user_count"] = $gameActive[$i]["active_user_count"];
$this->adddata[$gameActive[$i]["game_id"]]["active_user_list"] = $gameActive[$i]["active_user_list"]; $this->gamedata[$gameActive[$i]["game_id"]]["active_user_list"] = $gameActive[$i]["active_user_list"];
}else{ }else{
$this->addid[] = $gameActive[$i]["game_id"]; $this->gameid[] = $gameActive[$i]["game_id"];
$this->adddata[$gameActive[$i]["game_id"]] = $gameActive[$i]; $this->gamedata[$gameActive[$i]["game_id"]] = $gameActive[$i];
} }
} }
unset($gameActive); unset($gameActive);
@ -251,9 +255,9 @@ class StatisticsCountSetController extends Controller {
//4加入数据库 //4加入数据库
public function gameCreateDb() public function gameCreateDb()
{ {
$count = count($this->addid); $count = count($this->gameid);
if ($count > 0) { if ($count > 0) {
foreach ($this->adddata as $key => $value) { foreach ($this->gamedata as $key => $value) {
$value['date']=$this->beginTime; $value['date']=$this->beginTime;
$value['create_time']=$this->nowdata; $value['create_time']=$this->nowdata;
$value['active_user_list'] = @json_encode(array_map("intFun",explode(",",$value['active_user_list']))); $value['active_user_list'] = @json_encode(array_map("intFun",explode(",",$value['active_user_list'])));

Loading…
Cancel
Save