优化统计

master
chenzhi 5 years ago
parent 9962366ab9
commit 1c9ed4b2ba

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

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

Loading…
Cancel
Save