|
|
@ -29,55 +29,85 @@ class StatisticsCountSetController extends Controller {
|
|
|
|
$this->LoginModel =M("user_login_record","tab_");
|
|
|
|
$this->LoginModel =M("user_login_record","tab_");
|
|
|
|
$this->SpendModel =M("spend","tab_");
|
|
|
|
$this->SpendModel =M("spend","tab_");
|
|
|
|
$this->PromoteModel =M("promote","tab_");
|
|
|
|
$this->PromoteModel =M("promote","tab_");
|
|
|
|
|
|
|
|
$this->model =M();
|
|
|
|
$this->PromoteCountModel =M("PromoteCount","tab_");
|
|
|
|
$this->PromoteCountModel =M("PromoteCount","tab_");
|
|
|
|
$this->GameCountModel =M("GameCount","tab_");
|
|
|
|
$this->GameCountModel =M("GameCount","tab_");
|
|
|
|
$this->nowdata =time();
|
|
|
|
$this->nowdata =time();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$group_concat_max_len = M()->execute("SET SESSION group_concat_max_len = 4294967295");
|
|
|
|
|
|
|
|
echo "set group_concat_max_len ok,beging count".PHP_EOL;
|
|
|
|
if(I("reset")) $this->reset = true;
|
|
|
|
if(I("reset")) $this->reset = true;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setChartCount()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$begin = date("Y-m-d",strtotime("-1 day"));
|
|
|
|
|
|
|
|
$this->setDateCount($begin);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setFreeDateCount($begin,$end='')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if($end == '') $end = $begin;
|
|
|
|
|
|
|
|
//判断日期格式
|
|
|
|
|
|
|
|
$patten = "/^\d{4}[\-](0?[1-9]|1[012])[\-](0?[1-9]|[12][0-9]|3[01])$/";
|
|
|
|
|
|
|
|
if (!preg_match($patten, $begin)) {
|
|
|
|
|
|
|
|
die("开始时间格式错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!preg_match($patten, $end)) {
|
|
|
|
|
|
|
|
die("结束时间格式错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strtotime($end) < strtotime($begin)){
|
|
|
|
|
|
|
|
die("结束时间不能比开始时间小");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strtotime($end)+86399 > time()){
|
|
|
|
|
|
|
|
die("结束时间不能包含今日");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($begin == $end){
|
|
|
|
|
|
|
|
$this->setDateCount($begin);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$starttime = $begin?strtotime($begin):mktime(0,0,0,date('m'),date('d')-1,date('Y'));
|
|
|
|
|
|
|
|
$endtime = $end?strtotime($end)+86399:$starttime+86399;
|
|
|
|
|
|
|
|
$datelist = get_date_list($starttime,$endtime,1);
|
|
|
|
|
|
|
|
$countdate = count($datelist);
|
|
|
|
|
|
|
|
for($i=0;$i<$countdate;$i++){
|
|
|
|
|
|
|
|
$this->setDateCount($datelist[$i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public function setDateCount($date)
|
|
|
|
public function setDateCount($date)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->date = $date;
|
|
|
|
$this->date = $date;
|
|
|
|
$tarry = explode('-',$date);
|
|
|
|
$tarry = explode('-',$date);
|
|
|
|
$this->beginTime=mktime(0,0,0,$tarry[1],$tarry[2],$tarry[0]);
|
|
|
|
$this->beginTime=mktime(0,0,0,$tarry[1],$tarry[2],$tarry[0]);
|
|
|
|
$this->endTime=mktime(0,0,0,$tarry[1],$tarry[2]-0+1,$tarry[0])-1;
|
|
|
|
$this->endTime=mktime(0,0,0,$tarry[1],$tarry[2]-0+1,$tarry[0])-1;
|
|
|
|
|
|
|
|
|
|
|
|
set_time_limit(0);
|
|
|
|
set_time_limit(0);
|
|
|
|
$t1 = microtime(true);
|
|
|
|
$t1 = microtime(true);
|
|
|
|
//判断是否存在
|
|
|
|
//判断是否存在
|
|
|
|
// $res = $this->ChartModel->where("date = '{$this->beginTime}'")->find();
|
|
|
|
$PromoteRes = $this->PromoteCountModel->where("date = '{$this->beginTime}'")->find();
|
|
|
|
// $reset='';
|
|
|
|
$GameRes = $this->GameCountModel->where("date = '{$this->beginTime}'")->find();
|
|
|
|
// if(!empty($res)){
|
|
|
|
$reset='';
|
|
|
|
// if($this->reset){
|
|
|
|
if(!empty($PromoteRes) || !empty($GameRes) ){
|
|
|
|
// $this->ChartModel->where("date = '{$this->beginTime}'")->delete();
|
|
|
|
if($this->reset){
|
|
|
|
// $reset = "reset and creat ";
|
|
|
|
$this->PromoteCountModel->where("date = '{$this->beginTime}'")->delete();
|
|
|
|
// }else{
|
|
|
|
$this->GameCountModel->where("date = '{$this->beginTime}'")->delete();
|
|
|
|
// echo ("{$this->date} 已统计,请勿重复提交".PHP_EOL);
|
|
|
|
$reset = "reset and creat ";
|
|
|
|
// return;
|
|
|
|
}else{
|
|
|
|
// }
|
|
|
|
echo ("{$this->date} 已统计,请勿重复提交".PHP_EOL);
|
|
|
|
|
|
|
|
return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
$group_concat_max_len = M()->query("show variables like 'group_concat_max_len'")[0]['value'];
|
|
|
|
|
|
|
|
if($group_concat_max_len < 102400){
|
|
|
|
|
|
|
|
echo ("请".PHP_EOL);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dump($res);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->model->startTrans();
|
|
|
|
// $this->promoteNew();
|
|
|
|
$this->promoteNew();
|
|
|
|
// $this->promotePayMoeny();
|
|
|
|
$this->promotePayMoeny();
|
|
|
|
// $this->promoteActive();
|
|
|
|
$this->promoteActive();
|
|
|
|
// $this->promoteCreateDb();
|
|
|
|
$this->promoteCreateDb();
|
|
|
|
|
|
|
|
$this->addid = [];
|
|
|
|
// $this->addid = [];
|
|
|
|
$this->adddata = [];
|
|
|
|
// $this->adddata = [];
|
|
|
|
$this->gameNew();
|
|
|
|
|
|
|
|
$this->gamePayMoeny();
|
|
|
|
// $this->gameNew();
|
|
|
|
$this->gameActive();
|
|
|
|
// $this->gamePayMoeny();
|
|
|
|
$this->gameCreateDb();
|
|
|
|
// $this->gameActive();
|
|
|
|
$this->model->commit();
|
|
|
|
// $this->gameCreateDb();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$t2 = microtime(true);
|
|
|
|
$t2 = microtime(true);
|
|
|
|
echo ("{$this->date} {$reset}success runtime:".round($t2-$t1,3).'s'.PHP_EOL);
|
|
|
|
echo ("{$this->date} {$reset}success runtime:".round($t2-$t1,3).'s'.PHP_EOL);
|
|
|
|
# code...
|
|
|
|
# code...
|
|
|
@ -149,10 +179,14 @@ class StatisticsCountSetController extends Controller {
|
|
|
|
$value['date']=$this->beginTime;
|
|
|
|
$value['date']=$this->beginTime;
|
|
|
|
$value['create_time']=$this->nowdata;
|
|
|
|
$value['create_time']=$this->nowdata;
|
|
|
|
$value['active_user_list'] = @serialize(explode(",",$value['active_user_list']));
|
|
|
|
$value['active_user_list'] = @serialize(explode(",",$value['active_user_list']));
|
|
|
|
if(empty($value['promote_account'])){
|
|
|
|
if(empty($value['promote_account']) && $value['promote_id']){
|
|
|
|
$value['promote_account'] = $this->PromoteModel->field("account")->where("id = {$value['promote_id']}")->find()['account'];
|
|
|
|
$value['promote_account'] = $this->PromoteModel->field("account")->where("id = {$value['promote_id']}")->find()['account'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->PromoteCountModel->add($value);
|
|
|
|
$tempdbres = $this->PromoteCountModel->add($value);
|
|
|
|
|
|
|
|
if($tempdbres === false){
|
|
|
|
|
|
|
|
$this->model->rollback();
|
|
|
|
|
|
|
|
die("error");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -222,7 +256,11 @@ class StatisticsCountSetController extends Controller {
|
|
|
|
$value['date']=$this->beginTime;
|
|
|
|
$value['date']=$this->beginTime;
|
|
|
|
$value['create_time']=$this->nowdata;
|
|
|
|
$value['create_time']=$this->nowdata;
|
|
|
|
$value['active_user_list'] = @serialize(explode(",",$value['active_user_list']));
|
|
|
|
$value['active_user_list'] = @serialize(explode(",",$value['active_user_list']));
|
|
|
|
$this->GameCountModel->add($value);
|
|
|
|
$tempdbres = $this->GameCountModel->add($value);
|
|
|
|
|
|
|
|
if($tempdbres === false){
|
|
|
|
|
|
|
|
$this->model->rollback();
|
|
|
|
|
|
|
|
die("error");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|