计算回头率方法

WBOY
Freigeben: 2016-08-08 09:23:47
Original
1728 Leute haben es durchsucht

public function probability() {
		global $_INPUT;
		$ret        = array();
		$time	    = $_INPUT['date'] && preg_match('/^\d{4}-\d{2}\-\d{2}$/', $_INPUT['date']) ? strtotime($_INPUT['date']) : strtotime('today');
		$today      = $time;          //该天时间头
		$tomorrow   = $time + 86400;  //该天时间尾
		$flag       = 1;              //是否进入比赛
		$model      = Model::getInstance('logs.fixedlog');
		$paymodel   = Model::getInstance('main.payment');
		$stats      = array();
		$num        = 0;              //连续一周回头人数
		$option     = isset($_INPUT['app']) ? intval($_INPUT['app']) : 1;
		$interval   = isset($_INPUT['period']) ? intval($_INPUT['period']) : 1; //时间区间一周
		if($option == 1) {
			for($i = 0;$i turnround($today,$tomorrow,$flag);  //获取该天参加比赛的会员
		        $temp = array(); 
		        foreach($res as $value){
		        	$inmatch = isset($value['inmatch']) ? json_decode($value['inmatch']) : array();
		            foreach($inmatch as $val) {
		            	if(!in_array($val, $temp)) {
	                        array_unshift($temp,$val);  //去掉该天重复参加比赛会员
		            	}
		            }
		        }
		        $i==0 ? $total = count($temp) : "";     
		        $temp = array_fill_keys($temp, $i);  //把会员记录导入stats数组
		        foreach($temp as $k=>$v) {
		        	if(array_key_exists($k,$stats)) {   //如果stats数组里面存着该会员ID,则尾部追加该登陆的每日号
	                    $stats[$k] = $stats[$k].",".$v;
		        	} else {
		        		$stats[$k] = $v;
		        	}
		        }
		        $today    = $today - 86400;   //逐次改变每日号起止时间
	            $tomorrow = $tomorrow - 86400;        
		    }
			$strlen = ($interval+1)*2-1;
			foreach($stats as $v) {
				if(isset($v)) {
					strlen(trim($v)) == $strlen ? $num++ : $num;
				}		
			}
			$ret['turnround']['all']   = $stats;
			$ret['turnround']['total'] = $total;
			$ret['turnround']['stats'] = count($stats);
			$ret['turnround']['num']   = $num;
		} else {
			$res  = $model->turnround($today,$tomorrow,$flag);  //获取该天参加比赛的会员
			$temp = array(); 
	        foreach($res as $value){
	        	$inmatch = isset($value['inmatch']) ? json_decode($value['inmatch']) : array();
	            foreach($inmatch as $val) {
	            	if(!in_array($val, $temp)) {
                        array_unshift($temp,$val);  //去掉该天重复参加比赛会员
	            	}
	            }
	        }  
	        foreach($temp as $k=>$v) {
                $paystatus = $paymodel->hasCharge($v,$tomorrow,$today-1);
                isset($paystatus) && $paystatus['num']0 ? $num++ : "";

	        }
            $ret['payrate']['all']   = $temp;
            $ret['payrate']['total'] = count($temp);
			$ret['payrate']['num']   = $num;
		}
		return $this->ret($ret);
    }
Nach dem Login kopieren

以上就介绍了计算回头率方法,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!