NoteStar 5 سال پیش
والد
کامیت
ed5e722168

+ 113 - 2
vendor/fancyecommerce/fecshop/app/appadmin/modules/Fecadmin/block/visitortj/Index.php

@@ -46,7 +46,9 @@ class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface
 		$tbody = $this->getTableTbody();
 		# 分页部分
 		$toolBar = $this->getToolBar($this->_param['numCount'],$this->_param['pageNum'],$this->_param['numPerPage']); 
-		
+
+		$tongji = $this->getTongji();
+
 		return [
 			'pagerForm'	 	=> $pagerForm,
 			'searchBar'		=> $searchBar,
@@ -54,9 +56,118 @@ class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface
 			'thead'		=> $thead,
 			'tbody'		=> $tbody,
 			'toolBar'	=> $toolBar,
+			'tongji'	=> $tongji,
 		];
 	}
-	
+
+	public function getTongji(){
+        $obj = Yii::$service->userfrom->getSystemLogModel();
+        $table = $obj::tableName();
+        $db = \Yii::$app->db;
+
+
+        $seven_tjtime = date('Y-m-d 00:00:00',strtotime("-7 day"));
+        $three_tjtime = date('Y-m-d 00:00:00',strtotime("-3 day"));
+        $today_tjtime = date('Y-m-d 00:00:00',strtotime("today"));
+
+        $one_day_array = array();
+        $three_day_array = array();
+        $seven_day_array = array();
+
+        $seven_where = " where user_from_time >=  '$seven_tjtime'  ";
+        $three_where = " where user_from_time >=  '$three_tjtime'  ";
+        $one_where = " where user_from_time >=  '$today_tjtime' ";
+
+
+        # 得到 统计数组。
+        $seven_sql = "select user_ip,user_from_time,count(user_ip) as ip_num  from $table  $seven_where  group by user_ip order by user_ip desc";
+        $seven_day_array = $db->createCommand($seven_sql,[])->queryAll();
+
+        $three_sql = "select user_ip,user_from_time,count(user_ip) as ip_num  from $table  $three_where  group by user_ip order by user_ip desc ";
+        $three_day_array = $db->createCommand($three_sql,[])->queryAll();
+
+        $one_sql = "select user_ip,user_from_time,count(user_ip) as ip_num  from $table  $one_where  group by user_ip order by user_ip desc ";
+        $one_day_array = $db->createCommand($one_sql,[])->queryAll();
+
+        $created_at_lt 	= $this->_param['user_from_time_lt'];
+        $created_at_gte = $this->_param['user_from_time_gte'];
+        $where = [];
+
+        if($created_at_lt)
+            $where []= " user_from_time < '$created_at_lt' ";
+        if($created_at_gte)
+            $where []= " user_from_time >= '$created_at_gte' ";
+        if(!empty($where)){
+            $where = ' where '.implode(' and ',$where);
+        }else{
+            $where = '';
+        }
+        $period_sql = "select user_ip,user_from_time,count(user_ip) as ip_num  from $table  $where  group by user_ip";
+        $period_data = $db->createCommand($period_sql,[])->queryAll();
+
+        $str = '<div class="tj">IP只显示访问三次及以上的</div>';
+
+        $one_num = 0;
+        $str .= "<div class='tj'>今日来访IP:";
+        foreach ($one_day_array as $o_k => $o_v){
+            if($o_v['ip_num'] < 3){
+                continue;
+            }
+            $str .= "&nbsp;&nbsp;";
+            $str .= $o_v['user_ip']."(".$o_v['ip_num']."次)";
+            $one_num++;
+        }
+        $str .= "</div>";
+        $str .= "<div class='tj'>今日来访人数: $one_num 人</div>";
+
+        $three_num = 0;
+        $str .= "<div class='tj'>近三天来访IP:";
+        foreach ($three_day_array as $o_k => $o_v){
+            if($o_v['ip_num'] < 3){
+                continue;
+            }
+            $str .= "&nbsp;&nbsp;";
+            $str .= $o_v['user_ip']."(".$o_v['ip_num']."次)";
+            $three_num++;
+        }
+        $str .= "</div>";
+        $str .= "<div class='tj'>近三天来访人数: $three_num 人</div>";
+
+        $seven_num = 0;
+        $str .= "<div class='tj'>近七天来访IP:";
+        foreach ($seven_day_array as $o_k => $o_v){
+            if($o_v['ip_num'] < 3){
+                continue;
+            }
+            $str .= "&nbsp;&nbsp;";
+            $str .= $o_v['user_ip']."(".$o_v['ip_num']."次)";
+            $seven_num++;
+        }
+        $str .= "</div>";
+        $str .= "<div class='tj'>近七天来访人数: $seven_num 人</div>";
+
+
+        $period_num = 0;
+        $str .= "<div class='tj'>当前时间段来访IP:";
+        foreach ($period_data as $o_k => $o_v){
+            if($o_v['ip_num'] < 3){
+                continue;
+            }
+            $str .= "&nbsp;&nbsp;";
+            $str .= $o_v['user_ip']."(".$o_v['ip_num']."次)";
+            $period_num++;
+        }
+        $str .= "</div>";
+        $str .= "<div class='tj'>当前时间段来访人数: $period_num 人</div>";
+
+
+
+        return $str;
+
+
+    }
+
+
 	# 定义搜索部分字段格式
 	public function getSearchArr(){
 		$data = [

+ 12 - 0
vendor/fancyecommerce/fecshop/app/appadmin/theme/base/default/fecadmin/visitortj/index.php

@@ -21,6 +21,11 @@ use fec\helpers\CRequest;
 		</div>
 	</form>
 </div>
+<div class="pageContent">
+
+        <?= $tongji; ?>
+
+</div>
 <div class="pageContent">
 	<div class="panelBar">
 		<?php //echo $editBar;  ?>
@@ -35,3 +40,10 @@ use fec\helpers\CRequest;
 		</tbody>
 	</table>
 </div>
+<style>
+    .tj{
+        width: 96%;
+        line-height: 25px;
+        padding: 0px 2%;
+    }
+</style>