xiaosongshu007 5 роки тому
батько
коміт
2c25be08b6

+ 2 - 1
.gitignore

@@ -9,4 +9,5 @@ Logs
 logs
 *.lock
 Application/Common/Conf/master.php
-Public/Upload/*
+Public/Upload/*
+.idea

+ 12 - 2
Application/Admin/Controller/CleanPrizeLogController.class.php

@@ -54,12 +54,12 @@ class CleanPrizeLogController extends CommonController {
             $this->error(L('common_unauthorized_access'));
         }
         $act_id = I('act_id');
-        $actinfo = M('activity_v2')->field('id,prize_log_table')->find($act_id);
+        $actinfo = M('activity_v2')->find($act_id);
         if(!$actinfo){
             exit('相关活动不存在,清除数据失败');
         }
         //清理prize_log
-        if(false === M($actinfo['prize_log_table'])->where(['act_id'=>$actinfo['id']])->delete()){
+        if(false === M('prize_log_v2')->where(['act_id'=>$actinfo['id']])->delete()){
             exit(M()->getLastSql());
         }
 
@@ -83,6 +83,16 @@ class CleanPrizeLogController extends CommonController {
             exit(M()->getLastSql());
         }
 
+        //清理vip_vote
+        if(false === M('activity_vip_vote')->where(['act_id'=>$actinfo['id']])->delete()){
+            exit(M()->getLastSql());
+        }
+
+        //清理vote
+        if(false === M('activity_vote')->where(['act_id'=>$actinfo['id']])->delete()){
+            exit(M()->getLastSql());
+        }
+
         exit('清理活动数据成功');
     }
 

+ 385 - 0
Application/Admin/Controller/MengbaoController.class.php

@@ -0,0 +1,385 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 素材管理
+ * @author   brent
+ * @version  0.0.1
+ */
+class MengbaoController 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('activity_mengbao');
+    }
+
+    /**
+     * [Index 列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+    public function Index() {
+        $where = array();
+        $listRows = I('listRows') ? I('listRows') : 100;
+        $keyword = I("keyword", "", "trim");
+        $keyword && $where['name'] = array('like', '%' . $keyword . '%');
+        if (isset($keyword) && !empty($keyword)) {
+            $this->assign('keyword', $keyword);
+        }
+        
+//        var_dump(I('post.'));die;
+        $page = I('p') ? I('p') : 1;
+        $this->assign('p', $page);
+        $list = D('Admin/Mengbao')->get_mengbao_list($where, $page, $listRows, $count);
+        // echo "<pre>";
+        // var_dump($list);  die;  
+        //分页
+        $Page = new \Think\Page($count, $listRows);
+        $Page->parameter .= "&p=[PAGE]";
+        $Page->parameter .= "&listRows=" . $listRows;
+        $Page->parameter .= "&keyword=" .$keyword;
+        $Page = $this->page_config($Page);
+        $show = $Page->show();
+        $this->assign('page', $show);
+
+        $this->assign('List', $list);
+        $this->display('Index');
+    }
+
+        /**
+     * [ExcelExport excel文件导出]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2017-01-10T15:46:00+0800
+     */
+    public function ExcelExport()
+    {
+		$where = array();
+        $data = M('activity_mengbao')->where($where)->order('score desc , id asc')->select();
+
+		$title = array(
+			'id'						 =>	array('col' => 'A', 'name' => 'ID'),
+			'name'						 =>	array('col' => 'B', 'name' => '名字'),
+			'uid'						 =>	array('col' => 'C', 'name' => 'uid'),
+			'phone'					     =>	array('col' => 'D', 'name' => '联系人手机号'),
+			'score'					     =>	array('col' => 'E', 'name' => '得票数')
+		);
+        // Excel驱动导出数据
+        $excel = new \My\Excel(array('filename' => '萌宝排行榜', 'title' => $title, 'data' => $data, 'msg' => L('common_not_data_tips')));
+        $excel->Export();
+    }
+
+    /**
+     * [SaveInfo 文章添加/编辑页面]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function SaveInfo() {
+        // 文章信息
+        if (empty($_REQUEST['id'])) {
+            $data = array();
+        } else {
+            $data = $this->table->find(I('id'));
+            if (empty($data)) {
+                $data = array('id' => I('id'));
+            }
+        }
+        if ($_REQUEST['map']) {
+            $map = $_REQUEST['map'];
+        }
+        //素材列表
+        if (I('id')) {
+            $sourceList = M('activity_mengbao')->where(['id' => array('neq', I('id'))])->field('id as source_id,name as source_name')->select();
+        } 
+        $this->assign('sourceList', $sourceList);
+
+        $this->assign('data', $data);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 文章添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function Save() {
+        // 是否ajax请求
+        if (!IS_AJAX) {
+            $this->error(L('common_unauthorized_access'));
+        }
+        // 添加
+        if (empty($_POST['id'])) {
+            $this->Add();
+
+            // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 文章添加]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-18T16:20:59+0800
+     */
+    private function Add() {
+        $m = $this->table;
+        $data = array();
+        // 额外数据处理
+        // $data['created_at'] = date('Y-m-d H:i:s', time());
+        // $data['name'] = I('name');
+        // if ($data['name']) {
+        //     $data['first_string'] = $this->first_string($data['name']);
+        // }
+        $data['uid'] = I('uid');
+        $data['name'] = I('name');
+        $data['age'] = I('age');
+        $data['image'] = I('image');
+        $data['desc'] = I('desc');
+        $data['phone'] = I('phone');
+        $data['media_id'] = I('media_id');
+        $data['media_num'] = I('media_num');
+        $data['score'] = I('score');
+        $data['video'] = I('video');
+
+        // 数据添加
+        if ($m->add($data)) {
+            $this->ajaxReturn(L('common_operation_add_success'));
+        } else {
+            $this->ajaxReturn(L('common_operation_add_error'), -100);
+        }
+    }
+
+    /**
+     * [Edit 文章编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-17T22:13:40+0800
+     */
+    private function Edit() {
+        $m = $this->table;
+        $source_id = I('id');
+        $data = array();
+        // 额外数据处理
+        // $data['name'] = I('name');
+        // if ($data['name']) {
+        //     $data['first_string'] = $this->first_string($data['name']);
+        // }
+        $data['uid'] = I('uid');
+        $data['name'] = I('name');
+        $data['age'] = I('age');
+        $data['image'] = I('image');
+        $data['desc'] = I('desc');
+        $data['phone'] = I('phone');
+        $data['media_id'] = I('media_id');
+        $data['media_num'] = I('media_num');
+        $data['score'] = I('score');
+        $data['video'] = I('video');
+        // 数据更新
+
+        if (false !== $m->where(array('id' => I('id')))->save($data)) {
+            $this->ajaxReturn(L('common_operation_edit_success'));
+        } else {
+//             echo M()->getLastsql();die;
+            $this->ajaxReturn(L('common_operation_edit_error'), -100);
+        }
+    }
+
+    /**
+     * [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 (!empty($_POST['id'])) {
+            // 更新
+            if ($this->table->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);
+        }
+    }
+
+    public function importExcel()
+    {
+        $param['title'] = array(
+            "id"            => array('name' => 'id'),
+            "uid"           => array('name' => 'uid'),
+            "phone"         => array('name' => 'phone'),
+            "name"          => array('name' => 'name'),
+            "age"           => array('name' => 'age'),
+            "desc"          => array('name' => 'desc'),
+            'score'         => array('namr' => 'score'),
+            "image"         => array('name' => 'image'),
+            "video"         => array('name' => 'video'),
+            "media_id"      => array('name' => 'media_id'),
+            "media_num"     => array('name' => 'media_num'),
+        );
+        $excel       = new \My\Excel($param);
+        $excel_data        = $excel->Import($_FILES['excel']['tmp_name']);
+        $data        = array_filter($excel_data);
+        if(!$data){
+            $msg = "检查标题是否对应正确";
+            goto end;
+        }
+        $update_data = $insert_data = array();
+        foreach ($data as $index=>$row) {
+            $row_num = $index + 2;
+            if(!$row = array_filter($row)){
+                $msg = '检查数据行: '.$row_num;
+                goto end;
+            }
+            //存在ID即代表更新
+            if($row['id']){
+                if(count($row) > 1){
+                    //查看该素材是否存在,如果存在则更新,不存在则插入
+                    if(M('activity_mengbao')->where(['id'=>$row['id']])->find()){
+                        if(M('activity_mengbao')->save($row) === false){
+                            Writelog( M()->getLastSql(), 'errorsql', 'inserttag');
+                            $msg = '数据行更新失败: ' . $row_num . ' ,请告知技术进行处理';
+                            goto end;
+                        }
+                    }
+                }else{
+                    $msg = '检查数据行: '.$row_num;
+                    goto end;
+                }
+            }else{
+                //新插入时检查注入所必须字段
+                $must_fields = array('name','image','phone','uid');
+                foreach ($must_fields as $field) {
+                    if(!isset($row[$field])){
+                        $msg = '检查数据行: '.$row_num;
+                        goto end;
+                    }
+                }
+                // $row['first_string'] = $this->first_string($row['name']);//首字母
+                $row['created_at'] = date('Y-m-d H:i:s');
+                if(!M('activity_mengbao')->add($row)){
+                    Writelog( M()->getLastSql(), 'errorsql', 'inserttag');
+                    $msg = '数据行插入失败: ' . $insertID . ' ,请告知技术进行处理';
+                    goto end;
+                }
+
+                $insert_data[] = $row;
+            }
+        }
+        $msg = '导入完成';
+        goto end;
+        
+        end:
+        $responsedata = array("msg" => $msg, "res" => 1, 'data' => []);
+        echo json_encode($responsedata,JSON_UNESCAPED_UNICODE);
+        exit;
+    }
+
+    /**
+     * 批量更新
+     * @param  string $table_name [description]
+     * @param  array  $data       [description]
+     * @param  string $field      [description]
+     * @return [type]             [description]
+     */
+    public function batch_update($table_name = '', $data = array(), $field = '') {
+        if (!$table_name || !$data || !$field) {
+            return false;
+        } else {
+            $sql = 'UPDATE ' . C('DB_PREFIX') . $table_name;
+        }
+        $con = array();
+        $con_sql = array();
+        $fields = array();
+        foreach ($data as $key => $value) {
+            $x = 0;
+            foreach ($value as $k => $v) {
+                if ($k != $field && !$con[$x] && $x == 0) {
+                    $con[$x] = " set {$k} = (CASE {$field} ";
+                } elseif ($k != $field && !$con[$x] && $x > 0) {
+                    $con[$x] = " {$k} = (CASE {$field} ";
+                }
+                if ($k != $field) {
+                    $temp = $value[$field];
+                    $con_sql[$x] .= " WHEN '{$temp}' THEN '{$v}' ";
+                    $x++;
+                }
+            }
+            $temp = $value[$field];
+            if (!in_array($temp, $fields)) {
+                $fields[] = $temp;
+            }
+        }
+        $num = count($con) - 1;
+        foreach ($con as $key => $value) {
+            foreach ($con_sql as $k => $v) {
+                if ($k == $key && $key < $num) {
+                    $sql .= $value . $v . ' end),';
+                } elseif ($k == $key && $key == $num) {
+                    $sql .= $value . $v . ' end)';
+                }
+            }
+        }
+        $str = implode(',', $fields);
+        $sql .= " where {$field} in({$str})";
+        $res = M($table_name)->execute($sql);
+        return $res;
+    }
+
+    /**
+     * 上传图片文件
+     * @return [type] [description]
+     */
+    public function uploadPics() {
+        $temp_config['pathFormat'] = C('uploaderSourceImg');
+        $temp_config['maxSize'] = C('ueditor_config.imageMaxSize');
+        $temp_config['allowFiles'] = C('ueditor_config.imageAllowFiles');
+        $up = new \My\Uploader('pics', $temp_config);
+        $info = $up->getFileInfo();
+        if ($info['state'] == 'SUCCESS') {
+            $this->ajaxReturn($info['state'], 200);
+        } else {
+            $this->ajaxReturn($info['state'], 400);
+        }
+    }
+
+
+}

+ 182 - 0
Application/Admin/Controller/VipVoteController.class.php

@@ -0,0 +1,182 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 投票管理
+ * @author   brent
+ * @version  0.0.1
+ */
+class VipVoteController 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('activity_vip_vote');
+    }
+
+    /**
+     * [Index 列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+    public function Index() {
+        $where = array();
+        $listRows = I('listRows') ? I('listRows') : 100;
+        $keyword = I("keyword", "", "trim");
+        $keyword && $where['uid'] = array('like', '%' . $keyword . '%');
+        if (isset($keyword) && !empty($keyword)) {
+            $this->assign('keyword', $keyword);
+        }
+        
+        $page = I('p') ? I('p') : 1;
+        $this->assign('p', $page);
+        $list = D('Admin/VipVote')->get_vote_list($where, $page, $listRows, $count);
+
+        $Page = new \Think\Page($count, $listRows);
+        $Page->parameter .= "&p=[PAGE]";
+        $Page->parameter .= "&listRows=" . $listRows;
+        $Page->parameter .= "&keyword=" .$keyword;
+        $Page = $this->page_config($Page);
+        $show = $Page->show();
+        $this->assign('page', $show);
+
+        $this->assign('List', $list);
+        $this->assign('Mengbaos', $mengbaos);
+        $this->display('Index');
+    }
+
+
+    /**
+     * [SaveInfo 文章添加/编辑页面]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function SaveInfo() {
+        // 文章信息
+        if (empty($_REQUEST['id'])) {
+            $data = array();
+        } else {
+            $data = $this->table->find(I('id'));
+            if (empty($data)) {
+                $data = array('id' => I('id'));
+            }
+        }
+
+        $this->assign('data', $data);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 文章添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function Save() {
+
+        // 是否ajax请求
+        if (!IS_AJAX) {
+            $this->error(L('common_unauthorized_access'));
+        }
+        // 添加
+        if (empty($_POST['id'])) {
+            $this->Add();
+
+            // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 文章添加]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-18T16:20:59+0800
+     */
+    private function Add() {
+
+        $data['uid'] = I('uid');
+        $data['num'] = I('num');
+        $data['act_id'] = I('act_id');
+        // 数据添加
+        if ($this->table->add($data)) {
+            $this->ajaxReturn(L('common_operation_add_success'));
+        } else {
+            $this->ajaxReturn(L('common_operation_add_error'), -100);
+        }
+    }
+
+    /**
+     * [Edit 文章编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-17T22:13:40+0800
+     */
+    private function Edit() {
+        $id = I('id');
+        $data = array();
+
+        $data['uid'] = I('uid');
+        $data['num'] = I('num');
+        $data['act_id'] = I('act_id');
+        // 数据更新
+        if (false !== $this->table->where(array('id' => $id))->save($data)) {
+            $this->ajaxReturn(L('common_operation_edit_success'));
+        } else {
+            $this->ajaxReturn(L('common_operation_edit_error'), -100);
+        }
+    }
+
+    /**
+     * [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 (!empty($_POST['id'])) {
+            // 更新
+            if ($this->table->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);
+        }
+    }
+
+}

+ 189 - 0
Application/Admin/Controller/VoteController.class.php

@@ -0,0 +1,189 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 投票管理
+ * @author   brent
+ * @version  0.0.1
+ */
+class VoteController 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('activity_vote');
+    }
+
+    /**
+     * [Index 列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+    public function Index() {
+        $where = array();
+        $listRows = I('listRows') ? I('listRows') : 100;
+        $keyword = I("keyword", "", "trim");
+        $keyword && $where['uid'] = array('like', '%' . $keyword . '%');
+        if (isset($keyword) && !empty($keyword)) {
+            $this->assign('keyword', $keyword);
+        }
+        
+        $page = I('p') ? I('p') : 1;
+        $this->assign('p', $page);
+        $list = D('Admin/Vote')->get_vote_list($where, $page, $listRows, $count);
+
+        $mengbaos = M('activity_mengbao')->getField('id,name',true);
+
+        $Page = new \Think\Page($count, $listRows);
+        $Page->parameter .= "&p=[PAGE]";
+        $Page->parameter .= "&listRows=" . $listRows;
+        $Page->parameter .= "&keyword=" .$keyword;
+        $Page = $this->page_config($Page);
+        $show = $Page->show();
+        $this->assign('page', $show);
+
+        $this->assign('List', $list);
+        $this->assign('Mengbaos', $mengbaos);
+        $this->display('Index');
+    }
+
+
+    /**
+     * [SaveInfo 文章添加/编辑页面]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function SaveInfo() {
+        // 文章信息
+        if (empty($_REQUEST['id'])) {
+            $data = array();
+        } else {
+            $data = $this->table->find(I('id'));
+            if (empty($data)) {
+                $data = array('id' => I('id'));
+            }
+        }
+
+        $this->assign('data', $data);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 文章添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function Save() {
+        // 是否ajax请求
+        if (!IS_AJAX) {
+            $this->error(L('common_unauthorized_access'));
+        }
+        // 添加
+        if (empty($_POST['id'])) {
+            $this->Add();
+
+            // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 文章添加]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-18T16:20:59+0800
+     */
+    private function Add() {
+
+        $data['uid'] = I('uid');
+        $data['num'] = I('num');
+        $data['act_id'] = I('act_id');
+        $data['date'] = I('date');
+        $data['created_at'] = I('created_at');
+
+        // 数据添加
+        if ($this->table->add($data)) {
+            $this->ajaxReturn(L('common_operation_add_success'));
+        } else {
+            $this->ajaxReturn(L('common_operation_add_error'), -100);
+        }
+    }
+
+    /**
+     * [Edit 文章编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-17T22:13:40+0800
+     */
+    private function Edit() {
+        $id = I('id');
+        $data = array();
+
+        $data['uid'] = I('uid');
+        $data['num'] = I('num');
+        $data['act_id'] = I('act_id');
+        $data['date'] = I('date');
+        $data['created_at'] = I('created_at');
+        // 数据更新
+
+        if (false !== $this->table->where(array('id' => $id))->save($data)) {
+            $this->ajaxReturn(L('common_operation_edit_success'));
+        } else {
+            $this->ajaxReturn(L('common_operation_edit_error'), -100);
+        }
+    }
+
+    /**
+     * [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 (!empty($_POST['id'])) {
+            // 更新
+            if ($this->table->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);
+        }
+    }
+
+}

+ 37 - 0
Application/Admin/Model/MengbaoModel.class.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 文章模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class MengbaoModel extends CommonModel
+{
+	/**
+	 * 获取列表
+	 * @author brent
+	 */
+	public function get_mengbao_list($where = array(), $page = 1, $listRows = 10, &$count = 0){
+	    $model 	= M("activity_mengbao");
+	    $map = array();
+	    $where['name'] && $map['name|uid|phone'] = $where['name'];
+	    
+	    //排序
+	    $order	= "id desc";
+	    $count = $model
+	    	->where($map)
+			-> count();
+	    // echo $count;die;
+	    
+	    $model->where($map)-> page("{$page}, {$listRows}");
+	    $list 	= $model->order($order)->select();
+//	     echo M()->getlastSQL();die;
+	    return $list;
+	}
+}
+?>

+ 37 - 0
Application/Admin/Model/VipVoteModel.class.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 文章模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class VipVoteModel extends CommonModel
+{
+	/**
+	 * 获取列表
+	 * @author brent
+	 */
+	public function get_vote_list($where = array(), $page = 1, $listRows = 10, &$count = 0){
+	    $model 	= M("activity_vip_vote");
+	    $map = array();
+	    $where['uid'] && $map['uid'] = $where['uid'];
+	    
+	    //排序
+	    $order	= "id desc";
+	    $count = $model
+	    	->where($map)
+			-> count();
+	    // echo $count;die;
+	    
+	    $model->where($map)-> page("{$page}, {$listRows}");
+	    $list 	= $model->order($order)->select();
+//	     echo M()->getlastSQL();die;
+	    return $list;
+	}
+}
+?>

+ 37 - 0
Application/Admin/Model/VoteModel.class.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 文章模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class VoteModel extends CommonModel
+{
+	/**
+	 * 获取列表
+	 * @author brent
+	 */
+	public function get_vote_list($where = array(), $page = 1, $listRows = 10, &$count = 0){
+	    $model 	= M("activity_vote");
+	    $map = array();
+	    $where['uid'] && $map['uid'] = $where['uid'];
+	    
+	    //排序
+	    $order	= "id desc";
+	    $count = $model
+	    	->where($map)
+			-> count();
+	    // echo $count;die;
+	    
+	    $model->where($map)-> page("{$page}, {$listRows}");
+	    $list 	= $model->order($order)->select();
+//	     echo M()->getlastSQL();die;
+	    return $list;
+	}
+}
+?>

Різницю між файлами не показано, бо вона завелика
+ 452 - 0
Application/Admin/View/Default/ActivityV2/mengbao.html


+ 126 - 0
Application/Admin/View/Default/Mengbao/Index.html

@@ -0,0 +1,126 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+		<!-- form start -->
+		<form class="am-form view-list" action="{{:U('Admin/Mengbao/Index')}}" method="POST">
+			<div class="am-g">
+				<input type="text" class="am-radius form-keyword" style="width: 20rem;display: inline-block;" placeholder="素材名搜索" name="keyword" <present name="keyword"> value="{{$keyword}}"</present> />
+				<label>分页每页显示条数:</label>
+				<input type="text" class="am-radius form-keyword" style="width: 10rem;display: inline-block;" placeholder="分页显示条数" name="listRows" <present name="listRows"> value="{{$listRows}}"</present> />
+				<button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit">查询</button>
+            </div>
+        </form>
+        <!-- form end -->
+        <!-- operation start -->
+        <div class="am-g m-t-15">
+            <a href="{{:U('Admin/Mengbao/SaveInfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus" style="float: left;"> {{:L('common_operation_add')}}</a>
+            <div class="am-form-group am-form-file" style="float: left;margin-left: 5px;">
+              <button type="button" class="am-btn am-btn-success am-btn-xs">导入文件</button>
+              <input id="import_source" type="file" name="excel" multiple accept="application/vnd.ms-excel">
+            </div>
+            <div>
+                <a href="{{:U('Admin/Mengbao/ExcelExport')}}" class="am-btn am-btn-danger am-btn-xs">导出</a>
+            </div>
+        </div>
+        <div class="am-g" id="faillist">
+        </div>
+        <!-- operation end -->
+		<!-- list start -->
+		<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
+			<thead>
+				<tr>
+					<th>序号</th>
+					<th>ID</th>
+                    <th class="am-hide-sm-only">uid</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">媒资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.source_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.uid}}</td>
+							<td class="am-hide-sm-only">{{$v.name}}</td>
+							<td class="am-hide-sm-only"><img style="width: 10rem" src="{{$v.image}}" /></td>
+                            <td class="am-hide-sm-only">{{$v.score}}</td>
+                            <td class="am-hide-sm-only">{{$v.age}}</td>
+                            <td class="am-hide-sm-only">{{$v.media_id}}</td>
+                            <td class="am-hide-sm-only">{{$v.media_num}}</td>
+                            <td class="am-hide-sm-only">{{$v.desc}}</td>
+                            <td class="am-hide-sm-only">{{$v.video}}</td>
+							<td class="am-hide-sm-only">{{$v.created_at}}</td>
+							<td class="view-operation">
+								<a href="{{:U('Admin/Mengbao/SaveInfo', array('id'=>$v['id']))}}">
+									<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" data-am-popover="{content: '{{:L('common_operation_edit')}}', trigger: 'hover focus'}"></button>
+								</a>                                
+								<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:U('Admin/Mengbao/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 -->
+		<div id="pages" class="p">{{$page}}</div>
+		<!-- page end -->
+	</div>
+</div>
+
+<!-- right content end  -->
+		
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end -->
+<script type="text/javascript">
+    $("#import_source").on('change', function(event) {
+        event.preventDefault();
+        $.ajaxFileUpload
+            (
+                {
+                    url: '{{:U("Admin/Mengbao/importExcel");}}', //用于文件上传的服务器端请求地址
+                    secureuri: false, //是否需要安全协议,一般设置为false
+                    fileElementId: 'import_source', //文件上传域的ID
+                    dataType: 'text', //返回值类型 一般设置为json
+                    success: function(data, status) //服务器成功响应处理函数
+                    {
+                        data =  eval('(' + data + ')');
+                        if(data.data[0] !== undefined){
+                            var faillist = data.data;
+                            for(faillist in x){
+                                $("#faillist").append('<span class="am-badge am-badge-danger">'+ faillist[x] +'</span>');
+                            }
+                            return false;
+                        }
+                        alert(data.msg);
+                        setTimeout('myrefresh()',3000); //指定5秒刷新一次
+                    },
+                    error: function(data, status, e)//服务器响应失败处理函数
+                    {
+                        alert(status);
+                    }
+                }
+            );
+    });
+
+    function myrefresh() { window.location.reload(); } 
+    
+</script>
+	

+ 142 - 0
Application/Admin/View/Default/Mengbao/SaveInfo.html

@@ -0,0 +1,142 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+<style type="text/css">
+	
+</style>
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+		<!-- form start -->
+		<form class="am-form form-validation view-save" action="{{:U('Admin/Mengbao/Save')}}" method="POST" request-type="ajax-url" request-value="{{:U('Admin/Mengbao/Index')}}">
+			<legend>
+				<span class="fs-16">
+					<if condition="empty($data['id'])">
+						素材添加
+					<else />
+						素材编辑
+					</if>
+				</span>
+				<a href="{{:U('Admin/Source/Index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> {{:L('common_operation_back')}}</a>
+			</legend>
+			<div class="am-form-group">
+				<label>机顶盒账号(uid)</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="uid" placeholder="uid" data-validation-message="机顶盒账号(uid)" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.uid}}" </notempty>
+				</div>
+			</div>
+			<div class="am-form-group">
+				<label>报名联系方式</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="phone" placeholder="phone" data-validation-message="报名联系方式" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.phone}}" </notempty>
+				</div>
+			</div>
+			<div class="am-form-group">
+				<label>宝宝名字</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="name" placeholder="name" data-validation-message="请填写宝宝名字" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.name}}" </notempty>
+				</div>
+			</div>
+			<div class="am-form-group">
+				<label>宝宝年龄</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="name" placeholder="age" data-validation-message="请填写宝宝年龄" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.age}}" </notempty>
+				</div>
+			</div>
+			<div class="am-form-group">
+				<label>宝宝照片</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="image" placeholder="image"  data-validation-message="请填写七牛云图片地址" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.image}}" </notempty>
+				</div>
+			</div>
+			
+			<div class="am-form-group">
+				<label>视频地址</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="video" placeholder="视频地址"  data-validation-message="请填写七牛云视频地址" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.video}}" </notempty>
+				</div>
+			</div>
+
+			<div class="am-form-group">
+				<label>得票数</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="score" placeholder="score"  data-validation-message="得票数" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.score}}" </notempty>
+				</div>
+			</div>
+
+			<div class="am-form-group">
+				<label>媒体ID</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="media_id" placeholder="媒体ID"  class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.media_id}}" </notempty></>
+				</div>
+			</div>
+                        
+			<div class="am-form-group">
+				<label>媒体集数</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="media_num" placeholder="媒体集数"  class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.media_num}}" </notempty></>
+				</div>
+			</div>
+                        
+			<div class="am-form-group">
+				<label>简介</label>
+				<div class="am-input-group am-input-group-sm">
+					<textarea name="desc" value="{{$data.desc}}">{{$data.desc}}</textarea>
+				</div>
+			</div>
+			<div class="am-form-group" style="padding-top: 2rem">
+				<input type="hidden" name="id" <notempty name="data"> value="{{$data.id}}"</notempty>" />
+				<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'{{:L('common_form_loading_tips')}}'}">{{:L('common_operation_save')}}</button>
+			</div>
+
+		</form>
+        <!-- form end -->
+	</div>
+</div>
+<!-- right content end  -->
+
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end -->
+<script type="text/javascript">	
+    $("#file1").change(function() {
+        ajaxFileUpload();
+    });
+	function ajaxFileUpload() {
+		var img_height = $('.img_height').val();
+		var img_width  = $('.img_width').val();
+		var url = "{{:U('Admin/Source/Uploader')}}&img_height="+img_height+"&img_width="+img_width;
+	    $.ajaxFileUpload
+            (
+                {
+                    url: url, //用于文件上传的服务器端请求地址
+                    secureuri: false, //是否需要安全协议,一般设置为false
+                    fileElementId: 'file1', //文件上传域的ID
+                    dataType: 'text', //返回值类型 一般设置为json
+                    success: function(data, status) //服务器成功响应处理函数
+                    {
+                        data =  eval('(' + data + ')');
+                        $(".imgurl").attr("value", data.imgurl);
+                        $("#img1").attr("src", data.imgurl);
+                        
+                    },
+                    error: function(data, status, e)//服务器响应失败处理函数
+                    {
+                        alert(status);
+                    }
+                }
+            )
+	    return false;
+	}
+        
+
+</script>

+ 3 - 0
Application/Admin/View/Default/Public/Footer.html

@@ -24,6 +24,9 @@
 <js href="__PUBLIC__/Common/Lib/amazeui-switch/amazeui.switch.min.js" />
 <js href="__PUBLIC__/Common/Lib/amazeui-chosen/amazeui.chosen.min.js" />
 
+<!-- ajax图片上传-->
+<js href="__PUBLIC__/Common/Lib/uploader/ajaxfileupload.js" />
+
 <!-- 项目公共 -->
 <js href="__PUBLIC__/Common/Js/Common.js" />
 

+ 82 - 0
Application/Admin/View/Default/VipVote/Index.html

@@ -0,0 +1,82 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+<!-- 上传按钮样式 -->
+<style type="text/css">
+    .webuploader-container {float: left;height: 28px;}
+    .webuploader-pick {height: 28px;line-height: 28px;border-radius:0;padding: 0px 12px;}
+    .webuploader-element-invisible {display: none;}
+</style>
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+		<!-- form start -->
+		<form class="am-form view-list" action="{{:U('Admin/VipVote/Index')}}" method="POST">
+			<div class="am-g">
+				<input type="text" class="am-radius form-keyword" style="width: 20rem;display: inline-block;" placeholder="uid搜索" name="keyword" <present name="keyword"> value="{{$keyword}}"</present> />
+				<label>分页每页显示条数:</label>
+				<input type="text" class="am-radius form-keyword" style="width: 10rem;display: inline-block;" placeholder="分页显示条数" name="listRows" <present name="listRows"> value="{{$listRows}}"</present> />
+				<button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit">查询</button>
+            </div>
+        </form>
+        <!-- form end -->
+        <!-- operation start -->
+        <div class="am-g m-t-15">
+            <a href="{{:U('Admin/Vote/SaveInfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus" style="float: left;"> {{:L('common_operation_add')}}</a>
+        </div>
+        <div class="am-g" id="faillist">
+        </div>
+        <!-- operation end -->
+		<!-- list start -->
+		<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
+			<thead>
+				<tr>
+					<th>序号</th>
+					<th>ID</th>
+                    <th class="am-hide-sm-only">活动</th>
+                    <th class="am-hide-sm-only">uid</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.source_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.act_id}}</td>
+                            <td class="am-hide-sm-only">{{$v.uid}}</td>
+                            <td class="am-hide-sm-only">{{$v.num}}</td>
+							<td class="am-hide-sm-only">{{$v.created_at}}</td>
+							<td class="am-hide-sm-only">{{$v.updated_at}}</td>
+							<td class="view-operation">
+								<a href="{{:U('Admin/VipVote/SaveInfo', array('id'=>$v['id']))}}">
+									<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" data-am-popover="{content: '{{:L('common_operation_edit')}}', trigger: 'hover focus'}"></button>
+								</a>                                
+								<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:U('Admin/VipVote/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 -->
+		<div id="pages" class="p">{{$page}}</div>
+		<!-- page end -->
+	</div>
+</div>
+
+<!-- right content end  -->
+		
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end -->
+
+	

+ 58 - 0
Application/Admin/View/Default/VipVote/SaveInfo.html

@@ -0,0 +1,58 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+<style type="text/css">
+	
+</style>
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+		<!-- form start -->
+		<form class="am-form form-validation view-save" action="{{:U('Admin/VipVote/Save')}}" method="POST" request-type="ajax-url" request-value="{{:U('Admin/VipVote/Index')}}">
+			<legend>
+				<span class="fs-16">
+					<if condition="empty($data['id'])">
+						添加
+					<else />
+						编辑
+					</if>
+				</span>
+				<a href="{{:U('Admin/VipVote/Index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> {{:L('common_operation_back')}}</a>
+			</legend>
+			<div class="am-form-group">
+				<label>机顶盒账号(uid)</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="uid" placeholder="uid" data-validation-message="机顶盒账号(uid)" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.uid}}" </notempty>
+				</div>
+			</div>
+			<div class="am-form-group">
+				<label>act_id</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="act_id" placeholder="name" data-validation-message="" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.act_id}}" </notempty>
+				</div>
+			</div>
+
+			<div class="am-form-group">
+				<label>已投票数</label>
+				<div class="am-input-group am-input-group-sm">
+					<input type="text" name="num" placeholder="num"  data-validation-message="已投票数" class="am-form-field am-radius" 
+					<notempty name="data"> value="{{$data.num}}" </notempty>
+				</div>
+			</div>
+   
+			<div class="am-form-group" style="padding-top: 2rem">
+				<input type="hidden" name="id" <notempty name="data"> value="{{$data.id}}"</notempty>" />
+				<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'{{:L('common_form_loading_tips')}}'}">{{:L('common_operation_save')}}</button>
+			</div>
+
+		</form>
+        <!-- form end -->
+	</div>
+</div>
+<!-- right content end  -->
+
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end -->

+ 79 - 0
Application/Admin/View/Default/Vote/Index.html

@@ -0,0 +1,79 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+<!-- 上传按钮样式 -->
+<style type="text/css">
+    .webuploader-container {float: left;height: 28px;}
+    .webuploader-pick {height: 28px;line-height: 28px;border-radius:0;padding: 0px 12px;}
+    .webuploader-element-invisible {display: none;}
+</style>
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+		<!-- form start -->
+		<form class="am-form view-list" action="{{:U('Admin/Vote/Index')}}" method="POST">
+			<div class="am-g">
+				<input type="text" class="am-radius form-keyword" style="width: 20rem;display: inline-block;" placeholder="uid搜索" name="keyword" <present name="keyword"> value="{{$keyword}}"</present> />
+				<label>分页每页显示条数:</label>
+				<input type="text" class="am-radius form-keyword" style="width: 10rem;display: inline-block;" placeholder="分页显示条数" name="listRows" <present name="listRows"> value="{{$listRows}}"</present> />
+				<button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit">查询</button>
+            </div>
+        </form>
+        <!-- form end -->
+        <!-- operation start -->
+        <div class="am-g m-t-15">
+            <a href="{{:U('Admin/Vote/SaveInfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus" style="float: left;"> {{:L('common_operation_add')}}</a>
+        </div>
+        <div class="am-g" id="faillist">
+        </div>
+        <!-- operation end -->
+		<!-- list start -->
+		<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
+			<thead>
+				<tr>
+					<th>序号</th>
+					<th>ID</th>
+                    <th class="am-hide-sm-only">活动</th>
+                    <th class="am-hide-sm-only">uid</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.source_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.act_id}}</td>
+                            <td class="am-hide-sm-only">{{$v.uid}}</td>
+                            <td class="am-hide-sm-only">{{$Mengbaos[$v['mengbao_id']]}}</td>
+                            <td class="am-hide-sm-only">{{$v.num}}</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/Vote/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 -->
+		<div id="pages" class="p">{{$page}}</div>
+		<!-- page end -->
+	</div>
+</div>
+
+<!-- right content end  -->
+		
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end -->
+
+	

+ 1 - 0
Application/Common/Conf/activity.php

@@ -11,5 +11,6 @@
 return array(
 	'activity'=>array(
         ['activity_name'=>'公仔兑换','view'=>'ActivityV2/collect','logic'=>'Collect2','log'=>'prize_log_v2'],
+        ['activity_name'=>'鼠年萌宝活动','view'=>'ActivityV2/mengbao','logic'=>'Mengbao','log'=>'prize_log_v2']
     )
 );

+ 788 - 0
Application/Home/Logic/Activityv2/MengbaoLogic.class.php

@@ -0,0 +1,788 @@
+<?php
+/**
+ * 佩奇拼图活动(由萌鸡快跑活动改写)
+ * @author   xusong
+ * @version  0.0.1
+ * @datetime 2019.07.25
+ */
+namespace Home\Logic\Activityv2;
+
+class MengbaoLogic extends BaseLogic
+{   
+
+    private $act_id;
+    private $uid;
+    private $userinfo;
+    private $activityinfo;
+    private $vip_level;
+
+
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-03T12:39:08+0800
+     */
+    public function _initialize() {
+        // 调用父类前置方法
+        parent::_initialize();
+        $this->uid = trim(I('uid'));
+        
+        if(!$this->userinfo = M('iptv_users')->where(['uid'=>$this->uid])->find()){
+            $this->responseError('uid 参数非法');
+        }
+        
+        $this->act_id = (int)I('act_id');
+        if(!$this->activityinfo = M('Activity_v2')->where(['id'=>$this->act_id])->find()){
+            $this->responseError('act_id 参数非法');
+        }
+        //检查vip鉴权方式
+        $this->vip_level = I('is_vip') >= 0 ? I('is_vip') : 0;
+    }
+
+    public function getMengbaoList()
+    {
+        $page = I('page',1);
+        $limit = I('limit',8);
+        $count = M('activity_mengbao')->count();
+
+        $maxPage = ceil($count/$limit);
+
+        if( ($page < 1) || ($page > $maxPage)){
+            $this->responseError('没有更多萌宝资料!', -3, $error);
+        }
+
+        $data = M('activity_mengbao')->field('id as mengbao_id,name,age,image,media_id,media_num,score')->order('score desc , id asc')->limit(($page-1)*$limit,$limit)->select();
+
+        foreach ($data as $key=>$value) {
+            $data[$key]['image'] = __MY_URL__.$value['image'];
+        }
+
+        $this->responseSuccess($data,'萌宝资料');
+    }
+
+    /**
+     * 获取活动状态
+     * @return [type] [description]
+     */
+    public function getActStatus()
+    {   
+        //开始时间结束时间未作限制
+        if($this->activityinfo['is_enable'] == 1){
+            $this->responseSuccess(1, "请求成功!");
+        }else{
+            $this->responseSuccess(-1, "请求成功!");
+        }
+    }
+    
+    /**
+     * 提交用户资料
+     * @return [type] [description]
+     */
+    public function setUserInfo()
+    {       
+        $phone  = trim(I('phone'));
+        if (empty($phone)) {
+            $this->responseError('参数错误!');
+        }
+        //检测手机号码是否正确
+        if (!preg_match('/^1[345789]\d{9}$/ims', $phone)) {
+            $this->responseError('手机号填写有误!');
+        }
+        //更新用户活动手机号码
+        $where = array(
+            'uid'=>$this->uid,
+            'act_id'=>$this->act_id,
+        );
+        if ($id = M('activity_user_v2')->where($where)->getField('id')){
+            $update['user_phone']= $phone;
+            $update['updated_at']= date('Y-m-d H:i:s');
+            if(M('activity_user_v2')->where(['id'=>$id])->save($update)===false){
+                Writelog(M()->getLastSql(),'sql','prize');
+                $this->responseError("更新失败!");
+            }
+        }else{
+            $insert_data = array(
+                'uid'=>$this->uid,
+                'act_id'=>$this->act_id,
+                'user_phone'=>$phone,
+                'created_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)){
+                Writelog(M()->getLastSql(),'sql','prize');
+                $this->responseError("登记失败!");                
+            }
+        }
+        $this->responseSuccess(0, "登记成功!");
+    }
+
+    public function vote()
+    {
+        $score = I('score',1);
+        $mengbao_id = I('mengbao_id');
+        $remain_vote_chance = $this->_getVoteChance();
+
+        if(($remain_chance = $remain_vote_chance - $score) < 0){
+            $this->responseError('您没有足够的投票次数,投票失败');
+        }
+
+        //更新萌宝获得总票数
+        M('activity_mengbao')->where(['id'=>$mengbao_id])->setInc('score',$score);
+
+        $where = [
+            'uid'=>$this->uid,
+            'created_at'=>['gt','2020-01-15'],
+            'product_id'=>'365',
+            'pay_result'=>0
+        ];
+        $is_year_vip = M('iptv_order')->where($where)->find();
+
+        if($is_year_vip){
+            //已投票数
+            $vip_vote = M('activity_vip_vote')->where(['uid'=>$this->uid,'act_id'=>$this->act_id])->field('id,num')->find();
+            $alrady_vip_vote = $vip_vote['num'] ? : 0;
+            //剩余数
+            $remain_vip_vote = 200 - $alrady_vip_vote;
+
+            $diff = $remain_vip_vote - $score;
+
+            if($diff >= 0){
+                M('activity_vip_vote')->where(['id'=>$vip_vote['id']])->setInc('num',$diff);
+            }else{
+                M('activity_vip_vote')->where(['id'=>$vip_vote['id']])->save(['num'=>200]);
+            }
+        }
+
+        //插入
+        $insert_data = [
+            'act_id'=>$this->act_id,
+            'uid'   =>$this->uid,
+            'num'   =>$score,
+            'mengbao_id'=>$mengbao_id,
+            'created_at'=>date('Y-m-d H:i:s'),   
+            'date'  =>date('Ymd')
+        ];
+        M('activity_vote')->add($insert_data);
+
+        $this->responseSuccess(['num'=>$remain_chance],'投票成功,去参与抽奖吧');
+    }
+    
+
+    /**
+    * 获取剩余投票次数
+    */
+    public function _getVoteChance()
+    {
+        if($this->vip_level >= 1){
+            $vote = 10;
+        }else{
+            $vote = 5;
+        }
+
+        $add = 0;
+        $where = [
+            'uid'=>$this->uid,
+            'created_at'=>['gt','2020-01-15'],
+            'product_id'=>'365',
+            'pay_result'=>0
+        ];
+        $is_year_vip = M('iptv_order')->where($where)->find();
+
+        if($is_year_vip){
+            $num = M('activity_vip_vote')->where(['uid'=>$this->uid,'act_id'=>$this->act_id])->getField('num');
+
+            if($num === null){
+                $insert = [
+                    'act_id'=>$this->act_id,
+                    'uid'=>$this->uid,
+                    'num'=>0,
+                    'created_at'=>date('Y-m-d H:i:s')
+                ];
+                M('activity_vip_vote')->add($insert);
+            }
+            $add = 200 - $num;
+        }
+
+        $vote += $add;
+
+        //查看当前已投票次数
+        $alreay_num = M('activity_vote')->where(['date'=>date('Ymd'),'uid'=>$this->uid,'act_id'=>$this->act_id])->sum('num');
+
+        //查看当前应有票数
+        if($vote <= $alreay_num){
+            return 0;
+        }
+
+        return $vote > $alreay_num ? $vote - $alreay_num : 0;
+    }
+
+    /**
+    * 获取剩余投票次数
+    */
+    public function getVoteChance()
+    {   
+        $data['num'] = $this->_getVoteChance();
+        $this->responseSuccess($data,'投票剩余次数');
+    }
+
+
+    /**
+     * 提交用户资料
+     * @return [type] [description]
+     */
+    public function setUserInfoByphone()
+    {
+        $phone  = trim(I('phone'));
+        $address  = trim(I('address'));
+        $receiver  = trim(I('receiver'));
+        if (!($phone && $address && $receiver)) {
+            $this->responseError('参数错误!');
+        }
+        //检测手机号码是否正确
+        if (!preg_match('/^1[345789]\d{9}$/ims', $phone)) {
+            $this->responseError('手机号填写有误!');
+        }
+        //更新用户活动手机号码
+        $where = array(
+            'uid'=>$this->uid,
+            'act_id'=>$this->act_id,
+        );
+        if ($id = M('activity_user_v2')->where($where)->getField('id')){
+            $update['user_phone']= $phone;
+            $update['address'] = $address;
+            $update['receiver'] = $receiver;
+            $update['updated_at'] = date('Y-m-d H:i:s');            
+            if(M('activity_user_v2')->where(['id'=>$id])->save($update)===false){
+                Writelog(M()->getLastSql(),'sql','prize');
+                $this->responseError("更新失败!");
+            }
+        }else{
+            $insert_data = array(
+                'uid'=>$this->uid,
+                'act_id'=>$this->act_id,
+                'user_phone'=>$phone,
+                'address'=>$address,
+                'receiver'=>$receiver,
+                'created_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)){
+                Writelog(M()->getLastSql(),'sql','prize');
+                $this->responseError("登记失败!");                
+            }
+        }
+        $this->responseSuccess(0, "登记成功!");
+    }
+    
+
+    /**
+     * 活动规则说明
+     * @return [type] [description]
+     */
+    public function getActivityInfo()
+    {        
+//        //获取活动规则信息
+        $data['act'] = $this->activityinfo;
+        $data['act']['info'] = explode('######', $this->activityinfo['introduce']);
+        $data['act']['info'][0] = mb_substr(htmlspecialchars_decode($data['act']['info'][0]), 0, -3) ;
+        $data['act']['info'][1] = mb_substr(htmlspecialchars_decode($data['act']['info'][1]), 4);
+        //获取当前活动的手机号码
+        $user_phone          = M('activity_user_v2')->where(['act_id'=>$this->act_id,'uid'=>$this->uid])->getField('user_phone');
+        if ($user_phone) {
+            $data['user']['user_phone'] = $user_phone;
+        }
+        //获取奖品信息
+        $prizes_tmp = json_decode($this->activityinfo['prize_list'],TRUE);
+        foreach ($prizes_tmp as $key => $v) {
+            $prizes[$v['prize_id']] = $v; 
+            if($v['prize_status'] == 0 || $v['prize_status'] == -1){
+                continue;
+            }
+            $prize_list[] = ['id'=>$v['prize_id'],'prize_name'=>$v['prize_name'],'prize_img'=>$v['prize_img']];
+        }
+        // var_dump($prizes);die;
+        $data['prizes'] = $prize_list;
+        //获取中奖信息
+        $data['rank'] = $this->prizelog('localhost');
+        unset($data['act']['prize_list']);
+        unset($data['act']['prize_rule']);
+        //获取当前用户中奖信息
+        $map['act_id']       = $this->act_id;
+        $map['uid'] = $this->uid;
+        $map['rule_id']     = array("neq", 0); 
+        //$data['my_prizes']   = M('prize_log_v2')->field('prize_id,prize_name')->where($map)->select();
+        $my_prizes = M('prize_log_v2')->field('created_at,prize_id')->where($map)->select() ? : array();
+        if($my_prizes){
+            foreach ($my_prizes as $k=>$value) {
+                $my_prizes[$k]['prize_name'] = $prizes[$value['prize_id']]['prize_name'];
+                $data['my_prizes'][] = ['prize_id'=>$value['prize_id'],'prize_name'=>$prizes[$value['prize_id']]['prize_name']];
+            }            
+        }     
+        //获取用户剩余中奖次数
+        $data['remain_chance'] = $this->_getUserChance();
+        $this->responseSuccess($data);
+    }
+
+    /**
+     * 获取用户当日抽奖次数
+     * @param  [type] $uid [description]
+     * @return [type]      [description]
+     */
+    public function _getUserChance()
+    {
+        $map['uid']             = $this->uid;
+        $map['act_id']          = $this->act_id;
+        $map['date']            = date('Ymd');
+        $chance = M('prize_log_v2')->where($map)->count();
+
+        if(($this->activityinfo['is_test'] == 1) && (I('is_test') == 1)){
+            return 1;
+        }
+        
+        if($chance){
+            return 0;
+        }
+
+        //是否参与了投票
+        $bool = M('activity_vote')->where([$map])->find();
+
+        if($bool){
+            return 1;
+        }else{
+            return -1;
+        }
+    }
+        
+    /**
+     * 获取用户剩余抽奖次数
+     * @return [type] [description]
+     */
+    public function getPrizeNum()
+    {
+        $remain_chance = $this->_getUserChance();
+        if($remain_chance == 0){
+            $this->responseSuccess(['num'=>0],'您今天的抽奖次数用完了');
+        }
+        if($remain_chance == 1){
+            $this->responseSuccess(['num'=>1],'您今天的剩余次数');
+        }
+        if($remain_chance == -1){
+            $this->responseSuccess(['num'=>-1],'参与投票,即可抽奖');
+        }
+
+    }
+
+    /**
+     * 所有中奖记录查询
+     */
+    public function prizelog($model = ''){
+        $error[] = ['error' => 'error'];
+        $where['pl.act_id'] = $this->act_id;
+        $where['pl.prize_status'] = 1;
+        $data = M('prize_log_v2')->alias('pl')
+            ->join(array('left join '.C("DB_PREFIX").'activity_user_v2 as iu on iu.uid = pl.uid and iu.act_id = '.$this->act_id))
+            ->where($where)
+            ->order('pl.id desc')
+            ->field('pl.prize_id,pl.created_at,pl.uid,iu.user_phone')
+            ->select();
+        $prizes = json_decode($this->activityinfo['prize_list'],TRUE);
+        foreach ($prizes as $value) {
+            $prize_list[$value['prize_id']] = $value;
+        }
+        if($data){
+            foreach ($data as $key=>$value) {
+                $data[$key]['prize_name'] = $prize_list[$value['prize_id']]['prize_name'];
+                $data[$key]['prize_img'] = __MY_URL__.$prize_list[$value['prize_id']]['prize_img'];
+            }
+        }
+        //增加虚拟中奖信息
+        $default_data = $this->getPrizeDefault();    
+        
+        if($data || $default_data){
+            if($data){
+                foreach ($data as $k=>$v){
+                    if($v['user_phone']){
+                        $data[$k]['user_phone'] = substr_replace($v['user_phone'],'****',3,4);
+                    }else {
+                        $data[$k]['user_phone'] = substr_replace($v['uid'],'****',6);
+                    }
+                    unset($data[$k]['uid']);
+                }                
+            }
+            if($data && $default_data){
+                $data = array_merge($default_data,$data);
+            }else{
+                $data = $data ? : $default_data;
+            }
+            array_multisort(array_column($data,'created_at'),SORT_DESC,$data);  
+            if($model == 'localhost'){
+                return $data;
+            }
+            $this->responseSuccess($data, '查询成功!');
+        }else{
+            if($model == 'localhost'){
+                return array();
+            }
+            $this->responseError('没有抽奖记录!', -3, $error);
+        }
+    }
+
+    /**
+     * 我的中奖记录查询
+     */
+    public function userPrizelog(){
+        $error[] = ['error' => 'error'];
+        //获取用户
+        if($user_phone = M('activity_user_v2')->where(['uid'=>$this->uid,'act_id'=>$this->act_id])->getField('user_phone')){
+            $phone_staus = 1;//填过
+        }else{
+            $phone_staus = 2;//填过
+        }
+        $where = array();
+        $where['pl.prize_status'] = 1;
+        $where['pl.uid'] = $this->uid;
+        $where['pl.act_id'] = $this->act_id;
+        $data = M('prize_log_v2')->alias('pl')
+        ->where($where)
+        ->order('pl.id desc')
+        ->field('pl.prize_id,pl.created_at')
+        ->select();
+//        echo M()->getLastSql();die;
+        $prizes = json_decode($this->activityinfo['prize_list'],TRUE);
+        foreach ($prizes as $value) {
+            $prize_list[$value['prize_id']] = $value;
+        }
+
+        $flag = $data ? 1 : 0;
+        if($flag){
+            if($data){
+                foreach ($data as $k => $v){
+                    $data[$k]['prize_name'] = $prize_list[$v['prize_id']]['prize_name'];
+                    $data[$k]['prize_object'] = 'real';
+                    $data[$k]['show_image']  = $prize_list[$v['prize_id']]['prize_img'] ? __MY_URL__.$prize_list[$v['prize_id']]['prize_img']:null;
+                    unset($data[$k]['prize_id']);
+                }                
+            }
+
+            $return_data = array(
+                'my_prizes'=>$data,
+                'user_phone'=>['phone_status'=>$phone_staus,'user_phone'=>$user_phone ? :''],
+                'prize_status'=>$data ? 'real' : 'vitual'
+            ); 
+            $this->responseSuccess($return_data, '查询成功!');
+        }else{
+            $this->responseError('没有抽奖记录!', -3, $error);
+        }
+    }
+
+    /**
+     * 抽奖
+     */
+    public function prize(){
+        $error[] = ['error' => 'error'];
+
+        $chance = $this->_getUserChance();
+
+
+        if($chance == 0){
+            $this->responseError('您今天的抽奖次数用完了');
+        }
+        if($chance == -1){
+            $this->responseSuccess('参与投票,即可抽奖');
+        }
+       
+        //开始抽奖
+        $prize_data = $this->_get_prize();
+        unset($prize_data['yes']['rule_id']);
+        $this->responseSuccess($prize_data, '抽奖成功!');
+    }
+
+    private function _get_prize() {
+        $result = $this->getPrizeSetDeatil();
+//        var_dump($result);die;
+        $this->_writePrizeLog($result);
+        $res = array();
+        $res['yes']['prize_name'] = $result['prize_name']; //中奖项
+        $res['yes']['prize_status'] = $result['prize_object'] ? : 'none';
+        $res['yes']['prize_img'] = $result['prize_img'] ? __MY_URL__.$result['prize_img'] : '';
+        $res['yes']['rule_id'] = $result['rule_id'];
+        return $res;
+    }
+    
+    /**
+     * @param desc 写入抽奖日志
+     * @param type $result
+     */
+    private function _writePrizeLog(&$result) {
+        $log_data['uid'] = $this->uid;
+        $log_data['prize_id'] = $result['prize_id'];
+        $log_data['is_vip'] = $this->vip_level;
+        $log_data['act_id'] = $this->act_id;
+        $log_data['created_at'] = date('Y-m-d H:i:s');
+        $log_data['date'] = date('Ymd');
+        $log_data['rule_id'] = $result['rule_id'];
+        $log_data['prize_status'] = $result['prize_status'];
+        if(!M('prize_log_v2')->add($log_data)){
+            Writelog(M()->getLastSql(),'sql','activity');
+            $this->responseError('系统繁忙抽奖失败', -1);
+        }        
+    }
+    
+    /**
+     * 返回中奖的信息
+     */
+    private function getPrizeSetDeatil()
+    {
+        $prize_list = json_decode($this->activityinfo['prize_list'],TRUE);//获取奖项设置
+        if($prize_list){
+            foreach ($prize_list as $row) {
+                $limit_sales[$row['prize_id']] = $row;
+                if($row['prize_level']== 0){
+                    $impossible_prize = ['prize_id'=>$row['prize_id'],'prize_name'=>$row['prize_name'],'rule_id'=>0,'prize_img'=>'','prize_status'=>0];
+                }
+            }
+        }
+        //获取所有规则
+        $rules = json_decode($this->activityinfo['prize_rule'],TRUE);
+        if(!$rules){
+            return $impossible_prize;
+        }
+        
+        if(I('run')!='complate'){
+            return $impossible_prize;
+        }
+
+        //如果中了一次实物奖就不允许中第二次
+        $map = array(
+            'act_id'=> $this->act_id,
+            'uid'=> $this->uid,
+            'prize_status'=>1,
+        );
+        if(M('Prize_log_v2')->where($map)->find()){
+            return $impossible_prize;
+        }
+
+        $swithc_no = ''; 
+        foreach ($rules as $value) {
+            if($value['rule_status'] == 0){
+                $swithc_no = $swithc_no. 0; 
+                continue;
+            }
+            //1.检查是否符合身份
+            if(FALSE === $this->_checkRuleRole($value['rule_role'])){
+                $swithc_no = $swithc_no. 1;
+                continue;
+            }
+            //2.检查中奖日期设置
+            if(FALSE === $this->_checkRuleDate($value['rule_date'])){
+                $swithc_no = $swithc_no. 2;
+                continue;
+            }
+            //3.检查时段设置
+            if(FALSE === $this->_checkRuleHour($value['rule_hour'])){
+                $swithc_no = $swithc_no. 3;
+                continue;
+            }
+            //4.概率摇奖
+            if(FALSE === $this->_getRandNum($value['rule_probability'])){
+                $swithc_no = $swithc_no. 4;
+                continue;
+            }
+            //5.查询是否超出当前规则下的出奖数
+            if(FALSE === $this->_checkCurrentRuleSale($value)){
+                $swithc_no = $swithc_no. 5;
+                continue;
+            }
+            //6.查询是否超出奖品总数
+            if(FALSE === $this->_checkGolabRule($value,$limit_sales)){
+                $swithc_no = $swithc_no. 6;
+                continue;
+            }
+
+           //8.如果中了一次实物奖就不允许中第二次
+           if('real'== $limit_sales[$value['rule_prize_id']]['prize_object']){
+               if(M('Prize_log_v2')->where(['act_id'=>$this->act_id,'uid'=>$this->uid,'prize_status'=>1])->find()){
+                   $swithc_no = $swithc_no. 8;
+                   continue;
+               }
+           }
+            Writelog('uid: '.$this->uid.'跳出关卡: '.$swithc_no,'switch','activityv2');
+            $prize = $limit_sales[$value['rule_prize_id']];
+            $prize['rule_id'] = $value['rule_id'];
+            $prize['prize_status'] = 1;
+            return $prize;
+        }
+        Writelog('uid: '.$this->uid.'跳出关卡: '.$swithc_no,'switch','activityv2');
+        return $impossible_prize;
+    }
+    
+    /**
+     * 获取转盘信息
+     */
+    public function prizeData(){
+        $error[] = ['error' => 'error'];
+        $data = array();
+        $data['userp']['prize_num'] = $this->_getUserChance();
+        $data['userp']['user_phone'] = $this->userinfo['user_phone'] ? :$this->userinfo['uid'];
+        //转盘信息
+        $turn_data = json_decode($this->activityinfo['prize_list'],TRUE);
+        if($turn_data){
+            foreach ($turn_data as $k => $v){
+                if($v['prize_status'] == 0){
+                    unset($turn_data[$k]);
+                    continue;
+                }
+                if($v['prize_img']){
+                    $turn_data[$k]['prize_img'] = __MY_URL__.$v['prize_img'];
+                }
+                unset($turn_data[$k]['prize_num']);
+                unset($turn_data[$k]['prize_level']);
+                unset($turn_data[$k]['prize_status']);
+            }
+            $data['prize_data'] = $turn_data;
+        }else{
+            $this->responseError('获取失败!', -1, $error);
+        }
+        $this->responseSuccess($data, '查询成功!');
+    }
+    
+    private function getPrizeDefault()
+    {   
+        $map['pd.act_id'] = $this->act_id;
+        $prizes = json_decode($this->activityinfo['prize_list'],true);
+        foreach ($prizes as $key=>$v){
+            $prize_list[$v['prize_id']] = $v;
+        }
+//        var_dump($prize_list);die;
+        $data = M('prize_default_v2')->where(['act_id'=>$this->act_id])->select();
+        if($data){
+            foreach ($data as $value) {
+                $return_data[] = array(
+                    'created_at'=>$value['prize_date'],
+                    'prize_name'=>$prize_list[$value['prize_id']]['prize_name'],
+                    'prize_img'=>$prize_list[$value['prize_id']]['prize_img'] ? __MY_URL__.$prize_list[$value['prize_id']]['prize_img']:'',
+                    'user_phone'=>substr_replace($value['phone'],'****',3,4),
+                );
+            }            
+        }
+        return $return_data;
+    }
+    
+    /**
+     * @desc 检查中奖规则关于身份设置
+     */
+    private function _checkRuleRole($rule_role)
+    { 
+        $role = $this->vip_level ? '会员' : '普通用户';
+        if(FALSE !== strpos($rule_role, '不限')){
+            return TRUE;
+        }
+        if($rule_role != '虚拟用户'){
+            if(in_array($role, explode(',', $rule_role))){
+                return TRUE;
+            }
+        }
+        return FALSE;
+    }
+    /**
+     * @desc 检查中奖规则关于日期
+     */
+    private function _checkRuleDate($rule_date)
+    { 
+        if(FALSE !== strpos($rule_date,'每日')){
+            return TRUE;
+        }
+        //时间段
+        if(strpos($rule_date,'至')){
+            $date = explode('至', $rule_date);
+            if((time()>=strtotime($date[0])) && time()< strtotime($date[1])){
+                return TRUE;
+            }else{
+                return FALSE;
+            }
+        }else{
+            if(date('Y-m-d') == $rule_date){
+                return TRUE;
+            }else{
+                return FALSE;
+            }
+        }
+    }
+    
+    /**
+     * @desc 检查中奖规则关于时间段
+     */
+    private function _checkRuleHour($rule_hour)
+    { 
+        $hour = explode('至', $rule_hour);
+        if((date('H:i')>= trim($hour[0])) && (date('H:i')< trim($hour[1]))){
+            return TRUE;
+        }else{
+            return FALSE;
+        }
+    }
+    /**
+     * @desc 概率摇奖 
+     * @param type $rule_probability
+     * @return boolean
+     */
+    private function _getRandNum($rule_probability)
+    {
+        if($rule_probability == 0){
+            return FALSE;
+        }
+        $tmp = explode('/', $rule_probability);
+        $rand_array = range(1, $tmp[1]);
+        shuffle($rand_array);
+        $get_randnum = array_slice($rand_array, 0, $tmp[0]);
+        Writelog('uid: '.$this->uid.'抽签: '.json_encode($get_randnum),'switch','activityv2');
+        if(in_array($tmp[0], $get_randnum)){
+            return TRUE;
+        }else{
+            return FALSE;
+        }        
+    }
+    /**
+     * @desc 查询符合当前规则
+     */
+    private function _checkCurrentRuleSale(&$rule)
+    {
+        //查询当前规则下的中奖数,如果为-1则无限制
+        if($rule['rule_num'] == -1){
+            return TRUE;
+        }
+        if((FALSE!==strpos($rule['rule_date'],'至')) && ($rule['rule_cycle']=='total')){
+            $rule_date = explode('至', $rule['rule_date']);
+            $where['rule_id'] = $rule['rule_id'];
+            $where['act_id'] = $this->act_id;
+            $where['date'] = ['between',[date('Ymd', strtotime($rule_date[0])),date('Ymd', strtotime($rule_date[1]))]];
+            $countNum = M('Prize_log_v2')->where($where)->count();
+            Writelog('当前1:'.$countNum.'规则:'.$rule['rule_num'],'info','activityv2');
+            return $countNum >= $rule['rule_num'] ? FALSE : TRUE;    
+        }else{
+            $where['date'] = date('Ymd');
+            $where['rule_id'] = $rule['rule_id'];
+            $where['act_id'] = $this->act_id;
+            $countNum = M('Prize_log_v2')->where($where)->count();
+            Writelog('当前2:'.$countNum.'规则:'.$rule['rule_num'],'info','activityv2');
+//            echo M()->getLastSql();die;
+            return $countNum >= $rule['rule_num'] ? FALSE : TRUE;            
+        }        
+    }
+    
+    /**
+     * @desc 不能超过奖品总数
+     */
+    private function _checkGolabRule(&$rule,&$limit_sales)
+    {   
+        if($limit_sales[$rule['rule_prize_id']]['prize_num'] == -1){
+            return TRUE;
+        }
+        $countNum = M('Prize_log_v2')->where(['prize_id'=>$rule['rule_prize_id'],'act_id'=>$this->act_id])->count();
+//        echo M()->getLastSql();die;
+        Writelog('当前3:'.$countNum.'总量:'.$limit_sales[$rule['rule_prize_id']]['prize_num'],'info','activityv2');
+        return $countNum >= $limit_sales[$rule['rule_prize_id']]['prize_num'] ? FALSE : TRUE;         
+    }
+}