xiaosongshu007 5 vuotta sitten
vanhempi
commit
e556e1fcfd

+ 141 - 0
Application/Admin/Controller/StatisticController.class.php

@@ -0,0 +1,141 @@
+<?php
+
+namespace Admin\Controller;
+use Think\Model;
+/**
+ * 样式管理
+ * @author   brent
+ * @version  0.0.1
+ */
+class StatisticController extends CommonController
+{
+    protected $table = ''; //表名
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+		//要执行的表
+		$this->table = M('iptv_users');
+	}
+
+    public function orderData()
+    {
+        $start = I('start_time',date('Y-m-d',strtotime('-8 day', time())));
+        $end = I('end_time',date('Y-m-d'));
+
+//        $start = '2019-10-10';
+//        $end   = '2019-10-17';
+
+        $start_date = date('Ymd',strtotime($start));
+        $end_date = date('Ymd',strtotime($end));
+
+        $where['date(created_at)'] = ['between',[$start,$end]];
+        $pvs = []; $uvs =[]; $times = [];
+        for ($i=0;$i<=9;$i++) {
+            # code...
+            if($i==0){
+                $table = 'iptv_user_login_log';
+            }else{
+                $table = 'iptv_user_login_log_'.$i;
+            }
+
+            $tmp_pvs   = M($table)->where($where)->group('day')->getField('date(created_at) as day,count(*) as total');
+            $tmp_uvs   = M($table)->where($where)->group('day')->getField('date(created_at) as day,count(distinct(uid)) as total');
+
+            foreach ($tmp_pvs as $date => $val) {
+                if(isset($pvs[$date])){
+                    $pvs[$date] = $pvs[$date] + $val;
+                }else{
+                    $pvs[$date] = $val;
+                }
+            }
+
+            foreach ($tmp_uvs as $date => $val) {
+                if(isset($uvs[$date])){
+                    $uvs[$date] = $uvs[$date] + $val;
+                }else{
+                    $uvs[$date] = $val;
+                }
+            }
+        }
+        unset($where);
+        $where['date'] = ['between',[$start_date ,$end_date]];
+        $where['status'] = 0;
+        $orders = M('iptv_order_own')->where($where)->group('date')->getField('date,count(distinct(uid)) as total');
+//        dump($orders);
+        $where['status'] = 2;
+        $pre_orders = M('iptv_order_own')->where($where)->group('date')->getField('date,count(distinct(uid)) as total');
+        $pre_orders_counts = M('iptv_order_own')->where($where)->group('date')->getField('date,count(*) as total');
+
+        unset($where);
+        $where['status'] =99;
+        $cancel_orders = M('iptv_order_own')->where($where)->group('date')->getField('date,count(distinct(uid)) as total');
+
+        //新增用户数
+        unset($where);
+        $where['date(created_at)'] = ['between',[$start,$end]];
+        $addusers = M('iptv_users')->where($where)->group('day')->getField('date(created_at) as day,count(*) as total');
+//        dump($pre_orders);
+        // $play_time_sum = M('statistic_source')->where(['date'=>])
+        //播放时长
+        // var_dump($addusers);
+        while ($start_date <= $end_date){
+            $dates[] = date('Y-m-d',strtotime($start_date));
+            $start_date = date('Ymd',(strtotime($start_date)+24*3600));
+        }
+        $dates = array_reverse($dates);
+        foreach ($dates as $date){
+        	$where['created_at'] = ['elt',date('Y-m-d 23:59:59',strtotime($date))]; 
+            $data[] = [
+                'date'=>$date,
+                'pv'=>$pvs[$date] ?:0,
+                'uv'=>$uvs[$date]?:0,
+                'order'=>$orders[date('Ymd',strtotime($date))]?:0,
+                'pre_order'=>$pre_orders[date('Ymd',strtotime($date))]?:0,
+                'pre_order_count'=>$pre_orders_counts[date('Ymd',strtotime($date))] ? :0,
+                'cancel_order'=>$cancel_orders[date('Ymd',strtotime($date))] ? : 0,
+                'add_user'=>$addusers[$date] ? : 0,
+                'user_sum'=>M('iptv_users')->where($where)->order('user_id desc')->limit(1)->getField('user_id')
+
+            ];
+            // echo M()->getlastSQL();die;
+        }
+        // dump($data);
+        if(I('model')){
+            $title = array(
+                'date'                      =>  array('col' => 'A', 'name' => '日期'),
+                'pv'                        =>  array('col' => 'B', 'name' => 'pv'),
+                'uv'                        =>  array('col' => 'C', 'name' => 'uv'),
+                'order'                     =>  array('col' => 'D', 'name' => '订购数'),
+                'cancel_order'              =>  array('col' => 'E', 'name' => '退订数'),
+                'pre_order'                 =>  array('col' => 'F', 'name' => '预订购(去重)'),
+                'pre_order_count'           =>  array('col' => 'G', 'name' => '预订购'),
+                'add_user'					=>  array('col'	=> 'I',	'name' => '新增用户'	),
+                'user_sum'					=>  array('col'	=> 'J',	'name' => '累计用户'	)
+            );
+            // Excel驱动导出数据
+            $excel = new \My\Excel(array('filename' => '金鹰电竞运营数据'.$start.'至'.$end, 'title' => $title, 'data' => $data, 'msg' => L('common_not_data_tips')));
+            $excel->Export();
+            die;
+        }
+        $this->assign('start_time',$start);
+        $this->assign('end_time',$end);
+        $this->assign('dates',$dates);
+        $this->assign('data',$data);
+        $this->display();
+    }
+	
+}

+ 172 - 0
Application/Admin/View/Default/Statistic/Index.html

@@ -0,0 +1,172 @@
+<!-- header start -->
+<include file="Public/Header" />
+<style>
+	.yearset{display: inline-block;}
+	.monthset{display: inline-block;}
+	.dayset{display: inline-block;}
+	.datebb{padding: 0.4rem 0;}
+</style>
+<!-- header end -->
+<!-- right content start  -->
+<div style="border-bottom: 0.1rem solid #ddd;margin-bottom: 2rem ;">
+	<b>新增设备用户:</b>
+</div>
+<div class="am-g">
+	<form class="am-form view-list mybform" name="mybform" action="{{:U('Admin/Statistic/Index')}}" method="POST">
+		<div style="display: inline-block;margin-left: 5rem;">
+			<select name="type" style="display: inline-block;width: 10rem;margin-right: 1rem;">
+					<option value="-1">请选择</option>
+					<option value="1" <if condition="isset($type) and $type eq 1">selected</if> >日走势</option>
+					<option value="2" <if condition="isset($type) and $type eq 2">selected</if> >月走势</option>
+					<option value="3" <if condition="isset($type) and $type eq 3">selected</if> >年走势</option>
+			</select>	
+		</div>
+		<div style="width:500px;display: inline-block;">
+			<label>时间:</label>
+			<input name="time" class="datebb"  value="{{$time}}" autocomplete="off" style="width:12rem;border-left: 0.1rem solid;" />
+		</div>
+	<button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit" style="display: inline-block;position: absolute;top:4rem;left: 45rem;">查询</button>
+	</form>
+	</div>
+<div id="container" style="width: 1200px; height: 400px; margin: 2rem 5rem 5rem 5rem;"></div>
+<div>
+	<div>
+		<button class="watch_list">查看列表</button>
+	</div>
+	<div class="data_list">
+		<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
+			<thead>
+				<tr>
+					<th>序号</th>
+					<th class="am-hide-sm-only">平台</th>
+					<th>用户ID(设备id)</th>
+					<th class="am-hide-sm-only">手机号</th>
+					<th class="am-hide-sm-only">会员到期时间</th>
+					<th class="am-hide-sm-only">最后登录时间</th>
+					<th class="am-hide-sm-only">创建时间</th>
+					<th>{{:L('common_operation_name')}}</th>
+				</tr>
+			</thead>
+			<tbody>
+				<if condition="!empty($List)">
+					<foreach name="List" item="v">
+						<tr id="data-list-{{$v.id}}">
+							<td class="am-hide-sm-only">{{$key+1}}</td>
+							<td class="am-hide-sm-only">{{$v.user_origin}}</td>
+							<td class="am-hide-sm-only">{{$v.uid}}</td>
+							<td class="am-hide-sm-only">{{$v.phone}}</td>
+							<td class="am-hide-sm-only">{{$v.member_time}}</td>
+							<td class="am-hide-sm-only">{{$v.last_login_at}}</td>
+							<td class="am-hide-sm-only">{{$v.created_at}}</td>
+							<td class="view-operation">
+								<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:U('Admin/User/Delete')}}" data-am-popover="{content: '{{:L('common_operation_delete')}}', trigger: 'hover focus'}" data-id="{{$v.user_id}}"></button>
+							</td>
+						</tr>
+					</foreach>
+				<else />
+					<tr><td colspan="10" class="table-no">{{:L('common_not_data_tips')}}</td></tr>
+				</if>
+			</tbody>
+		</table>
+		<!-- list end -->
+
+		<!-- page start -->
+		<div id="pages" class="p">{{$page}}</div>
+	</div>
+</div>
+<script src="__PUBLIC__/Admin/Default/Js/lyz.calendar.min.js" type="text/javascript"></script>
+<script type="text/javascript">
+			data_list(2);
+			$('.watch_list').click(function(){
+			var value = $('.watch_list').attr('data');
+			data_list(value);
+			});
+			var chart;
+			$(document).ready(function() {
+				chart = new Highcharts.Chart({
+					chart: {
+						renderTo: 'container',
+						defaultSeriesType: 'line',
+						marginRight: 130,
+						marginBottom: 25
+					},
+					
+					title: {//标题
+						text: '新增设备用户',
+						x: -20 //center
+					},
+//					subtitle: {//副标题
+//						text: 'Source: WorldClimate.com',
+//						x: -20
+//					},
+					xAxis: {//x轴
+						categories: [<volist name="user_data" id="vo">'{{$vo.time}}',</volist>]
+					},
+					yAxis: {//y轴项
+						title: {
+							text: '新增数量'
+						},
+						plotLines: [{
+							value: 0,
+							width: 1,
+							color: '#808080'
+						}]
+					},
+					tooltip: {//鼠标移动位置提示
+						formatter: function() {
+				                return '<b>'+ this.series.name +'</b><br/>'+
+                               this.x +'<br/>'+ 
+                                Highcharts.numberFormat(this.y,0)+'人';
+						}
+					},
+					legend: {//设置图表向右对齐
+						layout: 'vertical',
+						align: 'right',
+						verticalAlign: 'top',
+						x: -10,
+						y: 100,
+						borderWidth: 0
+					},
+					series: [{//数据
+						name:'新增设备用户',
+						data:[<volist name="user_data" id="vo">{{$vo.total}},</volist>]
+					}]
+				});
+				
+			});
+		$("select[name='type']").change(function(){
+			var type = $(this).val();
+			if(type ==2 || type ==3){
+				$(".yearset").css('display','inline-block');
+				$(".monthset").css('display','none');
+			}else{
+				$(".yearset").css('display','inline-block');
+				$(".monthset").css('display','inline-block');
+			}
+		});
+		function check(obj){
+			$('.checksearch li').removeClass('checkin');
+			$(obj).addClass('checkin');
+		}
+		function data_list($value){
+			if($value == 1){//列表展示
+				$('.data_list').css('display','block');
+				$('.watch_list').attr('data','2');
+				$('.watch_list').text('隐藏列表');
+			}else{
+				$('.data_list').css('display','none');
+				$('.watch_list').attr('data','1');
+				$('.watch_list').text('显示列表');
+			}
+		}
+</script>
+<!-- right content end  -->
+<script>
+	jeDate("input[name=time]",{
+		//onClose:false,
+		format: "YYYY-MM-DD"
+	});
+</script>
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end

+ 96 - 0
Application/Admin/View/Default/Statistic/orderData.html

@@ -0,0 +1,96 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+	<h3>不要一次查询超过14天的数据</h3>
+	</div>
+	<div class="content">
+		<form class="am-form view-list" action="{{:U('Admin/Statistic/orderCheck')}}" method="POST" id="form1">
+			<div class="am-g">
+				<div style="width:500px;display: inline-block;">
+					<label>时间:</label>
+					<input name="start_time" class="datebb"  value="{{$start_time}}" autocomplete="off" style="width:20rem;border-left: 0.1rem solid;" />~
+					<input name="end_time" class="datebb" value="{{$end_time}}" autocomplete="off" style="width: 20rem;border-left: 0.1rem solid;" />
+				</div>
+				<button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit">查询</button>
+				<a href="#" class="am-btn am-btn-danger am-btn-xs" onclick="exportData();">导出</a>
+			</div>
+
+		</form>
+
+	</div>
+		<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
+			<thead>
+			<tr>
+				<th>序号</th>
+				<th class="am-hide-sm-only">时间</th>
+				<th class="am-hide-sm-only">pv</th>
+				<th class="am-hide-sm-only">uv</th>
+				<th class="am-hide-sm-only">订购数</th>
+				<th class="am-hide-sm-only">退订数</th>
+				<th class="am-hide-sm-only">预订购(去重)</th>
+				<th class="am-hide-sm-only">预订购总数</th>
+				<th class="am-hide-sm-only">播放总时长(秒)</th>
+				<th class="am-hide-sm-only">新增用户</th>
+				<th class="am-hide-sm-only">累计用户</th>
+<!--				<th>{{:L('common_operation_name')}}</th>-->
+			</tr>
+			</thead>
+			<tbody>
+			<if condition="!empty($data)">
+				<foreach name="data" item="v">
+					<tr id="data-list-{{$v.id}}">
+						<td class="am-hide-sm-only">{{$key+1}}</td>
+						<td class="am-hide-sm-only">{{$v.date}}</td>
+						<td class="am-hide-sm-only">{{$v.pv|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.uv|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.order|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.cancel_order|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.pre_order|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.pre_order_count|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.play_time_sum|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.add_user|default=0}}</td>
+						<td class="am-hide-sm-only">{{$v.user_sum|default=0}}</td>
+<!--						<td class="view-operation">-->
+<!--							<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:U('Admin/SourceOrigin/Delete')}}" data-am-popover="{content: '{{:L('common_operation_delete')}}', trigger: 'hover focus'}" data-id="{{$v.id}}"></button>-->
+<!--						</td>-->
+					</tr>
+				</foreach>
+				<else />
+				<tr><td colspan="10" class="table-no">{{:L('common_not_data_tips')}}</td></tr>
+			</if>
+			</tbody>
+		</table>
+		<!-- list end -->
+
+		<!-- page start -->
+		<if condition="!empty($List)">
+			{{$page_html}}
+		</if>
+		<!-- page end -->
+	</div>
+</div>
+<!-- right content end  -->
+<script>
+	function exportData(){
+		var form =  $('#form1').serialize();
+		var url = './index.php?m=Admin&c=Statistic&a=orderCheck&model=export&'+form;
+		window.location.href = url;
+	}
+	jeDate("input[name=start_time]",{
+		//onClose:false,
+
+		format: "YYYY-MM-DD 00:00:00"
+	});
+	jeDate("input[name=end_time]",{
+		//onClose:false,
+
+		format: "YYYY-MM-DD 23:59:59"
+	});
+</script>
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end

+ 177 - 0
Application/Admin/View/Default/Statistic/total.html

@@ -0,0 +1,177 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+<style>
+	.statistic{clear: both;}
+	.st_le{display: inline-block;}
+	.st_le p{    width: 14rem;
+    padding-right: 0.5rem;
+    float: left;
+    border: solid #333 1px;
+    height: 11rem;
+    margin-right: .5rem; padding: .5rem}
+    .st_le span{ display: block; clear: both; }
+</style>
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+		<!-- form start -->
+		<form class="am-form view-list" action="{{:U('Admin/Statistic/total')}}" method="POST">
+			<div class="am-g">
+				<div style="width:500px;display: inline-block;">
+				<label>时间:</label>
+				  (含)<input name="start_time" class="datebb"  value="{{$start_time}}" autocomplete="off" style="width:12rem;border-left: 0.1rem solid;" />~
+				  (含)<input name="end_time" class="datebb" value="{{$end_time}}" autocomplete="off" style="width: 12rem;border-left: 0.1rem solid;" />
+				</div>
+				<button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit">查询</button>
+			</div>
+        </form>
+        <!-- form end -->		
+		<div class="statistic">
+            <!--<?php var_dump($source_type_names);?>-->
+			<div class="st_le">
+				<span >总&nbsp;&nbsp;计:</span>
+				<p>总用户数: {{$mk['userAll_num']}}
+					<if condition="$mk['userAll']">
+						<foreach name="mk['userAll']" item="vo" >
+							<br/>
+							(来源){{$vo.user_origin}}:{{$vo.total}}
+						</foreach>
+					</if>
+				</p>
+				<p>总订购数:{{$mk['payAll_num']}}
+					<if condition="$mk['payAll']">
+						<foreach name="mk['payAll']" item="vo" >
+							<br/>
+							(来源){{$vo.user_origin}}:{{$vo.total}}
+						</foreach>
+					</if>
+				</p>
+				<p>转化率:{{$mk['FeeAll_num']}}%
+					<if condition="$mk['FeeAll']">
+						<foreach name="mk['FeeAll']" item="vo" k="key">
+							<br/>
+							(来源){{$key}}:{{$vo}}%
+						</foreach>
+					</if>
+				</p>
+			
+				<span >条件统计:</span>
+                                <p style="color:red">新增用户:{{$mk['userUvNew_num']}}
+									<if condition="$mk['userUvNew']">
+										<foreach name="mk['userUvNew']" item="vo" >
+											<br/>
+											(来源){{$vo.user_origin}}:{{$vo.total}}
+										</foreach>
+									</if>
+								</p>
+                                <p style="color:red">未订购访问用户:{{$mk['noVipUv_num']}}
+									<if condition="$mk['noVipUv']">
+										<foreach name="mk['noVipUv']" item="vo" k="key">
+											<br/>
+											(来源){{$key}}:{{$vo}}
+										</foreach>
+									</if>
+								</p>
+                                <p style="color:red">已订购访问用户:{{$mk['vipAllUv_num']}}
+									<if condition="$mk['vipAllUv']">
+										<foreach name="mk['vipAllUv']" item="vo" k="key">
+											<br/>
+											(来源){{$key}}:{{$vo}}
+										</foreach>
+									</if>
+								</p>
+				<p style="color:red">订购数:{{$mk['UpayAll_num']}}
+					<if condition="$mk['UpayAll']">
+						<foreach name="mk['UpayAll']" item="vo" >
+							<br/>
+							(来源){{$vo.user_origin}}:{{$vo.total}}
+						</foreach>
+					</if>
+				</p>
+
+				<p style="color:red">综合转化率:{{$mk['UserFee_num']}}%
+					<if condition="$mk['UserFee']">
+						<foreach name="mk['UserFee']" item="vo" k="key">
+							<br/>
+							(来源){{$key}}:{{$vo}}%
+						</foreach>
+					</if>
+				</p>
+				<p style="color:red">uv:{{$mk['userUv_num']}}
+					<if condition="$mk['userUv']">
+						<foreach name="mk['userUv']" item="vo" k="key">
+							<br/>
+							(来源){{$key}}:{{$vo}}
+						</foreach>
+					</if>
+				</p>
+				<p style="color:red">pv:{{$mk['pageView_num']}}
+					<if condition="$mk['pageView']">
+						<foreach name="mk['pageView']" item="vo" k="key">
+							<br/>
+							(来源){{$key}}:{{$vo}}
+						</foreach>
+					</if>
+				</p>
+				<p style="color:red">预订购数去重
+						<foreach name="mk['repare_order']" item="vo" k="key">
+							<br/>
+							(来源){{$vo['user_origin']}}:{{$vo.total}}
+						</foreach>
+				</p>
+				<p style="color:red">退订数
+					<foreach name="mk['cancel_order']" item="vo" k="key">
+						<br/>
+						(来源){{$vo['user_origin']}}:{{$vo.total}}
+					</foreach>
+				</p>
+			</div>
+		</div>
+
+		<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
+			<thead>
+			<tr>
+				<th>序号</th>
+				<th class="am-hide-sm-only">产品包名</th>
+				<th class="am-hide-sm-only">产品ID</th>
+				<th class="am-hide-sm-only">订购数</th>
+			</tr>
+			</thead>
+			<tbody>
+			<if condition="!empty($mk['order_details'])">
+				<?php
+					$products = C('products');
+				?>
+				<foreach name="mk['order_details']" item="v" key="k">
+					<tr id="data-list-{{$k}}">
+						<td class="am-hide-sm-only">{{++$k}}</td>
+						<td class="am-hide-sm-only">{{$products[$v['product_id']]['name']}}</td>
+						<td class="am-hide-sm-only">{{$v.product_id}}</td>
+						<td class="am-hide-sm-only">{{$v.total}}</td>
+					</tr>
+				</foreach>
+				<else />
+				<tr><td colspan="10" class="table-no">{{:L('common_not_data_tips')}}</td></tr>
+			</if>
+			</tbody>
+		</table>
+		<!-- page end -->
+	</div>
+</div>
+<!-- right content end  -->
+<script>
+    jeDate("input[name=start_time]",{
+        //onClose:false,
+        
+        format: "YYYY-MM-DD"
+    });
+    jeDate("input[name=end_time]",{
+        //onClose:false,
+        
+        format: "YYYY-MM-DD"
+    });
+</script>	
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end