Browse Source

Merge branch 'master' of http://120.78.169.79:3000/xusong_hc/tp3_activity

Wang 5 years ago
parent
commit
76ac574ee6

+ 1 - 5
Application/Admin/Controller/CollectController.class.php

@@ -67,21 +67,17 @@ class CollectController extends CommonController {
                 ->limit($offset,$listRows)
                 ->limit($offset,$listRows)
                 ->select();
                 ->select();
         $activitys = M('activity_v2')->where(['id'=>$act_id])->find();
         $activitys = M('activity_v2')->where(['id'=>$act_id])->find();
-        foreach($activitys as $row){
-            $activity_info[$row['id']] = ['activity_name'=>$row['activity_name']];
-        }
         if($activitys['collect_list']){
         if($activitys['collect_list']){
             $collects = json_decode($activitys['collect_list'],true);
             $collects = json_decode($activitys['collect_list'],true);
             $collects = array_column($collects, null,'collect_id');
             $collects = array_column($collects, null,'collect_id');
         }
         }
 
 
         foreach ($List as $key=>$row) {
         foreach ($List as $key=>$row) {
-            $List[$key]['activity_name'] = $activity_info[$row['act_id']]['activity_name'];
+            $List[$key]['activity_name'] = $activitys['activity_name'];
             if($collects){
             if($collects){
                 $List[$key]['collect_name']  = $collects[$row['collect_id']]['collect_name'];
                 $List[$key]['collect_name']  = $collects[$row['collect_id']]['collect_name'];
             }
             }
         }
         }
-//        var_dump($List);die;
         $count = $this->table->where($where)->count();
         $count = $this->table->where($where)->count();
         $Page = new \Think\Page($count, $listRows);
         $Page = new \Think\Page($count, $listRows);
         $Page->parameter .= "&p=[PAGE]";
         $Page->parameter .= "&p=[PAGE]";

+ 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();
+    }
+	
+}

+ 110 - 0
Application/Admin/Controller/ThemeController.class.php

@@ -0,0 +1,110 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 样式管理
+ * @author   xusong
+ * @version  0.0.1
+ */
+class ThemeController extends CommonController {
+
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+
+    public function _initialize() {
+        // 调用父类前置方法
+        parent::_initialize();
+        // 登录校验
+        $this->Is_Login();
+        // 权限校验
+        $this->Is_Power();
+        //要执行的表
+    }
+
+    /**
+     * 主题列表
+     * @author   Devil
+     */
+    public function Index() {
+        $List = M('theme')->order('id desc')->select();
+        $this->assign('List', $List);
+        $this->display('Index');
+    }
+
+    /**
+     * [SaveInfo 文章添加/编辑页面]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function SaveInfo() {
+        $data = M('theme')->find(I('id'));
+        $this->assign('data', $data);
+        $this->display($data['view']);
+    }
+
+    /**
+     * [Save 文章添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function Save() {
+        if (!IS_AjAX) {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        $data['name'] = trim(I('name'));
+        $data['type'] = trim(I('type'));
+        // 添加
+        if ($id = I('id')) {
+            $data['id'] = $id;
+            if (M('theme')->save($data)) {
+                $this->ajaxReturn('更新成功');
+            } else {
+                $this->ajaxReturn('更新失败',400);
+            }
+        } else {
+            $data['created_at'] = date('Y-m-d H:i:s');
+            if ($bool=M('theme')->add($data)) {
+                $this->ajaxReturn('新增成功');
+            } else {
+                echo M()->getLastSql();
+                $this->ajaxReturn('新增失败',400);
+            }
+        }
+
+
+    }
+
+    /**
+     * [Delete 删除]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-15T11:03:30+0800
+     */
+    public function Delete() {
+        // 是否ajax请求
+        if (!IS_AJAX) {
+            $this->error(L('common_unauthorized_access'));
+        }
+        // 删除数据
+        if (I('id')) {
+            // 更新
+            if (M('theme')->delete(I('id'))) {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+
+}

+ 12 - 0
Application/Admin/View/Default/Lib/IsShow.html

@@ -0,0 +1,12 @@
+<!-- 是否显示 开始 -->
+<div class="am-form-group">
+	<label>{{:L('common_view_is_show_title')}}</label>
+	<div>
+		<foreach name="common_is_show_list" item="v">
+			<label class="am-radio-inline m-r-10">
+				<input type="radio" name="is_show" value="{{$v.id}}" <if condition="isset($data['is_show']) and $data['is_show'] eq $v['id']">checked="checked"<else /><if condition="!isset($data['is_show']) and isset($v['checked']) and $v['checked'] eq true">checked="checked"</if></if> data-am-ucheck /> {{$v.name}}
+			</label>
+		</foreach>
+	</div>
+</div>
+<!-- 是否显示 结束 -->

+ 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

+ 76 - 0
Application/Admin/View/Default/Theme/Index.html

@@ -0,0 +1,76 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+        <form class="am-form view-list" id="form" action="{{:U('Admin/Theme/Save')}}" method="POST">
+            <div class="am-g">
+                <label>名称</label>
+                <input type="text" required="required" class="am-radius form-keyword" style="width: 20rem;display: inline-block;" placeholder="活动名称" name="name"/>
+				<label>类型</label>
+				<select name="type" id="type" style="display: inline-block;width: 10rem;margin-right: 1rem;">
+					<option value="1" <if condition="isset($type) && $type eq 1">selected</if>>活动</option>
+					<option value="2" <if condition="isset($type) && $type eq 2">selected</if>>专题</option>
+				</select>
+                <button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit">增加</button>
+            </div>
+        </form>
+		<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">ThemeID</th>
+					<th class="am-hide-sm-only">名称</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>{{:L('common_operation_name')}}</th>
+				</tr>
+			</thead>
+			<tbody>
+				<if condition="!empty($List)">
+					<foreach name="List" item="v">
+						<tr id="data-list-{{$v.id}}">
+							<input type="hidden" value="{{$v.id}}" />
+							<td class="am-hide-sm-only">{{$key+1}}</td>
+							<td class="am-hide-sm-only">{{$v.id}}</td>
+							<td class="am-hide-sm-only">{{$v.name}}</td>
+							<td class="am-hide-sm-only">
+								<?php
+									if($v['type'] == 1){
+										echo "活动";
+									}elseif($v['type'] == 2){
+										echo "专题";
+									}
+								?>
+							</td>
+							<td class="am-hide-sm-only">{{$v.page_view}}</td>
+							<td class="am-hide-sm-only">{{$v.user_view}}</td>
+							<td class="am-hide-sm-only">{{$v.data_update}}</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/Theme/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  -->
+		
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end

+ 25 - 356
Application/Home/Controller/CommonController.class.php

@@ -35,18 +35,6 @@ class CommonController extends Controller
 	{
 	{
 		// 配置信息初始化
 		// 配置信息初始化
 		MyConfigInit();
 		MyConfigInit();
-
-		// 公共数据初始化
-		$this->CommonInit();
-
-		// 菜单
-		$this->NavInit();
-
-		// 视图初始化
-		$this->ViewInit();
-
-		// 站点状态校验
-		$this->SiteStateCheck();
 	}
 	}
 
 
 	/**
 	/**
@@ -117,352 +105,33 @@ class CommonController extends Controller
 		}
 		}
 	}
 	}
 
 
-	/**
-	 * [ViewInit 视图初始化]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2016-12-03T12:30:06+0800
-	 */
-	public function ViewInit()
-	{
-		// 主题
-		$default_theme = C('DEFAULT_THEME');
-		$this->assign('default_theme', $default_theme);
-
-		// 控制器静态文件状态css,js
-		$module_css = MODULE_NAME.DS.$default_theme.DS.'Css'.DS.CONTROLLER_NAME.'.css';
-		$this->assign('module_css', file_exists(ROOT_PATH.'Public'.DS.$module_css) ? $module_css : '');
-		$module_js = MODULE_NAME.DS.$default_theme.DS.'Js'.DS.CONTROLLER_NAME.'.js';
-		$this->assign('module_js', file_exists(ROOT_PATH.'Public'.DS.$module_js) ? $module_js : '');
-
-		// 导航
-		$this->assign('nav_header', $this->nav_header);
-		$this->assign('nav_footer', $this->nav_footer);
-
-		// 当前页面选择导航状态
-		$nav_pid	=	0;
-		$nav_id 	=	0;
-		foreach($this->nav_header as $v)
-		{
-			if(I('viewid') == $v['id'])
-			{
-				$nav_id = $v['id'];
-			}
-			if(!empty($v['item']))
-			{
-				foreach($v['item'] as $vs)
-				{
-					if(I('viewid') == $vs['id'])
-					{
-						$nav_pid = $v['id'];
-						$nav_id = $vs['id'];
-					}
-				}
-			}
-		}
-		$this->assign('nav_pid', $nav_pid);
-		$this->assign('nav_id', $nav_id);
-
-		// 图片host地址
-		$this->assign('image_host', C('IMAGE_HOST'));
-
-		// 标题
-		$this->assign('home_seo_site_title', MyC('home_seo_site_title'));
-
-		// 页面最大宽度
-		$max_width = MyC('home_content_max_width', 0, true);
-		$max_width_style = ($max_width == 0) ? '' : 'max-width:'.$max_width.'px;';
-		$this->assign('max_width_style', $max_width_style);
-
-		// 用户数据
-		$this->assign('user', $this->user);
-
-		// 用户中心菜单
-		$this->assign('user_left_menu', L('user_left_menu'));
-
-		// 用户顶部菜单
-		$this->assign('user_nav_menu', L('user_nav_menu'));
-	}
-
-	/**
-	 * [NavInit 导航初始化]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2016-12-19T22:41:20+0800
-	 */
-	private function NavInit()
-	{
-		// 读取缓存数据
-		$this->nav_header = S(C('cache_common_home_nav_header_key'));
-		$this->nav_footer = S(C('cache_common_home_nav_footer_key'));
-
-		// 导航模型
-		$m = M('Navigation');
-		$field = array('id', 'pid', 'name', 'url', 'value', 'data_type', 'is_new_window_open');
-
-		// 缓存没数据则从数据库重新读取,顶部菜单
-		if(empty($this->nav_header))
-		{
-			$this->nav_header = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
-			if(!empty($this->nav_header))
-			{
-				foreach($this->nav_header as $k=>$v)
-				{
-					$this->nav_header[$k]['item'] = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
-				}
-			}
-			S(C('cache_common_home_nav_header_key'), $this->nav_header);
-		}
-
-		// 底部导航
-		if(empty($this->nav_footer))
-		{
-			$this->nav_footer = NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer', 'is_show'=>1))->order('sort')->select());
-			S(C('cache_common_home_nav_footer_key'), $this->nav_footer);
-		}
-	}
-
-	/**
-	 * [GetClassList 获取班级列表,二级]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2016-12-30T13:26:00+0800
-	 * @return [array] [班级列表]
-	 */
-	protected function GetClassList()
-	{
-		$m = M('Class');
-		$data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select();
-		if(!empty($data))
-		{
-			foreach($data as $k=>$v)
-			{
-				$data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select();
-			}
-		}
-		return $data;
-	}
-
-	/**
-	 * [GetRoomList 获取教室列表,二级]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2016-12-30T13:26:00+0800
-	 * @return [array] [班级列表]
-	 */
-	protected function GetRoomList()
-	{
-		$m = M('Room');
-		$data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select();
-		if(!empty($data))
-		{
-			foreach($data as $k=>$v)
-			{
-				$data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select();
-			}
-		}
-		return $data;
-	}
-
-	/**
-	 * [GetLayoutList 获取布局-模块列表]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2017-02-22T10:15:40+0800
-	 * @param  [string] $type [布局类型(home, channel, detail)]
-	 * @return [array]        [布局+模块数据]
-	 */
-	protected function GetLayoutList($type = 'home')
-	{
-		// 布局+模块列表
-		$data = M('Layout')->field(array('id', 'value'))->where(array('is_enable'=>1, 'type'=>$type))->order('sort asc, id desc')->select();
-		if(!empty($data))
-		{
-			// 布局模块处理驱动
-			$lay = \My\LayoutModule::SetInstance();
-
-			// 开始处理布局数据
-			foreach($data as $k=>$v)
-			{
-				// 模块
-				$item = M('LayoutModule')->where(array('layout_id'=>$v['id']))->select();
-				if(!empty($item))
-				{
-					foreach($item as $ik=>$iv)
-					{
-						// 获取文章数据
-						$article = LayoutArticleList($lay->GetLayoutMouleWhere($iv), $iv);
-
-						// 模块数据生成
-						$fun = GetViewTitleStyleFun($iv['title_style']);
-						if(method_exists($lay, $fun))
-						{
-							$html = $lay->$fun($article, $iv);
-							$iv = $lay->GetRules();
-						} else {
-							$html = '';
-						}
-
-						// 重新赋值
-						$item[$ik] = $html;
-
-						// 模板赋值
-						$this->assign('data_'.$iv['id'], $article);
-						$this->assign('rules_'.$iv['id'], $iv);
-					}
-				}
-				$data[$k]['item'] = $item;
-			}
-		}
-		return $data;
-	}
-
-	/**
-	 * [GetBrowserSeoTitle 获取浏览器seo标题]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2017-02-25T14:21:21+0800
-	 * @param    [string]     $title [标题]
-	 * @param    [int]     	  $type  [页面类型 0, 1, 2]
-	 * @return   [string]            [浏览器seo标题]
-	 */
-	protected function GetBrowserSeoTitle($title, $type)
-	{
-		switch($type)
-		{
-			case 0:
-				break;
-
-			case 1:
-				$site_name = MyC('home_site_name');
-				break;
-
-			default:
-				$site_name = MyC('home_seo_site_title');
-		}
-		return empty($title) ? $site_name : $title.' - '.$site_name;
-	}
-
-	/**
-	 * [_empty 空方法操作]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2017-02-25T15:47:50+0800
-	 * @param    [string]      $name [方法名称]
-	 */
-	protected function _empty($name)
-	{
-		$this->assign('msg', L('common_unauthorized_access'));
-		$this->assign('is_footer', 0);
-		$this->display('/Public/Error');
-	}
-
-	/**
-	 * [SiteStateCheck 站点状态校验]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2017-02-25T21:43:07+0800
-	 */
-	private function SiteStateCheck()
-	{
-		if(MyC('home_site_state') == 0)
-		{
-			$this->assign('msg', MyC('home_site_close_reason', L('common_site_maintenance_tips'), true));
-			$this->assign('is_footer', 0);
-			$this->display('/Public/Error');
-			exit;
-		}
-	}
-
-	/**
-	 * [CommonIsImaVerify 是否开启图片验证码校验]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2017-03-22T15:48:31+0800
-	 * @param    [array] $verify_param [配置参数]
-	 * @return   [object]              [图片验证码类对象]
-	 */
-	protected function CommonIsImaVerify($verify_param)
-	{
-		if(MyC('home_img_verify_state') == 1)
-		{
-			if(empty($_POST['verify']))
-			{
-				$this->ajaxReturn(L('common_param_error'), -10);
-			}
-			$verify = new \My\Verify($verify_param);
-			if(!$verify->CheckExpire())
-			{
-				$this->ajaxReturn(L('common_verify_expire'), -11);
-			}
-			if(!$verify->CheckCorrect(I('verify')))
-			{
-				$this->ajaxReturn(L('common_verify_error'), -12);
-			}
-			return $verify;
-		}
-	}
-
-	/**
-	 * [CommonVerifyEntry 验证码显示]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2017-03-05T15:10:21+0800
-	 * @param    [string] $type [验证码类型]
-	 */
-	protected function CommonVerifyEntry($type = 'schoolcms')
-	{
-		$param = array(
-				'width' => 100,
-				'height' => 32,
-				'key_prefix' => $type,
-			);
-		$verify = new \My\Verify($param);
-		$verify->Entry();
-	}
+    /**
+     * 成功时返回
+     * @param unknown $data
+     * @param string $msg
+     * @author brent
+     */
+    protected function responseSuccess($data = [], $msg = 'sueccess') {
+        $data = empty($data) ? ['success'=>'success'] : $data;
+        $response = ['code' => 0, 'msg' => $msg, 'data' => $data];
+        echo json_encode($response,JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+    
 
 
-	/**
-	 * [UserLoginRecord 用户登录记录]
-	 * @author   Devil
-	 * @blog     http://gong.gg/
-	 * @version  0.0.1
-	 * @datetime 2017-03-09T11:37:43+0800
-	 * @param    [int]     $user_id [用户id]
-	 * @return   [boolean]          [记录成功true, 失败false]
-	 */
-	protected function UserLoginRecord($user_id = 0)
-	{
-		if(!empty($user_id))
-		{
-			$field = array('id', 'mobile', 'email', 'nickname', 'gender', 'signature', 'describe', 'birthday', 'add_time', 'upd_time');
-			$user = M('User')->field($field)->find($user_id);
-			if(!empty($user))
-			{
-				// 基础数据处理
-				$user['add_time_text']	=	date('Y-m-d H:i:s', $user['add_time']);
-				$user['upd_time_text']	=	date('Y-m-d H:i:s', $user['upd_time']);
-				$user['gender_text']	=	L('common_gender_list')[$user['gender']]['name'];
-				$user['birthday_text']	=	empty($user['birthday']) ? '' : date('Y-m-d', $user['birthday']);
-				$user['mobile_security']=	empty($user['mobile']) ? '' : substr($user['mobile'], 0, 3).'***'.substr($user['mobile'], -3);
-				$user['email_security']	=	empty($user['email']) ? '' : substr($user['email'], 0, 3).'***'.substr($user['email'], -3);
+    /**
+     * 失败时返回
+     * @param unknown $msg
+     * @param unknown $code
+     * @author brent
+     */
+    protected function responseError($msg, $code = -1,array $data = ['error'=>'error']) {
+        $response = ['code' => $code, 'msg' => $msg, 'data' => $data];
+
+        echo json_encode($response,JSON_UNESCAPED_UNICODE);
+        exit();
+    }
 
 
-				// 存储session
-				$_SESSION['user'] = $user;
-				return !empty($_SESSION['user']);
-			}
-		}
-		return false;
-	}
 
 
     protected function http($url, $method = 'GET', $postfields = null, $headers = array(), $debug = false) {
     protected function http($url, $method = 'GET', $postfields = null, $headers = array(), $debug = false) {
         $ci = curl_init();
         $ci = curl_init();

+ 7 - 9
Application/Home/Controller/IndexController.class.php

@@ -31,15 +31,13 @@ class IndexController extends CommonController
 	 * @version  0.0.1
 	 * @version  0.0.1
 	 * @datetime 2017-02-22T16:50:32+0800
 	 * @datetime 2017-02-22T16:50:32+0800
 	 */
 	 */
-	public function Index()
-	{
-		// 布局+模块列表
-		$this->assign('data', $this->GetLayoutList('home'));
-
-		// 友情链接
-		$this->assign('link', LayoutLink('home', 1));
+    public function Index()
+    {
 
 
-		$this->display('Index');
-	}
+        $url = '/admin.php?m=Admin&c=Admin&a=LoginInfo';
+        echo "<script language='javascript' type='text/javascript'>";
+        echo "window.location.href='" . $url . "'";
+        echo "</script>";
+    }
 }
 }
 ?>
 ?>

+ 2 - 2
Application/Home/Controller/OrderController.class.php

@@ -22,9 +22,9 @@ class OrderController extends CommonController {
         $map['usertoken'] = I('usertoken');
         $map['usertoken'] = I('usertoken');
         $map['version'] = I('version');
         $map['version'] = I('version');
         $map['mac'] = I('mac');
         $map['mac'] = I('mac');
-        $map['fromsource'] = 4;
+        $map['fromsource'] = 15;
         $prame = http_build_query($map);
         $prame = http_build_query($map);
-        $url = 'http://10.255.0.55:8082/SPM/Interface/ContentCTCAuth.action?' . $prame;
+        $url = 'http://183.215.118.129:6600/SPM/Interface/ContentCmccAuth.action?' . $prame;
 
 
         // \Think\Log::record('-------contentCTCAuth url------' . $url, \Think\Log::INFO); //记录参数
         // \Think\Log::record('-------contentCTCAuth url------' . $url, \Think\Log::INFO); //记录参数
         $result = $this->http($url);
         $result = $this->http($url);

+ 56 - 0
Application/Home/Controller/ThemeDataController.class.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace Home\Controller;
+
+use Think\Model;
+
+/**
+ * @author   Xusong
+ */
+class ThemeDataController extends CommonController {
+
+    public function _initialize() {
+        // 调用父类前置方法
+        parent::_initialize();
+    }
+
+    /**
+     * 新增主题运营数据
+     */
+    public function addData()
+    {
+        $uid            = I('uid');
+        $theme_id       = I('theme_id',0,'intval');
+        $user_origin    = I('user_origin');
+
+
+        $insertData = array(
+            'uid'           =>$uid,
+            'theme_id'      =>$theme_id,
+            'user_origin'   =>$user_origin,
+            'created_at'    =>date('Y-m-d H:i:s'),
+            'date'          =>date('Ymd')
+        );
+
+        if(!$theme_data = M('theme')->where(['id'=>$theme_id])->find()){
+            $this->responseError('params invalid');
+        }
+
+        //汇总数据更新
+        if(M('theme_detail')->where(['uid'=>$uid,'theme_id'=>$theme_id])->find()){
+            //如果数据存在,只更新pv,不更新uv
+            $update['page_view'] = $theme_data['page_view'] + 1;
+            M('theme')->where(['id'=>$theme_id])->save($update);
+        }else{
+            //如果数据存在,更新pv,更新uv
+            $update['page_view'] = $theme_data['page_view'] + 1;
+            $update['user_view'] = $theme_data['user_view'] + 1;
+            M('theme')->where(['id'=>$theme_id])->save($update);
+        }
+        if(!M('theme_detail')->add($insertData)){
+            echo M()->getLastSql();
+        }
+        $this->responseSuccess();
+    }
+
+}

+ 6 - 6
Application/Home/Logic/Activityv2/Collect2Logic.class.php

@@ -78,7 +78,7 @@ class Collect2Logic extends BaseLogic
             $update['user_phone']= $phone;
             $update['user_phone']= $phone;
             $update['updated_at']= date('Y-m-d H:i:s');
             $update['updated_at']= date('Y-m-d H:i:s');
             if(M('activity_user_v2')->where(['id'=>$id])->save($update)===false){
             if(M('activity_user_v2')->where(['id'=>$id])->save($update)===false){
-                Writelog(M()->getLastSql(),'sql','prize');
+                Writelog(M()->getLastSql(),'sql','activityv2');
                 $this->responseError("更新失败!");
                 $this->responseError("更新失败!");
             }
             }
         }else{
         }else{
@@ -90,7 +90,7 @@ class Collect2Logic extends BaseLogic
                 'updated_at'=>date('Y-m-d H:i:s')
                 'updated_at'=>date('Y-m-d H:i:s')
             );
             );
             if(!M('activity_user_v2')->add($insert_data)){
             if(!M('activity_user_v2')->add($insert_data)){
-                Writelog(M()->getLastSql(),'sql','prize');
+                Writelog(M()->getLastSql(),'sql','activityv2');
                 $this->responseError("登记失败!");                
                 $this->responseError("登记失败!");                
             }
             }
         }
         }
@@ -124,7 +124,7 @@ class Collect2Logic extends BaseLogic
             $update['receiver'] = $receiver;
             $update['receiver'] = $receiver;
             $update['updated_at'] = date('Y-m-d H:i:s');            
             $update['updated_at'] = date('Y-m-d H:i:s');            
             if(M('activity_user_v2')->where(['id'=>$id])->save($update)===false){
             if(M('activity_user_v2')->where(['id'=>$id])->save($update)===false){
-                Writelog(M()->getLastSql(),'sql','prize');
+                Writelog(M()->getLastSql(),'sql','activityv2');
                 $this->responseError("更新失败!");
                 $this->responseError("更新失败!");
             }
             }
         }else{
         }else{
@@ -138,7 +138,7 @@ class Collect2Logic extends BaseLogic
                 'updated_at'=>date('Y-m-d H:i:s'),
                 'updated_at'=>date('Y-m-d H:i:s'),
             );
             );
             if(!M('activity_user_v2')->add($insert_data)){
             if(!M('activity_user_v2')->add($insert_data)){
-                Writelog(M()->getLastSql(),'sql','prize');
+                Writelog(M()->getLastSql(),'sql','activityv2');
                 $this->responseError("登记失败!");                
                 $this->responseError("登记失败!");                
             }
             }
         }
         }
@@ -303,7 +303,7 @@ class Collect2Logic extends BaseLogic
         if($collect_id_sum == $should_collect_sum){
         if($collect_id_sum == $should_collect_sum){
             $collect['complate'][] = array(
             $collect['complate'][] = array(
                 'exchange_id'=>1,
                 'exchange_id'=>1,
-                'collect_ids'=>implode(',',[1,2,3,4,5,6,7,8,9,10,11,12])
+                'collect_ids'=>implode(',',[1,2,3,4,5,6,7])
             );
             );
             // $collect['complate'][] = array(
             // $collect['complate'][] = array(
             //     'exchange_id'=>2,
             //     'exchange_id'=>2,
@@ -600,7 +600,7 @@ class Collect2Logic extends BaseLogic
         $log_data['rule_id'] = $result['rule_id'] ? : 0;
         $log_data['rule_id'] = $result['rule_id'] ? : 0;
         $log_data['prize_status'] = $result['prize_status'];
         $log_data['prize_status'] = $result['prize_status'];
         if(!M('prize_log_v2')->add($log_data)){
         if(!M('prize_log_v2')->add($log_data)){
-            Writelog(M()->getLastSql(),'sql','activity');
+            Writelog(M()->getLastSql(),'sql','activityv2');
             $this->responseError('系统繁忙抽奖失败', -1);
             $this->responseError('系统繁忙抽奖失败', -1);
         }      
         }      
     }
     }

+ 32 - 0
ThinkPHP/Common/functions.php

@@ -1548,3 +1548,35 @@ function think_filter(&$value){
 function in_array_case($value,$array){
 function in_array_case($value,$array){
     return in_array(strtolower($value),array_map('strtolower',$array));
     return in_array(strtolower($value),array_map('strtolower',$array));
 }
 }
+
+
+
+
+ /**
+ * 日志记录,按照"Ymd.log"生成当天日志文件
+ * 日志路径为:入口文件所在目录/logs/$type/当天日期.log.php,例如 /logs/error/20120105.log.php
+ * @param string $type 日志类型,对应logs目录下的子文件夹名
+ * @param string $content 日志内容
+ * @return bool true/false 写入成功则返回true
+ */
+function Writelog($content = "",$key="key",$type = "debug") {
+    if (!$content) {
+        return FALSE;
+    }
+    $dir = getcwd() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . $type;
+    
+    if (!is_dir($dir)) {
+        
+        if (!mkdir($dir)) {
+            
+            return false;
+        }
+    }
+    $filename = $dir . DIRECTORY_SEPARATOR . date("Ymd", time()) . '.log.txt';
+
+    $logs= array("time" => date("Y-m-d H:i:s"), $key => $content);
+     
+    $str = var_export($logs, true);
+    file_put_contents($filename,$str,FILE_APPEND);
+    return true;
+}