Charlie 9 年之前
父节点
当前提交
dc4f2c2d60

+ 0 - 67
www/cs.php

@@ -1,67 +0,0 @@
-<?php
-
-/**
- * @version 1.0
- */
-class CS {
-
-    private $siteId;
-    private $scheme;
-    private $imageDomain = 'c.cnzz.com';
-
-    /**
-     * 
-     * @param Integer $siteId 站点ID
-     */
-    public function __construct($siteId) {
-        $this->setAccount($siteId);
-        $this->initScheme();
-    }
-
-    /**
-     * 设置站点ID
-     * @param type $siteId
-     */
-    public function setAccount($siteId) {
-        $this->siteId = $siteId;
-    }
-
-    private function initScheme() {
-        $this->scheme = $this->getScheme();
-    }
-
-    /**
-     * 得到url中的scheme
-     * @return String
-     */
-    private function getScheme() {
-        return (isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] !== "off") ? 'https://' : 'http://');
-    }
-
-    /**
-     * 
-     * @return String 回传数据的请求字符串
-     */
-    public function trackPageView() {
-        return $this->getImageUrl();
-    }
-
-    private function getImageUrl() {
-        $imageLocation = $this->scheme . $this->imageDomain . '/wapstat.php';
-        $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
-        $query = array();
-        array_push($query, 'siteid=' . $this->siteId * 1);
-        array_push($query, 'r=' . urlencode($referer));
-        array_push($query, 'rnd=' . mt_rand(1, 2147483647));
-        $imageUrl = $imageLocation . '?' . implode('&', $query);
-        return $imageUrl;
-    }
-
-}
-
-function _cnzzTrackPageView($siteId) {
-    $cs = new CS($siteId);
-    return $cs->trackPageView();
-}
-
-?>

+ 2 - 6
www/index.php

@@ -7,15 +7,11 @@
     $server_name = $_SERVER['SERVER_NAME'];
     $application = '';
     $app_name =explode(".",$server_name)[0];
-    if (preg_match('/api/',$app_name)){
-        $application = 'api';
-    }elseif(preg_match('/admin/',$app_name)){
+    if(preg_match('/admin/',$app_name)){
         $application = 'admin';
-    }else{
-        $application = 'common';
     }
     if (trim($env) == 'develop'){
-        define('DB_CONNETC', 'mongodb://192.168.1.192:27017');
+        define('DB_CONNETC', 'mongodb://127.0.0.1:27017');
         $config=dirname(__FILE__).'/protected/config/develop.php';
         $environment = 'develop';
         defined('YII_DEBUG') or define('YII_DEBUG',true);

+ 0 - 213
www/protected/controllers/ChannelCountController.php

@@ -1,213 +0,0 @@
-<?php
-class ChannelCountController extends AdminController{
-    public $layout = 'none';
-    public function actionAll(){   
-        $visitor = Yii::app()->request->getParam('visitor');
-        if($visitor){
-            $coll = 'users';
-        }else{
-            $coll = 'visitors';
-        }
-        $mongo = new MongoClient(DB_CONNETC);
-        $db = $mongo->wozhua_data;//库  
-        $collection = $db->selectCollection($coll);
-        $keys = array("channel" => 1);
-
-        $initial = array("count" => 0);
-
-        $reduce = "function (obj, prev) { prev.count++; }";
-
-        $g = $collection->group($keys, $initial, $reduce);
-        $this->render('all',array('data'=>$g['retval'],'sum'=>$g['count']));
-    }
-
-    public function actionByDay(){
-        $week_data = array();
-        $data['date_str'] = '';
-        $visitor = Yii::app()->request->getParam('visitor');
-        if($visitor){
-            $coll = 'users';
-            $time_condition = 'register_time';
-        }else{
-            $coll = 'visitors';
-            $time_condition = 'first_time';
-        }
-        $mongo = new MongoClient(DB_CONNETC);
-        $db = $mongo->wozhua_data;
-        for($i=6;$i>=0;$i--){
-            $day_start = strtotime(date('Ymd'))-$i*86400;
-            $date = date('m-d',$day_start);
-            $data['date_str'].= '"'.$date.'",';
-            $day_last = $day_start+86400;
-            $collection = $db->selectCollection($coll);
-            $keys = array("channel"=>1); 
-            $initial = array("count"=>0); 
-            $reduce = "function (obj, prev) { prev.count++; }";
-            $condition = array('condition' => array($time_condition => array( '$gte' => $day_start,'$lt' => $day_last)));
-            $g = $collection->group($keys, $initial, $reduce, $condition);
-            $week_data[$date] = $g['retval'];
-        }
-        $channel = array();
-        foreach ($week_data as $value) {
-            if(is_array($value)){
-                foreach ($value as $val) {
-                    if(!empty($val['channel'])&&!in_array($val['channel'],$channel)){
-                        $channel[] = $val['channel'];
-                    }
-                }
-            }
-        }
-        $data['channel_str'] ='';
-        foreach ($channel as $value) {
-            $data['channel_str'].= '"'.$value.'",';
-        }
-        $data['channel_str'] = substr($data['channel_str'],0,mb_strlen($data['channel_str'])-1);
-        $data['date_str'] = substr($data['date_str'],0,mb_strlen($data['date_str'])-1);
-        $data['channel_data'] = array();
-        foreach ($channel as $t_channel) {
-            $data['channel_data'][$t_channel] = '';
-            foreach ($week_data as $key => $value) {
-                foreach ($value as $val) {
-                    if($val['channel']==$t_channel){
-                        $t_count = $val['count'];
-                    }
-                }
-                if (isset($t_count)) {
-                    $data['channel_data'][$t_channel] = $data['channel_data'][$t_channel].$t_count.',';
-                }else{
-                    $data['channel_data'][$t_channel] = $data['channel_data'][$t_channel].'0'.',';
-                }
-                unset($t_count);
-            }
-        }
-        $this->render('view',array('data'=>$data));
-    }
-
-    public function actionByWeek(){
-        $month_data = array();
-        $data['date_str'] = '';
-        $visitor = Yii::app()->request->getParam('visitor');
-        if($visitor){
-            $coll = 'users';
-            $time_condition = 'register_time';
-        }else{
-            $coll = 'visitors';
-            $time_condition = 'first_time';
-        }
-        $mongo = new MongoClient(DB_CONNETC);
-        $db = $mongo->wozhua_data;
-        for($i=4;$i>=0;$i--){
-            $day_start = strtotime(date("Y-m-d",mktime(0,0,0,date("m"),date("d")-date("w")+1,date("Y"))))-$i*604800;
-            $date = date('W',$day_start);
-            $data['date_str'].= '"第'.$date.'周",';
-            $day_last = $day_start+604800;
-            $collection = $db->selectCollection($coll);
-            $keys = array("channel"=>1); 
-            $initial = array("count"=>0); 
-            $reduce = "function (obj, prev) { prev.count++; }";
-            $condition = array('condition' => array($time_condition => array( '$gte' => $day_start,'$lt' => $day_last)));
-            $g = $collection->group($keys, $initial, $reduce, $condition);
-            $month_data[$date] = $g['retval'];
-        }
-        $channel = array();
-        foreach ($month_data as $value) {
-            if(is_array($value)){
-                foreach ($value as $val) {
-                    if(!empty($val['channel'])&&!in_array($val['channel'],$channel)){
-                        $channel[] = $val['channel'];
-                    }
-                }
-            }
-        }
-        $data['channel_str'] ='';
-        foreach ($channel as $value) {
-            $data['channel_str'].= '"'.$value.'",';
-        }
-        $data['channel_str'] = substr($data['channel_str'],0,mb_strlen($data['channel_str'])-1);
-        $data['date_str'] = substr($data['date_str'],0,mb_strlen($data['date_str'])-1);
-        $data['channel_data'] = array();
-        foreach ($channel as $t_channel) {
-            $data['channel_data'][$t_channel] = '';
-            foreach ($month_data as $key => $value) {
-                foreach ($value as $val) {
-                    if($val['channel']==$t_channel){
-                        $t_count = $val['count'];
-                    }
-                }
-                if (isset($t_count)) {
-                    $data['channel_data'][$t_channel] = $data['channel_data'][$t_channel].$t_count.',';
-                }else{
-                    $data['channel_data'][$t_channel] = $data['channel_data'][$t_channel].'0'.',';
-                }
-                unset($t_count);
-            }
-        }
-        $this->render('view',array('data'=>$data));
-    }
-
-    public function actionByMonth(){
-        $month_data = array();
-        $data['date_str'] = '';
-        $visitor = Yii::app()->request->getParam('visitor');
-        if($visitor){
-            $coll = 'users';
-            $time_condition = 'register_time';
-        }else{
-            $coll = 'visitors';
-            $time_condition = 'first_time';
-        }
-        $mongo = new MongoClient(DB_CONNETC);
-        $db = $mongo->wozhua_data;
-        for($i=5;$i>=0;$i--){
-            $this_month = date('m');
-            $temp_month = $this_month-$i;
-            $time_str = date('Y-').$temp_month.'-01';
-            $day_start = strtotime($time_str);
-            $date = date('F',$day_start);
-            $data['date_str'].= '"'.$date.'",';
-            $day_last = strtotime(date('Y-m-d', strtotime(date('Y-m-01', strtotime($time_str)) . ' +1 month -1 day')));
-            $collection = $db->selectCollection($coll);
-            $keys = array("channel"=>1); 
-            $initial = array("count"=>0); 
-            $reduce = "function (obj, prev) { prev.count++; }";
-            $condition = array('condition' => array($time_condition => array( '$gte' => $day_start,'$lt' => $day_last)));
-            $g = $collection->group($keys, $initial, $reduce, $condition);
-            $month_data[$date] = $g['retval'];
-        }
-        $channel = array();
-        foreach ($month_data as $value) {
-            if(is_array($value)){
-                foreach ($value as $val) {
-                    if(!empty($val['channel'])&&!in_array($val['channel'],$channel)){
-                        $channel[] = $val['channel'];
-                    }
-                }
-            }
-        }
-        $data['channel_str'] ='';
-        foreach ($channel as $value) {
-            $data['channel_str'].= '"'.$value.'",';
-        }
-        $data['channel_str'] = substr($data['channel_str'],0,mb_strlen($data['channel_str'])-1);
-        $data['date_str'] = substr($data['date_str'],0,mb_strlen($data['date_str'])-1);
-        $data['channel_data'] = array();
-        foreach ($channel as $t_channel) {
-            $data['channel_data'][$t_channel] = '';
-            foreach ($month_data as $key => $value) {
-                foreach ($value as $val) {
-                    if($val['channel']==$t_channel){
-                        $t_count = $val['count'];
-                    }
-                }
-                if (isset($t_count)) {
-                    $data['channel_data'][$t_channel] = $data['channel_data'][$t_channel].$t_count.',';
-                }else{
-                    $data['channel_data'][$t_channel] = $data['channel_data'][$t_channel].'0'.',';
-                }
-                unset($t_count);
-            }
-        }
-        $this->render('view',array('data'=>$data));
-    }
-
-}

+ 0 - 412
www/protected/controllers/MaterialController.php

@@ -1,412 +0,0 @@
-<?php 
-/**
- * 物资控制器
- * @author zhouxuchen 2015-09-16
- */
-class MaterialController extends AdminController {
-
-    // 物资首页
-    public function actionIndex () {
-        $status_option = Material::$status_option;
-        $unit_option = Material::$unit_option;
-        $enable_option = Material::$enable_option;
-        $status = CommonFn::getComboboxData($status_option, 100, true, 100);
-        $type = CommonFn::getComboboxData($unit_option, 100, false, 0);
-        $enable = CommonFn::getComboboxData($enable_option, 100, true, 100);
-
-        // 服务点信息
-        $criteria = new EMongoCriteria();
-        $cursor = Station::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $parsedRows = Station::model()->parse($rows);
-        $station_data = array();
-        foreach ($parsedRows as $key => $v) {
-            $station_data = array_merge($station_data, array($v['id'] => array('name' => $v['name'])));
-            // $station_data[] = array('name' => $v['name']);
-        }
-
-        $station = CommonFn::getComboboxData($station_data, '', false, '');
-
-        $this->render('index', array(
-            'status'  => $status,
-            'type'    => $type,
-            'enable'  => $enable,
-            'station' => $station
-        ));
-    }
-
-    // 物资列表
-    public function actionList () {
-        $params = CommonFn::getPageParams();
-
-        $id = Yii::app()->request->getParam('id', '');
-        $status = intval(Yii::app()->request->getParam('status', 100));
-        $enable = intval(Yii::app()->request->getParam('enable', 100));
-        $search = Yii::app()->request->getParam('search', '');
-
-        $criteria = new EMongoCriteria($params);
-
-        // 库存状态删选
-        if($status!=100){
-            $criteria->status('==', $status);
-        }
-        // 物资启用状态筛选
-        if($enable!=100){
-            $criteria->enable('==', $enable);
-        }
-
-        if ($search != ''){
-            if (CommonFn::isMongoId($search)){
-                $criteria->_id('==',new MongoId($search));
-            } else {
-                $criteria->name = new MongoRegex('/' . $search . '/');
-            }
-        }
-
-        $cursor = Material::model()->findAll($criteria);
-        $total = $cursor->count();
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $parsedRows = Material::model()->parse($rows);
-
-        echo CommonFn::composeDatagridData($parsedRows, $total);
-    }
-
-    // 编辑物资信息
-    // 若id被传入则物资信息被编辑,若id未传入则新建一个物资信息
-    public function actionEdit () {
-        $id = Yii::app()->request->getParam('id', '');
-
-        $name = Yii::app()->request->getParam('name', '');
-        $unit = intval(Yii::app()->request->getParam('unit', 0));
-        $stockWarnLine = intval(Yii::app()->request->getParam('stockWarnLine', 0));
-        $price = number_format(Yii::app()->request->getParam('price', 0), 2, '.', '');
-        $enable = intval(Yii::app()->request->getParam('enable', 1));
-        $stock = intval(Yii::app()->request->getParam('stock', 0));
-        $remarks = Yii::app()->request->getParam('remarks', '');
-
-        if (!$unit) {
-            CommonFn::requestAjax(false, '请选择单位');
-            die;
-        }
-
-        if(!$id){
-            $material = new Material();
-            $material->addTime = time();
-            $material->stock = $stock;
-        }else{
-            $criteria = new EMongoCriteria();
-            $criteria->_id = new MongoId($id);
-            $material = Material::model()->find($criteria);
-            if (empty($material)){
-                CommonFn::requestAjax(false, '物资不存在');
-                die;
-            }
-        }
-
-        // 直接修改物资,正式使用后该行注释
-        $material->stock = $stock;
-
-        $material->name = $name;
-        $material->unit = $unit;
-        $material->unit_str = $this->unit_str($unit); // 判断单位str
-        $material->price = $price;
-        $material->stockWarnLine = $stockWarnLine;
-        $material->status = $this->status($material->stock, $material->stockWarnLine);
-        $material->status_str = $this->status_str($material->status); //判断库存状态
-        $material->enable = $enable;
-        $material->enable_str = $this->enable_str($enable);
-        $material->remarks = $remarks;
-        
-        $arr_addMaterial = array('name', 'unit_str', 'unit', 'price', 'stock', 'stockWarnLine', 'addTime', 'user', 'status', 'status_str', 'enable', 'enable_str', 'remarks');
-
-        $success = $material->save(true, $arr_addMaterial);
-
-        CommonFn::requestAjax($success, '', array());
-    }
-
-    /**
-     * 出入库操作
-     * @param obj c_user     : criteria for model `User`
-     * @param obj c_material : criteria for model `Material`
-     * @param obj c_object   : criteria for model `User`
-     * @param obj c_station  : criteria for model `Station`
-     */
-    public function actionStock () {
-        $mid = Yii::app()->request->getParam('mid', '');
-        $operate = intval(Yii::app()->request->getParam('operate', 1));
-        $num = intval(Yii::app()->request->getParam('num', 0));
-        $tot_price = Yii::app()->request->getParam('tot_price', 0);
-        $remarks =Yii::app()->request->getParam('remarks', '');
-        $object = Yii::app()->request->getParam('object', '');
-        $sid = Yii::app()->request->getParam('station', '');
-        $time = time();
-
-        if ($mid == '') {
-            CommonFn::requestAjax(false, '请选择物资');
-            die;
-        }
-
-        if ($num <= 0) {
-            CommonFn::requestAjax(false, '数量错误');
-            die;
-        }
-
-        // 用户信息
-        $user = Yii::app()->user;
-        $email = $user->name;
-        $c_user = new EMongoCriteria();
-        $c_user->email = $email;
-        $userInfo = User::model()->find($c_user);
-
-        // 物资基本信息
-        $c_material = new EMongoCriteria();
-        $c_material->_id = new MongoId($mid);
-        $material = Material::model()->find($c_material);
-        if (empty($material)) {
-            CommonFn::requestAjax(false, '物资不存在');
-            die;
-        }
-
-        $stock = new Stock();
-
-        // 所需要的物资数据
-        $lastStock = $material->stock;
-        $price = $material->price;
-
-        // 入库数量及价格
-        $stock->num = $num;
-        $stock->tot_price = $tot_price != 0 ? $tot_price : $num * $price;
-        $stock->lastStock = $lastStock;
-        $stock->newStock = $this->newStock($lastStock, $num, $operate);
-        if ($stock->newStock < 0) {
-            CommonFn::requestAjax(false, '出库操作错误,请检查数量', array());
-            die;
-        }
-
-        if ($operate == 0) {
-            if ($sid == '') {
-                CommonFn::requestAjax(false, '请选择服务点');
-                die;
-            }
-
-            // 目标用户
-            $c_object = new EMongoCriteria();
-            $c_object->name = $object;
-            $objInfo = User::model()->find($c_object);
-            if (empty($objInfo)) {
-                CommonFn::requestAjax(false, '目标用户不存在');
-                die;
-            } else {
-                $stock->object = $objInfo->_id;
-                $stock->objectName = $objInfo->name;
-            }
-
-            // 服务点信息
-            $c_station = new EMongoCriteria();
-            $c_station->_id = new MongoId($sid);
-            $station = Station::model()->find($c_station);
-            if (empty($station)) {
-                CommonFn::requestAjax(false, '服务点不存在');
-                die;
-            }
-            $stock->station = new MongoId($sid);
-            $stock->stationName = $station->name;
-
-            
-            $arr_addStock = array('mid', 'mname', 'operate', 'operate_str', 'user', 'time', 'username', 'num', 'tot_price', 'lastStock', 'newStock', 'remarks', 'object', 'objectName', 'station', 'stationName');
-        } else {
-            $stock->objectName = '公司总库';
-            $stock->stationName = '无';
-
-            $arr_addStock = array('mid', 'mname', 'operate', 'operate_str', 'user', 'time', 'username', 'num', 'tot_price', 'lastStock', 'newStock', 'remarks', 'objectName', 'stationName');
-        }
-
-        $stock->mid = new MongoId($mid);
-        $stock->mname = $material->name;
-        $stock->operate = $operate;
-        $stock->operate_str = $this->operate_str($operate);
-        $stock->user = $userInfo->_id;
-        $stock->username = $userInfo->name;
-        $stock->time = $time;
-
-        $stock->remarks = $remarks;        
-
-        $material->stock = $stock->newStock;
-        $material->status = $this->status($material->stock, $material->stockWarnLine);
-        $material->status_str = $this->status_str($material->status);
-
-        $arr_addMaterial = array('stock', 'status', 'status_str');
-
-        // 增加库存表记录
-        $success_stock = $stock->save(true, $arr_addStock);
-        // 修改物资表记录
-        $success_material = $material->save(true, $arr_addMaterial);
-        // print_r($stock);die;
-
-        CommonFn::requestAjax($success_stock&$success_material, '', array());
-    }
-
-    // 自动填充用户
-    public function actionSelectUser () {
-        $chars = Yii::app()->request->getParam('user', '');
-
-        $MongoDbAuthManager = new CMongoDbAuthManager();
-        $users_id = $MongoDbAuthManager->getAuthUser('技师');
-
-        $criteria = new EMongoCriteria();
-        $criteria->addCond('name', 'or', new MongoRegex('/'.$chars.'/'));
-        $criteria->addCond('email', 'or', new MongoRegex('/'.$chars.'/'));
-
-        $cursor = User::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $index = 0;
-        foreach ($rows as $key => $v) {
-            if (in_array($v['_id'], $users_id)) {
-                $arr[] = array(
-                    'id' => $index,
-                    'data' => $v['name'],
-                    'description' => $v['email'],
-                    'uid' => $v['_id'],
-                );
-                $index++;
-            } else {
-                continue;
-            }
-        }
-
-        if (empty($arr)) {
-            $arr = array(
-                'id' => 0,
-                'data' => '',
-                'description' => '',
-                'uid' => -1,
-            );
-        }
-
-        echo json_encode($arr);
-    }
-
-    // 自动填充物资
-    public function actionSelectMaterial () {
-        $chars = Yii::app()->request->getParam('material', '');
-
-        $criteria = new EMongoCriteria();
-        $criteria->name = new MongoRegex('/'.$chars.'/');
-
-        $cursor = Material::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        if (empty($rows)) {
-            $arr = array(
-                'id' => 0,
-                'data' => ''
-            );
-        } else {
-            foreach ($rows as $key => $v) {
-                $arr[] = array(
-                    'id' => $key,
-                    'data' => $v['name']
-                );
-            }
-        }
-
-        echo json_encode($arr);
-    }
-
-    // 判断单位类型
-    protected function unit_str ($type) {
-        switch ($type) {
-            case 1:
-                $unit_str = '瓶';
-                break;
-            case 2:
-                $unit_str = '袋';
-                break;
-            case 3:
-                $unit_str = '盒';
-                break;
-            case 4:
-                $unit_str = '台';
-                break;
-            case 5:
-                $unit_str = '件';
-                break;
-            case 6:
-                $unit_str = '双';
-                break;
-            default:
-                $unit_str = '未找到相应单位';
-                break;
-        }
-
-        return $unit_str;
-    }
-
-    // 判断库存状态(status)
-    protected function status ($stock, $stockWarnLine) {
-        if ($stock > $stockWarnLine && $stockWarnLine >= 0) {
-            $status = 2;
-        } else if ($stock > 0 && $stock <= $stockWarnLine) {
-            $status = 1;
-        } else if ($stock == 0) {
-            $status = 0;
-        } else {
-            $status = 3;
-        }
-
-        return $status;
-    }
-
-    // 判断库存状态(status_str)
-    protected function status_str ($type) {
-        switch ($type) {
-            case 0:
-                $status_str = '无库存';
-                break;
-            case 1:
-                $status_str = '紧张';
-                break;
-            case 2:
-                $status_str = '充足';
-                break;
-            default:
-                $status_str = '未知';
-                break;
-        }
-
-        return $status_str;
-    }
-
-    // 判断物资是否启用
-    protected function enable_str ($type) {
-        if ($type == 1) {
-            $enable_str = '启用';
-        } else {
-            $enable_str = '停用';
-        }
-
-        return $enable_str;
-    }
-
-    // 判断库存操作
-    protected function operate_str ($type) {
-        if ($type == 0) {
-            $operate_str = '出库';
-        } else {
-            $operate_str = '入库';
-        }
-
-        return $operate_str;
-    }
-
-    // 新库存计算
-    protected function newStock ($lastStock, $num, $operate) {
-        if ($operate == 0) {
-            $newStock = $lastStock - $num;
-        } else {
-            $newStock = $lastStock + $num;
-        }
-
-        return $newStock;
-    }
-}
-?>

+ 0 - 170
www/protected/controllers/MessageController.php

@@ -1,170 +0,0 @@
-<?php
-class MessageController extends AdminController{
-
-    public function actionIndex()
-    {
-        $status = array(
-                        1 => array('name' => '待处理')
-                    );
-        $user_ids = $usernames = array();
-        $sys_user_id =  Yii::app()->params['kefu_user'];      //系统客服账号
-        array_push($user_ids,new MongoId($sys_user_id));
-        $admin_info = $this->getAdminInfo();        //当前后台管理账号
-        if($admin_info){
-            foreach($admin_info['fake_users'] as $fake_user){
-                array_push($user_ids,$fake_user);
-            }
-        }
-
-        if($user_ids){
-            $model = new ZUser();
-            $users = $model->getUserInfo($user_ids,array('id',"user_name"));
-            if($users){
-                foreach($users as $user){
-                    $usernames[(string)$user["_id"]] = array(
-                        'name' => $user['user_name']
-                    );
-                }
-            }
-        }
-        $user_names = CommonFn::getComboboxData($usernames, 10, true,10);
-        $status = CommonFn::getComboboxData($status, 10, true,10);
-
-        $this->render('index', array(
-            'status' => $status,
-            'usernames' => $user_names
-        ));
-    }
-
-    public function actionList(){
-        $params = CommonFn::getPageParams();
-        $page =  Yii::app()->request->getParam('page',1);
-        $search = Yii::app()->request->getParam('search','');
-        $filter_status = Yii::app()->request->getParam('filter_status',0);
-        $filter_user = Yii::app()->request->getParam('filter_user','10');    // 选择全部的默认值
-
-        $from_user_ids = array();
-        $criteria = new EMongoCriteria($params);
-        if ($search != ''){
-            if (CommonFn::isMongoId($search)){
-                $from_user_ids = array(new MongoId($search)); //当搜索项为MongoID时,重置user_ids
-            } else {
-                $user_regex = new MongoRegex('/'.$search.'/');
-                $user_criteria = new EMongoCriteria();
-                $user_criteria->user_name("==", $user_regex);
-                $user = RUser::model()->findAll($user_criteria);
-                foreach ($user as $key => $value) {
-                    array_push($from_user_ids, $value->_id);
-                }
-            }
-
-            $criteria->from_user('in', $from_user_ids);
-        }
-
-        $to_user_ids = array();
-        if($filter_user != '10'){
-            array_push($to_user_ids,new MongoId($filter_user));
-        }
-        //默认为系统客服账号以及当前账号的马甲号
-        if(empty($to_user_ids) && empty($from_user_ids)){
-            array_push($to_user_ids,new MongoId(Yii::app()->params['kefu_user']));
-            $admin_info = $this->getAdminInfo();        //当前后台管理账号
-            if($admin_info){
-                foreach($admin_info['fake_users'] as $fake_user){
-                    array_push($to_user_ids,$fake_user);
-                }
-            }
-        }
-        if (!empty($to_user_ids)) {
-            $criteria->user('in',$to_user_ids);
-        }
-        $criteria->type("==",'message');
-        if($filter_status == 1){
-            $criteria->no_read_count(">",0);
-        }
-        $cursor = ActionCat::model()->findAll($criteria);
-        $total = $cursor->count();
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $parsedRows = ActionCat::model()->parse($rows);
-        echo CommonFn::composeDatagridData($parsedRows, $total);
-    }
-
-    public function actionGetUserMsgList(){
-        $from_user_id = Yii::app()->getRequest()->getParam("from_user_id",'');
-        $to_user_id = Yii::app()->getRequest()->getParam("to_user_id",'');;
-        $page = Yii::app()->request->getParam('page',1);
-        if(!$from_user_id || !$to_user_id){
-            return CommonFn::returnInfo(false,CommonFn::getMessage('user','id_not_exist'),array(),201);
-        }
-        $criteria = new EMongoCriteria();
-        $criteria->from_user('in', array(new MongoId($to_user_id),new MongoId($from_user_id)));
-        $criteria->to_user('in', array(new MongoId($to_user_id),new MongoId($from_user_id)));
-        $criteria->status('==', 1);
-        $cursor = Message::model()->findAll($criteria);
-        $total = $cursor->count();
-        $model = new ZMessage();
-        $data['page'] = $page;
-        $data['from_user'] = $to_user_id;
-        $data['to_user'] = $from_user_id;
-        $result = $model->readMessage($data);
-        $sModel = new Message();
-        $msg_list = array();
-        foreach($result['data']['messages'] as $key => $row){
-            $row['html'] = $sModel->generateMsgHtml($row['type'],$row);
-            $row['from_user']['avatar'] = CommonFn::getQiniuImage($row['from_user']['avatar'],50,50);
-            $msg_list[] = $row;
-        }
-        $msg_list = array_reverse($msg_list);
-        $data = array(
-            'msg_list' => $msg_list,
-            'total' => $total
-        );
-        echo json_encode($data);
-        Yii::app()->end();
-    }
-
-
-    public function actionUnReadCount(){
-        $user_ids = array();
-        $admin_info = $this->getAdminInfo();        //当前后台管理账号
-        if($admin_info){
-            foreach($admin_info['fake_users'] as $fake_user){
-                array_push($user_ids,$fake_user);
-            }
-        }
-        $list = new ARedisList('admin_no_read_reply_'.$admin_info['_id']);
-        $post_unread_count = $list->getCount();
-        // $criteria = new EMongoCriteria();
-        // $criteria->type("==",'message');
-        // $criteria->no_read_count("!=",0);
-        // $criteria->user('in',$user_ids);
-        // $unread = ActionCat::model()->count($criteria);
-        // echo CJSON::encode(array('count' => $unread,'post_unread_count'=>$post_unread_count));
-        echo CJSON::encode(array('count' => 0,'post_unread_count'=>$post_unread_count));
-        Yii::app()->end();
-    }
-
-    public function actionPush(){
-        $title = Yii::app()->request->getParam('title', '');
-        $content = Yii::app()->request->getParam('content', '');
-        $url = Yii::app()->request->getParam('url', '');
-        $stamp = uniqid();
-        $gt_content = [
-            'title' => $title,
-            'content' => $content,
-            'type' => 'custom_url',
-            'data' => [ "url"=>$url],
-            'stamp' => $stamp
-        ];
-        $gt_content = json_encode($gt_content,JSON_UNESCAPED_SLASHES );
-        $pay_load = json_encode(['t'=>'custom_url',"url"=>$url,'stamp' => $stamp],JSON_UNESCAPED_SLASHES );
-        if($title && $url){
-            echo '消息内容:'.$gt_content.'<br/>';
-            echo 'Message:'.$title.$content.'<br/>';
-            echo 'pay_load:'.$pay_load.'<br/>';
-            die();
-        }
-        $this->renderPartial('pushparam',array());
-    }
-
-}

+ 0 - 143
www/protected/controllers/RMessageController.php

@@ -1,143 +0,0 @@
-<?php 
-/**
- * 用户私信管理页面
- * @author zhouxuchen 2016-01-07
- */
-class RMessageController extends AdminController {
-
-    public function actionIndex() {
-        $status_option = Message::$status_option;
-        $status = CommonFn::getComboboxData($status_option, 1, true, 100);
-        $type_option = Message::$type_option;
-        $type = CommonFn::getComboboxData($type_option, 'all', true, 'all');
-
-        $data['status'] = $status;
-        $data['type'] = $type;
-        $this->render('index', $data);
-    }
-
-    public function actionList() {
-        $params = CommonFn::getPageParams();
-        $search = Yii::app()->request->getParam('search', '');
-        $search_from = Yii::app()->request->getParam('search_from', '');
-        $search_to = Yii::app()->request->getParam('search_to', '');
-        $filter_start = Yii::app()->request->getParam('start', '');
-        $filter_end = Yii::app()->request->getParam('end', '');
-        $filter_status = intval(Yii::app()->request->getParam('status', 100));
-        $filter_type = Yii::app()->request->getParam('type', 'all');
-        $filter_is_kennel = intval(Yii::app()->request->getParam('is_kennel', 0));
-
-        // 是否查看商家私信
-        $kennel_manager_list = [];
-        if ($filter_is_kennel) {
-            $criteria = new EMongoCriteria();
-            $criteria->status('==', 1);
-            $managers = KennelManager::model()->findAll($criteria);
-            foreach ($managers as $key => $item) {
-                $kennel_manager_list[] = $item->user;
-            }
-        }
-
-        $criteria = new EMongoCriteria($params);
-
-        // 过滤系统通知
-        $kefu_user = Yii::app()->params['kefu_user'];
-        $sys_user = Yii::app()->params['sys_user'];
-        $notin_user = [
-            new MongoId($kefu_user),
-            new MongoId($sys_user),
-        ];
-        $criteria->from_user('notin', $notin_user);
-        $criteria->to_user('notin', $notin_user);
-
-        if ($kennel_manager_list) {
-            $criteria->from_user('in', $kennel_manager_list);
-            $criteria->to_user('in', $kennel_manager_list);
-        }
-
-        if ($search != '') {
-            $regex = new MongoRegex ('/'.$search.'/');
-            $criteria->content('==', $regex);
-        }
-
-        if ($search_from != '') {
-            if (CommonFn::isMongoId($search_from)) {
-                $criteria->from_user('==', new MongoId($search_from));
-            } else {
-                $regex = new MongoRegex('/'.$search_from.'/');
-                $criteria_from = new EMongoCriteria();
-                $criteria_from->user_name('==', $regex);
-                $cursor = RUser::model()->findAll($criteria_from);
-                foreach ($cursor as $key => $eCursor) {
-                    $from_users[] = $eCursor->_id;
-                }
-                $criteria->from_user('in', $from_users);
-            }
-        }
-
-        if ($search_to != '') {
-            if (CommonFn::isMongoId($search_to)) {
-                $criteria->to_user('==', new MongoId($search_to));
-            } else {
-                $regex = new MongoRegex('/'.$search_to.'/');
-                $criteria_to = new EMongoCriteria();
-                $criteria_to->user_name('==', $regex);
-                $cursor = RUser::model()->findAll($criteria_to);
-                foreach ($cursor as $key => $eCursor) {
-                    $to_users[] = $eCursor->_id;
-                }
-                $criteria->to_user('in', $to_users);
-            }
-        }
-
-        if ($filter_status != 100) {
-            $criteria->status('==', $filter_status);
-        }
-
-        if ($filter_start != '') {
-            $start = strtotime($filter_start);
-            $criteria->time('>=', $start);
-        }
-
-        if ($filter_end != '') {
-            $end = strtotime($filter_end);
-            $criteria->time('<=', $end);
-        }
-
-        if ($filter_type != 'all') {
-            if ($filter_type == 'text') {
-                $criteria->content('!=', '');
-            } else if ($filter_type == 'image') {
-                $criteria->pics('size', 1);
-            } else if ($filter_type == 'voice') {
-                $criteria->voice('exists', true);
-                $criteria->voice('!=', array());
-            } else if ($filter_type == 'video') {
-                $criteria->video('exists', true);
-                $criteria->video('!=', array());
-            }
-        }
-
-        $cursor = Message::model()->findAll($criteria);
-        // $total = $cursor->count();
-        $total = 9999;
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $parsedRows = Message::model()->parse($rows);
-        
-        echo CommonFn::composeDatagridData($parsedRows, $total);
-    }
-
-    public function actionEdit() {
-        $id = Yii::app()->request->getParam('id', '');
-        $status = intval(Yii::app()->request->getParam('status', 1));
-
-        $_id = new MongoId($id);
-        $message = Message::get($_id);
-
-        $message->status = $status;
-
-        $success = $message->save();
-        CommonFn::requestAjax($success, '', array());
-    }
-
-}

+ 0 - 243
www/protected/controllers/StockController.php

@@ -1,243 +0,0 @@
-<?php 
-/**
- * 库存控制器
- * @author zhouxuchen 2015-09-18
- */
-class StockController extends AdminController {
-
-    // 显示库存修改信息首页
-    public function actionIndex () {
-        $operate_option = Stock::$operate_option;
-        $operate = CommonFn::getComboboxData($operate_option, 100, true, 100);
-        $objectName = Yii::app()->request->getParam('objectName', '');
-        $stationName = Yii::app()->request->getParam('stationName', '');
-        $fromStockView = (!empty($objectName) || !empty($stationName)) ? true : false;
-
-        // 服务点信息
-        $criteria = new EMongoCriteria();
-        $cursor = Station::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $parsedRows = Station::model()->parse($rows);
-        $station_data = array();
-        foreach ($parsedRows as $key => $v) {
-            $id = (string)$v['id'];
-            $station_data = array_merge($station_data, array($id => array('name' => $v['name'])));
-        }
-        $station_data = array_merge($station_data, array('noStation' => array('name' => '无')));
-
-        $station = CommonFn::getComboboxData($station_data, 'all', true, 'all');
-
-        $data = array(
-            'operate'       => $operate,
-            'objectName'    => $objectName,
-            'stationName'   => $stationName,
-            'fromStockView' => $fromStockView,
-            'station'       => $station
-        );
-
-        $this->render('index', $data);
-    }
-
-    // 库存操作列表
-    public function actionList () {
-        $params = CommonFn::getPageParams();
-
-        $operate = intval(Yii::app()->request->getParam('operate', 100));
-        $s_mname = Yii::app()->request->getParam('s_mname', '');
-        $s_user = Yii::app()->request->getParam('s_user', '');
-        $date_start = Yii::app()->request->getParam('date_start', '');
-        $date_end = Yii::app()->request->getParam('date_end', '');
-        $station = Yii::app()->request->getParam('station', 'all');
-
-        $criteria = new EMongoCriteria($params);
-
-        // 时间处理
-        if (!empty($date_start) && !empty($date_end)) {
-            // 开始时间处理
-            $timestamp_start = strtotime($date_start);
-            // 结束时间处理,需通过strtotime()增加一天
-            $timestamp_end = strtotime('+1 day', strtotime($date_end));
-
-            $criteria->time('>=', $timestamp_start);
-            $criteria->time('<=', $timestamp_end);
-        }
-
-        // 操作筛选
-        if($operate != 100) {
-            $criteria->operate('==', $operate);
-        }
-
-        // 根据物资名称搜索
-        if ($s_mname != '') {
-            if (CommonFn::isMongoId($s_mname)){
-                $criteria->mid('==',new MongoId($s_mname));
-            } else {
-                $criteria->mname = new MongoRegex('/' . $s_mname . '/');
-            }
-        }
-
-        // 根据目标用户名搜索
-        if ($s_user != '') {
-            if (CommonFn::isMongoId($s_user)){
-                $criteria->object('==', new MongoId($s_user));
-            } else {
-                $criteria->objectName = new MongoRegex('/' . $s_user . '/');
-            }
-        }
-
-        // 根据服务点搜索
-        if ($station != 'all') {
-            if ($station == 'noStation') {
-                $criteria->stationName('==', '无');
-            } else {
-                $criteria->station('==', new MongoId($station));
-            }
-        }
-
-        $cursor = Stock::model()->findAll($criteria);
-        $total = $cursor->count();
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $parsedRows = Stock::model()->parse($rows);
-
-        // $this->p($parsedRows);die;
-
-        echo CommonFn::composeDatagridData($parsedRows, $total);
-    }
-
-    // 编辑库存操作备注
-    public function actionEdit () {
-        // echo "<pre>";
-        // print_r($_POST);die;
-
-        $id         = Yii::app()->request->getParam('id', '');
-        $objectName = Yii::app()->request->getParam('objectName', '');
-        $station    = Yii::app()->request->getParam('station', '');
-        $remarks    = Yii::app()->request->getParam('remarks', ''); 
-
-        $criteria = new EMongoCriteria();
-        $criteria->_id = new MongoId($id);
-        $stock = Stock::model()->find($criteria);
-        if (empty($stock)) {
-            CommonFn::requestAjax(false, '该条操作不存在');
-        }
-
-        $arr_addStocks = array();
-
-        // 获取目标用户信息
-        if ($objectName != $stock->objectName) {
-            $criteria = new EMongoCriteria();
-            $criteria->name = $objectName;
-            $object_info = User::model()->find($criteria);
-
-            if (count($object_info) == 0) {
-                CommonFn::requestAjax(false, '用户不存在,请检查用户名', array());
-                die;
-            }
-
-            $stock->objectName = $objectName;
-            $stock->object = $object_info->_id;
-            $arr_addStocks[] = 'object';
-            $arr_addStocks[] = 'objectName';
-        }
-
-        // 获取服务点信息
-        if ((string)$station != (string)$stock->station) {
-            $station_id = new MongoId($station);
-            $criteria = new EMongoCriteria();
-            $criteria->_id = $station_id;
-            $station_info = Station::model()->find($criteria);
-
-            $stock->stationName = $station_info->name;
-            $stock->station = $station_id;
-            $arr_addStocks[] = 'stationName';
-            $arr_addStocks[] = 'station';
-        }
-
-        $arr_addStocks[] = 'remarks';
-
-        $stock->remarks = $remarks;
-
-        $success = $stock->save(true, $arr_addStocks);
-
-        CommonFn::requestAjax($success, '', array());
-    }
-
-    // 自动填充服务点信息
-    public function actionSelectStation () {
-        $station = Yii::app()->request->getParam('station', '');
-
-        $criteria = new EMongoCriteria();
-        $criteria->name = new MongoRegex('/'.$station.'/');
-
-        $cursor = Station::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-
-        if (empty($rows)) {
-            $arr = array(
-                'id' => 0,
-                'data' => ''
-            );
-        } else {
-            foreach ($rows as $key => $v) {
-                $arr[] = array(
-                    'id' => $key,
-                    'data' => $v['name']
-                );
-            }
-        }
-
-        echo json_encode($arr);
-    }
-
-    /**
-     * 几个私有方法
-     * p           使用<pre>标签打印数据
-     * checkAction 检查减小库存的操作是否超过最小库存量
-     * checkStock  检查库存量所处的状态
-     * unit        判断单位类型
-     */
-    protected function p($arr) {
-        echo '<pre>';
-        print_r($arr);
-        echo '</pre>';
-    }
-
-    // 检查库存是否充足(针对减小库存的操作)
-    protected function checkAction () {
-        // TODO...
-    }
-
-    // 修改库存后检查库存的状态(针对所有操作)
-    protected function checkStock () {
-        // TODO...
-    }
-
-    // 判断单位类型
-    protected function unit ($type) {
-        switch ($type) {
-            case 1:
-                $unit = '瓶';
-                break;
-            case 2:
-                $unit = '袋';
-                break;
-            case 3:
-                $unit = '盒';
-                break;
-            case 4:
-                $unit = '台';
-                break;
-            case 5:
-                $unit = '件';
-                break;
-            default:
-                $unit = '未找到相应单位';
-                break;
-        }
-
-        return $unit;
-    }
-
-}
-
-?>

+ 0 - 686
www/protected/controllers/StockViewStationController.php

@@ -1,686 +0,0 @@
-<?php 
-/**
- * 库存操作统计控制器(根据服务点)
- * @author zhouxuchen 2015-10-08
- */
-class StockViewStationController extends AdminController {
-
-    /**
-     * 首页
-     * 默认显示本周内数据统计及图表
-     */
-    public function actionIndex () {
-        $station = Yii::app()->request->getParam('station', '');
-
-        if ($station != '') {
-            $station = new MongoId($station);
-            $date_end = strtotime(date('Y-m-d', strtotime('+1 day', time())));
-            $date_start = strtotime(date('Y-m-d', strtotime('-6 day', time())));
-
-            $data = $this->getDataByStation($date_start, $date_end, $station);
-            $data_str = $this->getDataStr($data);
-
-            $criteria_station = new EMongoCriteria();
-            $criteria_station->_id('==', $station);
-            $cursor = Station::model()->find($criteria_station);
-            $stationName = $cursor->name;
-
-            $date_arr = $this->getDateArr($date_start, $date_end);
-            $date_str = $this->getTimeStr($date_arr);
-
-            $date_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-        } else {
-            $date_range = '';
-            $date_str = '';
-            $data_str = array('price_count'=>'', 'operate_count'=>'');
-            $station = '';
-            $stationName = '';
-        }
-
-        $station_data = $this->getStationComboboxData();
-
-        $this->render('index', array(
-            'date_range'    => $date_range,
-            'date_str'      => $date_str,
-            'price_count'   => $data_str['price_count'],
-            'operate_count' => $data_str['operate_count'],
-            'station'       => (string)$station,
-            'stationName'   => $stationName,
-            'station_data'  => $station_data
-        ));
-    }
-
-    /**
-     * 显示所有服务点在时间范围内的领取情况
-     * @param string date_start | 开始的时间
-     * @param string date_end   | 结束的时间
-     * @param string date_range | 时间范围,用于前端显示
-     * @param array  data       | 时间范围内服务点、总价统计、操作统计
-     */
-    public function actionAll () {
-        $date_start = Yii::app()->request->getParam('date_start', '');
-        $date_end = Yii::app()->request->getParam('date_end', '');
-        // 默认查询当天数据
-        if (empty($date_start) || empty($date_end)) {
-            $date_range = date('Y-m-d', time());
-            $date_start = strtotime(date('Y-m-d', time()));
-            $date_end = strtotime('+1 day', $date_start);
-        } else {
-            $date_range = $date_start == $date_end ? $date_start : $date_start.'至'.$date_end;
-            $date_start = strtotime($date_start);
-            $date_end = strtotime('+1 day', strtotime($date_end));
-        }
-
-        $data = $this->getAll($date_start, $date_end);
-        $data = $data['data'];
-
-        $price_count_arr = array();
-        $stationName_str = '';
-        foreach ($data as $key => $value) {
-            $stationName_str .= '"'.$value['stationName'].'",';
-            $price_count_arr[$value['stationName']] = $value['price_count'];
-        }
-        $stationName_str = substr($stationName_str, 0, mb_strlen($stationName_str)-1);
-
-        $station_data = $this->getStationComboboxData();
-
-        $this->render('all', array(
-            'date_start'      => $date_start,
-            'date_end'        => $date_end,
-            'date_range'      => $date_range,
-            'stationNames'    => $stationName_str,
-            'price_count_arr' => $price_count_arr,
-            'station'         => '',
-            'station_data'    => $station_data
-        ));
-    }
-
-    /**
-     * 左边列表显示
-     */
-    public function actionList () {
-        $merge_data_days = Yii::app()->request->getParam('merge_data_days', false);
-        $merge_data_weeks = Yii::app()->request->getParam('merge_data_weeks', false);
-        $merge_data_months = Yii::app()->request->getParam('merge_data_months', false);
-
-        $stationName = Yii::app()->request->getParam('stationName', '');
-        $date_start = Yii::app()->request->getParam('date_start', '');
-        $date_end = Yii::app()->request->getParam('date_end', '');
-
-        // 时间为空则查询所有数据
-        if (!empty($date_start) && !empty($date_end)) {
-            $date_start = strtotime($date_start);
-            $date_end = strtotime('+1 day', strtotime($date_end));
-        }
-
-        $data = $this->getAll($date_start, $date_end, $stationName, true, $merge_data_days, $merge_data_weeks, $merge_data_months);
-        $total = $data['total'];
-        $data = $data['data'];
-
-        echo CommonFn::composeDatagridData($data, $total);
-    }
-
-    /**
-     * 根据服务点ID查询本月领取情况
-     */
-    public function actionFindByWeeks () {
-        $station = Yii::app()->request->getParam('station', '');
-        // 默认日期已设,二次开发已预留根据时间调整范围的代码
-        $date_end = strtotime('monday', time());
-        if (strtotime(date('Y-m-d', time())) == $date_end) {
-            $date_end = strtotime('+7 day', $date_end);
-        }
-        $date_start = strtotime('-35 day', $date_end);
-
-        if ($station != '') {
-            $station = new MongoId($station);
-            $criteria_station = new EMongoCriteria();
-            $criteria_station->_id = $station;
-            $cursor = Station::model()->find($criteria_station);
-            $stationName = $cursor->name;
-
-            $week_arr = $this->getWeekArr($date_start, $date_end);
-            $week_str = $this->getTimeStr($week_arr);
-            $data_temp = $this->getDataByStation($date_start, $date_end, $station);
-            $data = $this->parseDataByWeeks($data_temp, $date_start, $date_end);
-            $data_str = $this->getDataStr($data);
-            $date_range = $month_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-        } else {
-            $date_range = '';
-            $week_str = '';
-            $data_str = array('price_count'=>'', 'operate_count'=>'');
-            $station = '';
-            $stationName = '';
-        }
-
-        $station_data = $this->getStationComboboxData();
-
-        $this->render('findByWeeks', array(
-            'date_range'   => $date_range,
-            'weeks'        => $week_str,
-            'price'        => $data_str['price_count'],
-            'operate'      => $data_str['operate_count'],
-            'station'      => (string)$station,
-            'stationName'  => $stationName,
-            'station_data' => $station_data
-        ));
-    }
-
-    /**
-     * 根据用户ID及月份范围查询领取情况
-     */
-    public function actionFindByMonths () {
-        $station = Yii::app()->request->getParam('station', '');
-        $date_end = strtotime(date('Y-m', strtotime('+1 month', time())));
-        $date_start = strtotime(date('Y-m', strtotime('-5 month', time())));
-
-        if ($station != '') {
-            $data_temp = $this->getDataByStation($date_start, $date_end, $station);
-            $data = $this->parseDataByMonths($data_temp, $date_start, $date_end, $station);
-
-            $station = new MongoId($station);
-            $criteria_station = new EMongoCriteria();
-            $criteria_station->_id = $station;
-            $cursor = Station::model()->find($criteria_station);
-            $stationName = $cursor->name;
-
-            $data_str = $this->getDataStr($data);
-            $month_arr = $this->getMonthArr($date_start, $date_end);
-            $month_str = $this->getTimeStr($month_arr);
-            
-            $month_range = date('Y-m', $date_start).'至'.date('Y-m', strtotime('-1 month', $date_end));
-        } else {
-            $month_range = '';
-            $month_str = '';
-            $data_str = array('price_count'=>'', 'operate_count'=>'');
-            $station = '';
-            $stationName = '';
-        }
-
-        $station_data = $this->getStationComboboxData();
-
-        $this->render('findByMonths', array(
-            'month_range'  => $month_range,
-            'month'        => $month_str,
-            'price'        => $data_str['price_count'],
-            'operate'      => $data_str['operate_count'],
-            'station'      => (string)$station,
-            'stationName'  => $stationName,
-            'station_data' => $station_data
-        ));
-    }
-
-
-    /**
-     * ----------------------------------
-     *
-     *      私有方法,对数据进行整理
-     * 
-     * ----------------------------------
-     */
-
-    /**
-     * 获取所有数据的统计
-     * @param  boolean $empty_data        : 查询的stock结果为空时是否记录
-     * @param  boolean $merge_data_days   : 是否在结果中记录时间范围内(按照天)的单服务点数据
-     * @param  boolean $merge_data_weeks  : 是否在结果中记录时间范围内(按照周)的单服务点数据
-     * @param  boolean $merge_data_months : 是否在结果中记录时间范围内(按照月)的单服务点数据
-     */
-    private function getAll($date_start = '', $date_end = '', $stationName = '', $empty_data = false, $merge_data_days = false, $merge_data_weeks = false, $merge_data_months = false) {
-        $params = CommonFn::getPageParams();
-
-        $data = array();
-        $criteria_station = new EMongoCriteria($params);
-
-        $criteria_station->name = new MongoRegex('/'.$stationName.'/');
-        $cursor = Station::model()->findAll($criteria_station);
-        $total = count($cursor);
-        $stations = CommonFn::getRowsFromCursor($cursor);
-
-        if (empty($stations)) {
-            return $data;
-        }
-
-        foreach ($stations as $key => $value) {
-            $criteria_stock = new EMongoCriteria();
-            $criteria_stock->station = $value['_id'];
-            // 时间为空则查询所有数据
-            if (!empty($date_start) && !empty($date_end)) {
-                $criteria_stock->time('>=', intval($date_start));
-                $criteria_stock->time('<', intval($date_end));
-            }
-            $criteria_stock->sort('time', EMongoCriteria::SORT_ASC);
-
-            $cursor = Stock::model()->findAll($criteria_stock);
-            $stock = CommonFn::getRowsFromCursor($cursor);
-
-            // 若查询数据为空则continue
-            if (empty($stock)) {
-                // 若$empty_data 及$merge_data_days 为真,则加入空数据(针对列表及默认柱状图)
-                if ($empty_data) {
-                    $data_temp = array(
-                        'price_count' => 0,
-                        'operate_count' => 0,
-                        'station' => (string)$value['_id'],
-                        'stationName' => $value['name'],
-                    );
-
-                    // 按照每天整合数据
-                    if ($merge_data_days) {
-                        $date_range = date('Y-m-d', $date_start);
-                        $date_range .= '至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                        $date_arr = $this->getDateArr($date_start, $date_end);
-                        $price_count_arr = array();
-                        $operate_count_arr = array();
-                        foreach ($date_arr as $k => $v) {
-                            array_push($price_count_arr, 0);
-                            array_push($operate_count_arr, 0);
-                        }
-
-                        $data_temp['data']['date_range'] = $date_range;
-                        $data_temp['data']['price_count'] = $price_count_arr;
-                        $data_temp['data']['operate_count'] = $operate_count_arr;
-                        $data_temp['data']['date_arr'] = $date_arr;
-                    // 按照每周整合数据
-                    } else if ($merge_data_weeks) {
-                        $date_end = strtotime('monday', time());
-                        if (strtotime(date('Y-m-d', time())) == $date_end) {
-                            $date_end = strtotime('+7 day', $date_end);
-                        }
-                        $date_start = strtotime('-35 day', $date_end);
-                        $date_range = $date_range = $month_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                        $week_str = $this->getWeekArr($date_start, $date_end);
-                        $price_count_arr = array();
-                        $operate_count_arr = array();
-                        foreach ($week_arr as $k => $v) {
-                            array_push($price_count_arr, 0);
-                            array_push($operate_count_arr, 0);
-                        }
-
-                        $data_temp['data']['price_count'] = $price_count_arr;
-                        $data_temp['data']['operate_count'] = $operate_count_arr;
-                        $data_temp['data']['week_arr'] = $week_arr;
-                        $data_temp['data']['date_range'] = $date_range;
-                    // 按照每月整合数据
-                    } else if ($merge_data_months) {
-                        $date_end = strtotime(date('Y-m', strtotime('+1 month', time())));
-                        $date_start = strtotime(date('Y-m', strtotime('-5 month', time())));
-                        $month_range = date('Y-m', $date_start).'至'.date(date('Y-m', strtotime('-1 month', $date_end)));
-
-                        $month_arr = $this->getMonthArr($date_start, $date_end);
-                        $price_count_arr = array();
-                        $operate_count_arr = array();
-                        foreach ($month_arr as $k => $v) {
-                            array_push($price_count_arr, 0);
-                            array_push($operate_count_arr, 0);
-                        }
-
-                        $data_temp['data']['price_count'] = $price_count_arr;
-                        $data_temp['data']['operate_count'] = $operate_count_arr;
-                        $data_temp['data']['month_arr'] = $month_arr;
-                        $data_temp['data']['month_range'] = $month_range;
-                    }
-
-                    $data[] = $data_temp;
-                }
-                
-                continue;
-            }
-
-            $data_temp = array();
-            $data_temp['price_count'] = 0;
-            $data_temp['operate_count'] = 0;
-            foreach ($stock as $k => $v) {
-                $data_temp['price_count'] += $v['tot_price'];
-                $data_temp['operate_count']++;
-            }
-            $data_temp['station'] = (string)$value['_id'];
-            $data_temp['stationName'] = $value['name'];
-
-            // 判断并加入每个服务点时间范围内的统计情况(按照天)
-            if ($merge_data_days) {
-                $date_range = date('Y-m-d', $date_start);
-                $date_range .= '至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                $data_station_temp_days = $this->parseDataByDays($stock, $date_start, $date_end);
-
-                $date_arr = $this->getDateArr($date_start, $date_end);
-
-                $data_temp['data']['date_range'] = $date_range;
-                
-                $price_count_arr = array();
-                $operate_count_arr = array();
-                foreach ($data_station_temp_days as $key => $value) {
-                    array_push($price_count_arr, $value['price_count']);
-                    array_push($operate_count_arr, $value['operate_count']);
-                }
-
-                $data_temp['data']['price_count'] = $price_count_arr;
-                $data_temp['data']['operate_count'] = $operate_count_arr;
-                $data_temp['data']['date_arr'] = $date_arr;
-            } else if ($merge_data_weeks) {
-                // 默认查询近一个月数据
-                $date_end = strtotime('monday', time());
-                if (strtotime(date('Y-m-d', time())) == $date_end) {
-                    $date_end = strtotime('+7 day', $date_end);
-                }
-                $date_start = strtotime('-35 day', $date_end);
-                $date_range = $date_range = $month_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                $data_station_temp = $this->parseDataByDays($stock, $date_start, $date_end);
-                $data_station_temp_weeks = $this->parseDataByWeeks($data_station_temp, $date_start, $date_end);
-
-                $week_arr = $this->getWeekArr($date_start, $date_end);
-
-                $price_count_arr = array();
-                $operate_count_arr = array();
-                foreach ($data_station_temp_weeks as $key => $value) {
-                    array_push($price_count_arr, $value['price_count']);
-                    array_push($operate_count_arr, $value['operate_count']);
-                }
-
-                $data_temp['data']['price_count'] = $price_count_arr;
-                $data_temp['data']['operate_count'] = $operate_count_arr;
-                $data_temp['data']['week_arr'] = $week_arr;
-                $data_temp['data']['date_range'] = $date_range;
-            // 判断并加入每个服务点时间范围内的统计情况(按照月)
-            } else if ($merge_data_months) {
-                // 默认查询最近半年数据
-                $date_end = strtotime(date('Y-m', strtotime('+1 month', time())));
-                $date_start = strtotime(date('Y-m', strtotime('-5 month', time())));
-                $month_range = date('Y-m', $date_start).'至'.date(date('Y-m', strtotime('-1 month', $date_end)));
-
-                $data_station_temp = $this->parseDataByDays($stock, $date_start, $date_end);
-                $data_station_temp_months = $this->parseDataByMonths($data_station_temp, $date_start, $date_end);
-
-                $month_arr = $this->getMonthArr($date_start, $date_end);
-
-                $price_count_arr = array();
-                $operate_count_arr = array();
-                foreach ($data_station_temp_months as $key => $value) {
-                    array_push($price_count_arr, $value['price_count']);
-                    array_push($operate_count_arr, $value['operate_count']);
-                }
-
-                $data_temp['data']['price_count'] = $price_count_arr;
-                $data_temp['data']['operate_count'] = $operate_count_arr;
-                $data_temp['data']['month_arr'] = $month_arr;
-                $data_temp['data']['month_range'] = $month_range;
-            }
-            
-
-            $data[] = $data_temp;
-        }
-
-        $data = array('data' => $data, 'total' => $total);
-
-        return $data;
-    }
-
-    /**
-     * 获取单服务点时间范围内所有数据(Y轴数据)
-     * 按照日期归类
-     * @param timestamp $date_start  : 开始时间
-     * @param timestamp $date_end    : 结束时间
-     * @param MongoID   $station     : 服务点ID
-     */
-    private function getDataByStation ($date_start, $date_end, $station) {
-        $data = array();
-        $date_index = $date_start;
-
-        $criteria = new EMongoCriteria();
-        $criteria->time('>=', $date_start);
-        $criteria->time('<', $date_end);
-        $criteria->station('==', $station);
-        $criteria->sort('time', EMongoCriteria::SORT_ASC);
-
-        $cursor = Stock::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-
-        $rows_count = count($rows);
-        $rows_index = 0;
-        while ($date_index < $date_end) {
-            $data_temp = array(
-                'date' => $date_index,
-                'price_count' => 0,
-                'operate_count'=> 0
-            );
-            while ($rows_index < $rows_count) {
-                if ($date_index <= $rows[$rows_index]['time'] && 
-                    $rows[$rows_index]['time'] < strtotime('+1 day', $date_index)) {
-                    $data_temp['price_count'] += $rows[$rows_index]['tot_price'];
-                    $data_temp['operate_count']++;
-                } else {
-                    break;
-                }
-
-                $rows_index++;
-            }
-
-            $data[] = $data_temp;
-            $date_index = strtotime('+1 day', $date_index);
-        }
-
-        return $data;
-    }
-
-    /**
-     * 根据查询Stock表获得的Rows整理数据,按照每天分类
-     * 减少与Mongo的交互,提高性能
-     * @param  array     $rows       : 从Stock表查询的单服务点数据
-     * @param  timestamp $date_start : 开始的时间
-     * @param  timestamp $date_end   : 结束的时间
-     * @return array     $data       : 返回的数据
-     */
-    private function parseDataByDays ($rows, $date_start, $date_end) {
-        $date_index = $date_start;
-        $rows_count = count($rows);
-        $rows_index = 0;
-
-        while ($date_index < $date_end) {
-            $data_temp = array(
-                'date' => $date_index,
-                'price_count' => 0,
-                'operate_count'=> 0
-            );
-
-            while ($rows_index < $rows_count) {
-                if ($date_index <= $rows[$rows_index]['time'] && 
-                    $rows[$rows_index]['time'] < strtotime('+1 day', $date_index)) {
-                    $data_temp['price_count'] += $rows[$rows_index]['tot_price'];
-                    $data_temp['operate_count']++;
-                } else {
-                    break;
-                }
-
-                $rows_index++;
-            }
-
-            $data[] = $data_temp;
-            $date_index = strtotime('+1 day', $date_index);
-        }
-
-        return $data;
-    }
-
-    /**
-     * 按照每周整理单服务点数据
-     */
-    private function parseDataByWeeks ($rows='', $date_start, $date_end, $station='') {
-        if (empty($rows) && $station != '') {
-            $station = new MongoId($station);
-            $rows = $this->getDataByStation($date_start, $date_end, $station);
-        }
-
-        $range = ($date_end - $date_start)/3600/24/7;
-        $data = array();
-
-        $rows_index = 0;
-        $day_count = 1;
-        for ($data_index=0; $data_index < $range; $data_index++) {
-            $data_temp = array(
-                'price_count' => 0,
-                'operate_count' => 0,
-            );
-
-            while ($day_count%8 != 0) {
-                $data_temp['price_count'] += $rows[$rows_index]['price_count'];
-                $data_temp['operate_count'] += $rows[$rows_index]['operate_count'];
-                $rows_index++;
-                $day_count++;
-            }
-
-            $data[] = $data_temp;
-            $day_count = 1;
-        }
-
-        return $data;
-    }
-
-    /**
-     * 按照月份整理单用户数据
-     * @param $date_start timestamp : 开始时间
-     * @param $date_end   timestamp : 结束时间
-     * @param $station    MongoID   : 服务点ID
-     */
-    private function parseDataByMonths ($rows='', $date_start, $date_end, $station='') {
-        if (empty($rows) && $station != '') {
-            $station = new MongoId($station);
-            $rows = $this->getDataByStation($date_start, $date_end, $station);
-        }
-
-        $range = intval(date('m', $date_end)) - intval(date('m', $date_start));
-        $num_of_days = array();
-        for ($i=0; $i<$range; $i++) {
-            $num_of_days[$i] = (strtotime('+'.($i+1).' month', $date_start) - strtotime('+'.$i.' month', $date_start))/3600/24;
-        }
-
-        $data = array();
-        $data_index = 0;
-        $day_count = 0;
-        foreach ($num_of_days as $key => $value) {
-            $day_count += $value;
-            $data_temp = array(
-                'price_count' => 0,
-                'operate_count' => 0
-            );
-
-            while ($data_index < $day_count) {
-                $data_temp['price_count'] += $rows[$data_index]['price_count'];
-                $data_temp['operate_count'] += $rows[$data_index]['operate_count'];
-                $data_index++;
-            }
-
-            $data[] = $data_temp;
-        }
-
-        return $data;
-    }
-
-    /**
-     * 将数据转换为字符串
-     * @param $data array : 需要转换为字符串的数据
-     */
-    private function getDataStr ($data) {
-        $data_str = array(
-            'price_count' => '',
-            'operate_count' => ''
-        );
-
-        $price_count = '';
-        $operate_count = '';
-
-        foreach ($data as $key => $value) {
-            $price_count .= '"'.$value['price_count'].'",';
-            $operate_count .= '"'.$value['operate_count'].'",';
-        }
-
-        $price_count = substr($price_count, 0, strlen($price_count)-1);
-        $operate_count = substr($operate_count, 0, strlen($operate_count)-1);
-        $data_str['price_count'] = $price_count;
-        $data_str['operate_count'] = $operate_count;
-
-        return $data_str;
-    }
-
-    /**
-     * 将时间范围数组转换为字符串
-     * @param  array  $data     : 待转换数据
-     * @return string $data_str : 转换后数据
-     */
-    private function getTimeStr ($data) {
-        $data_str = '';
-        foreach ($data as $key => $value) {
-            $data_str .= '"'.$value.'",';
-        }
-        $data_str = substr($data_str, 0, strlen($data_str)-1);
-
-        return $data_str;
-    }
-
-    /**
-     * 获取日期数组
-     */
-    private function getDateArr ($date_start, $date_end) {
-        $date_arr = array();
-        $date_index = $date_start;
-        while ($date_index < $date_end) {
-            $date_arr[] = date('m-d', $date_index);
-            $date_index = strtotime('+1 day', $date_index);
-        }
-
-        return $date_arr;
-    }
-
-    /**
-     * 获取周数组
-     */
-    private function getWeekArr ($date_start, $date_end) {
-        $week_arr = array();
-        $date_index = $date_start;
-        do {
-            $week_temp = date('m-d', $date_index);
-            $date_index = strtotime('+7 day', $date_index);
-            $week_temp .= '至'.date('m-d', strtotime('-1 day', $date_index));
-
-            $week_arr[] = $week_temp;
-        } while ($date_index < $date_end);
-
-        return $week_arr;
-    }
-
-    /**
-     * 获取月份数组
-     */
-    private function getMonthArr ($date_start, $date_end) {
-        $month_arr = array();
-        $date_index = $date_start;
-        while ($date_index < $date_end) {
-            $month_arr[] = intval(date('m', $date_index)).'月';
-            $date_index = strtotime('+1 month', $date_index);
-        }
-
-        return $month_arr;
-    }
-
-    /**
-     * 获取station的combobox数据
-     */
-    private function getStationComboboxData () {
-        $criteria = new EMongoCriteria();
-        $cursor = Station::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-        $parsedRows = Station::model()->parse($rows);
-        $station_data = array();
-        foreach ($parsedRows as $key => $v) {
-            $station_data = array_merge($station_data, array($v['name'] => array('name' => $v['name'])));
-        }
-
-        $station = CommonFn::getComboboxData($station_data, '全部', true, '');
-
-        return $station;
-    }
-}
-?>

+ 0 - 659
www/protected/controllers/StockViewUserController.php

@@ -1,659 +0,0 @@
-<?php 
-/**
- * 库存操作统计控制器(根据用户)
- * @author zhouxuchen 2015-09-29
- */
-class StockViewUserController extends AdminController {
-
-    /**
-     * 首页acion
-     * 默认显示本周内数据统计及图表
-     */
-    public function actionIndex () {
-        $object = intval(Yii::app()->request->getParam('object', 0));
-
-        if ($object != 0) {
-            $date_end = strtotime(date('Y-m-d', strtotime('+1 day', time())));
-            $date_start = strtotime(date('Y-m-d', strtotime('-6 day', time())));
-
-            $data = $this->getDataByUser($date_start, $date_end, $object);
-            $data_str = $this->getDataStr($data);
-
-            $criteria_user = new EMongoCriteria();
-            $criteria_user->_id('==', $object);
-            $cursor = User::model()->find($criteria_user);
-            $objectName = $cursor->name;
-
-            $date_arr = $this->getDateArr($date_start, $date_end);
-            $date_str = $this->getTimeStr($date_arr);
-
-            $date_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-        } else {
-            $date_range = '';
-            $date_str = '';
-            $data_str = array('price_count'=>'', 'operate_count'=>'');
-            $object = 0;
-            $objectName = '';
-        }
-
-        $this->render('index', array(
-            'date_range'    => $date_range,
-            'date_str'      => $date_str,
-            'price_count'   => $data_str['price_count'],
-            'operate_count' => $data_str['operate_count'],
-            'object'        => $object,
-            'objectName'    => $objectName
-        ));
-    }
-
-    /**
-     * 显示所有用户在时间范围内的领取情况
-     * @param string date_start | 开始的时间
-     * @param string date_end   | 结束的时间
-     * @param string date_range | 时间范围,用于前端显示
-     * @param array  data       | 时间范围内用户名、总价统计、操作统计
-     */
-    public function actionAll () {
-        $date_start = Yii::app()->request->getParam('date_start', '');
-        $date_end = Yii::app()->request->getParam('date_end', '');
-        // 默认查询当天数据
-        if (empty($date_start) || empty($date_end)) {
-            $date_range = date('Y-m-d', time());
-            $date_start = strtotime(date('Y-m-d', time()));
-            $date_end = strtotime('+1 day', $date_start);
-        } else {
-            $date_range = $date_start == $date_end ? $date_start : $date_start.'至'.$date_end;
-            $date_start = strtotime($date_start);
-            $date_end = strtotime('+1 day', strtotime($date_end));
-        }
-
-        $data = $this->getAll($date_start, $date_end);
-        $data = $data['data'];
-
-        $price_count_arr = array();
-        $objectName_str = '';
-        foreach ($data as $key => $value) {
-            $objectName_str .= '"'.$value['objectName'].'",';
-            $price_count_arr[$value['objectName']] = $value['price_count'];
-        }
-        $objectName_str = substr($objectName_str, 0, mb_strlen($objectName_str)-1);
-
-        $this->render('all', array(
-            'date_start'      => $date_start,
-            'date_end'        => $date_end,
-            'date_range'      => $date_range,
-            'objectNames'     => $objectName_str,
-            'price_count_arr' => $price_count_arr,
-            'object'          => ''
-        ));
-    }
-
-    /**
-     * 左边列表显示
-     * @param criteria_stockViewUser : criteria for StockViewUser
-     * @param criteria_users         : criteria for User
-     */
-    public function actionList () {
-        $merge_data_days = Yii::app()->request->getParam('merge_data_days', false);
-        $merge_data_weeks = Yii::app()->request->getParam('merge_data_weeks', false);
-        $merge_data_months = Yii::app()->request->getParam('merge_data_months', false);
-
-        $objectName = Yii::app()->request->getParam('s_user', '');
-        $date_start = Yii::app()->request->getParam('date_start', '');
-        $date_end = Yii::app()->request->getParam('date_end', '');
-
-        // 时间为空则查询所有数据
-        if (!empty($date_start) && !empty($date_end)) {
-            $date_start = strtotime($date_start);
-            $date_end = strtotime('+1 day', strtotime($date_end));
-        }
-
-        $data = $this->getAll($date_start, $date_end, $objectName, true, $merge_data_days, $merge_data_weeks, $merge_data_months);
-        $total = $data['total'];
-        $data = $data['data'];
-        echo CommonFn::composeDatagridData($data, $total);
-    }
-
-    /**
-     * 根据用户ID查询本月领取情况
-     */
-    public function actionFindByWeeks () {
-        $object = intval(Yii::app()->request->getParam('object', 0));
-        // 默认日期已设,二次开发已预留根据时间调整范围的代码
-        $date_end = strtotime('monday', time());
-        if (strtotime(date('Y-m-d', time())) == $date_end) {
-            $date_end = strtotime('+7 day', $date_end);
-        }
-        $date_start = strtotime('-35 day', $date_end);
-
-        if ($object != 0) {
-            $criteria_user = new EMongoCriteria();
-            $criteria_user->_id = $object;
-            $cursor = User::model()->find($criteria_user);
-            $objectName = $cursor->name;
-
-            $week_arr = $this->getWeekArr($date_start, $date_end);
-            $week_str = $this->getTimeStr($week_arr);
-            $data_temp = $this->getDataByUser($date_start, $date_end, $object);
-            $data = $this->parseDataByWeeks($data_temp, $date_start, $date_end);
-            $data_str = $this->getDataStr($data);
-            $date_range = $month_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-        } else {
-            $date_range = '';
-            $week_str = '';
-            $data_str = array('price_count'=>'', 'operate_count'=>'');
-            $object = 0;
-            $objectName = '';
-        }
-
-        $this->render('findByWeeks', array(
-            'date_range' => $date_range,
-            'weeks'      => $week_str,
-            'price'      => $data_str['price_count'],
-            'operate'    => $data_str['operate_count'],
-            'object'     => $object,
-            'objectName' => $objectName
-        ));
-    }
-
-    /**
-     * 根据用户ID及月份范围查询领取情况
-     */
-    public function actionFindByMonths () {
-        $object = intval(Yii::app()->request->getParam('object', 0));
-        $date_end = strtotime(date('Y-m', strtotime('+1 month', time())));
-        $date_start = strtotime(date('Y-m', strtotime('-5 month', time())));
-
-        if ($object != 0) {
-            $data_temp = $this->getDataByUser($date_start, $date_end, $object);
-            $data = $this->parseDataByMonths($data_temp, $date_start, $date_end, $object);
-
-            $criteria_user = new EMongoCriteria();
-            $criteria_user->_id = $object;
-            $cursor = User::model()->find($criteria_user);
-            $objectName = $cursor->name;
-
-            $data_str = $this->getDataStr($data);
-            $month_arr = $this->getMonthArr($date_start, $date_end);
-            $month_str = $this->getTimeStr($month_arr);
-            
-            $month_range = date('Y-m', $date_start).'至'.date('Y-m', strtotime('-1 month', $date_end));
-        } else {
-            $month_range = '';
-            $month_str = '';
-            $data_str = array('price_count'=>'', 'operate_count'=>'');
-            $object = 0;
-            $objectName = '';
-        }
-
-        $this->render('findByMonths', array(
-            'month_range' => $month_range,
-            'month' => $month_str,
-            'price' => $data_str['price_count'],
-            'operate' => $data_str['operate_count'],
-            'object' => $object,
-            'objectName' => $objectName
-        ));
-    }
-
-    /**
-     * ----------------------------------
-     *
-     *      私有方法,对数据进行整理
-     * 
-     * ----------------------------------
-     */
-
-    /**
-     * 获取所有数据的统计
-     * @param  boolean $empty_data        : 查询的stock结果为空时是否记录
-     * @param  boolean $merge_data_days   : 是否在结果中记录时间范围内(按照天)的单用户数据
-     * @param  boolean $merge_data_weeks  : 是否在结果中记录时间范围内(按照周)的单用户数据
-     * @param  boolean $merge_data_months : 是否在结果中记录时间范围内(按照月)的单用户数据
-     */
-    private function getAll($date_start = '', $date_end = '', $objectName = '', $empty_data = false, $merge_data_days = false, $merge_data_weeks = false, $merge_data_months = false) {
-        $params = CommonFn::getPageParams();
-
-        $data = array();
-        $criteria_users = new EMongoCriteria($params);
-
-        // 筛选为技师
-        $MongoDbAuthManager = new CMongoDbAuthManager();
-        $users_id = $MongoDbAuthManager->getAuthUser('技师');
-
-        $criteria_users->name = new MongoRegex('/'.$objectName.'/');
-        $criteria_users->_id('in', $users_id);
-
-        $cursor = User::model()->findAll($criteria_users);
-        $total = count($cursor);
-        $users = CommonFn::getRowsFromCursor($cursor);
-
-        if (empty($users)) {
-            $data = array('total' => 0, 'data' => array());
-            return $data;
-        }
-
-        foreach ($users as $key => $value) {
-            $criteria_stock = new EMongoCriteria();
-            $criteria_stock->object = $value['_id'];
-            // 时间为空则查询所有数据
-            if (!empty($date_start) && !empty($date_end)) {
-                $criteria_stock->time('>=', intval($date_start));
-                $criteria_stock->time('<', intval($date_end));
-            }
-            $criteria_stock->sort('time', EMongoCriteria::SORT_ASC);
-
-            $cursor = Stock::model()->findAll($criteria_stock);
-            $stock = CommonFn::getRowsFromCursor($cursor);
-
-            // 若查询数据为空则continue
-            if (empty($stock)) {
-                // 若$empty_data 及$merge_data_days 为真,则加入空数据(针对列表及默认柱状图)
-                if ($empty_data) {
-                    $data_temp = array(
-                        'price_count' => 0,
-                        'operate_count' => 0,
-                        'object' => $value['_id'],
-                        'objectName' => $value['name'],
-                    );
-
-                    // 按照每天整合数据
-                    if ($merge_data_days) {
-                        $date_range = date('Y-m-d', $date_start);
-                        $date_range .= '至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                        $date_arr = $this->getDateArr($date_start, $date_end);
-                        $price_count_arr = array();
-                        $operate_count_arr = array();
-                        foreach ($date_arr as $k => $v) {
-                            array_push($price_count_arr, 0);
-                            array_push($operate_count_arr, 0);
-                        }
-
-                        $data_temp['data']['date_range'] = $date_range;
-                        $data_temp['data']['price_count'] = $price_count_arr;
-                        $data_temp['data']['operate_count'] = $operate_count_arr;
-                        $data_temp['data']['date_arr'] = $date_arr;
-                    // 按照每周整合数据
-                    } else if ($merge_data_weeks) {
-                        $date_end = strtotime('monday', time());
-                        if (strtotime(date('Y-m-d', time())) == $date_end) {
-                            $date_end = strtotime('+7 day', $date_end);
-                        }
-                        $date_start = strtotime('-35 day', $date_end);
-                        $date_range = $date_range = $month_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                        $week_str = $this->getWeekArr($date_start, $date_end);
-                        $price_count_arr = array();
-                        $operate_count_arr = array();
-                        foreach ($week_arr as $k => $v) {
-                            array_push($price_count_arr, 0);
-                            array_push($operate_count_arr, 0);
-                        }
-
-                        $data_temp['data']['price_count'] = $price_count_arr;
-                        $data_temp['data']['operate_count'] = $operate_count_arr;
-                        $data_temp['data']['week_arr'] = $week_arr;
-                        $data_temp['data']['date_range'] = $date_range;
-                    // 按照每月整合数据
-                    } else if ($merge_data_months) {
-                        $date_end = strtotime(date('Y-m', strtotime('+1 month', time())));
-                        $date_start = strtotime(date('Y-m', strtotime('-5 month', time())));
-                        $month_range = date('Y-m', $date_start).'至'.date(date('Y-m', strtotime('-1 month', $date_end)));
-
-                        $month_arr = $this->getMonthArr($date_start, $date_end);
-                        $price_count_arr = array();
-                        $operate_count_arr = array();
-                        foreach ($month_arr as $k => $v) {
-                            array_push($price_count_arr, 0);
-                            array_push($operate_count_arr, 0);
-                        }
-
-                        $data_temp['data']['price_count'] = $price_count_arr;
-                        $data_temp['data']['operate_count'] = $operate_count_arr;
-                        $data_temp['data']['month_arr'] = $month_arr;
-                        $data_temp['data']['month_range'] = $month_range;
-                    }
-
-                    $data[] = $data_temp;
-                }
-                
-                continue;
-            }
-
-            $data_temp = array();
-            $data_temp['price_count'] = 0;
-            $data_temp['operate_count'] = 0;
-            foreach ($stock as $k => $v) {
-                $data_temp['price_count'] += $v['tot_price'];
-                $data_temp['operate_count']++;
-            }
-            $data_temp['object'] = $value['_id'];
-            $data_temp['objectName'] = $value['name'];
-
-            // 判断并加入每个用户时间范围内的统计情况(按照天)
-            if ($merge_data_days) {
-                $date_range = date('Y-m-d', $date_start);
-                $date_range .= '至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                $data_user_temp_days = $this->parseDataByDays($stock, $date_start, $date_end);
-
-                $date_arr = $this->getDateArr($date_start, $date_end);
-
-                $data_temp['data']['date_range'] = $date_range;
-                
-                $price_count_arr = array();
-                $operate_count_arr = array();
-                foreach ($data_user_temp_days as $key => $value) {
-                    array_push($price_count_arr, $value['price_count']);
-                    array_push($operate_count_arr, $value['operate_count']);
-                }
-
-                $data_temp['data']['price_count'] = $price_count_arr;
-                $data_temp['data']['operate_count'] = $operate_count_arr;
-                $data_temp['data']['date_arr'] = $date_arr;
-            } else if ($merge_data_weeks) {
-                // 默认查询近一个月数据
-                $date_end = strtotime('monday', time());
-                if (strtotime(date('Y-m-d', time())) == $date_end) {
-                    $date_end = strtotime('+7 day', $date_end);
-                }
-                $date_start = strtotime('-35 day', $date_end);
-                $date_range = $date_range = $month_range = date('Y-m-d', $date_start).'至'.date('Y-m-d', strtotime('-1 day', $date_end));
-
-                $data_user_temp = $this->parseDataByDays($stock, $date_start, $date_end);
-                $data_user_temp_weeks = $this->parseDataByWeeks($data_user_temp, $date_start, $date_end);
-
-                $week_arr = $this->getWeekArr($date_start, $date_end);
-
-                $price_count_arr = array();
-                $operate_count_arr = array();
-                foreach ($data_user_temp_weeks as $key => $value) {
-                    array_push($price_count_arr, $value['price_count']);
-                    array_push($operate_count_arr, $value['operate_count']);
-                }
-
-                $data_temp['data']['price_count'] = $price_count_arr;
-                $data_temp['data']['operate_count'] = $operate_count_arr;
-                $data_temp['data']['week_arr'] = $week_arr;
-                $data_temp['data']['date_range'] = $date_range;
-            // 判断并加入每个用户时间范围内的统计情况(按照月)
-            } else if ($merge_data_months) {
-                // 默认查询最近半年数据
-                $date_end = strtotime(date('Y-m', strtotime('+1 month', time())));
-                $date_start = strtotime(date('Y-m', strtotime('-5 month', time())));
-                $month_range = date('Y-m', $date_start).'至'.date(date('Y-m', strtotime('-1 month', $date_end)));
-
-                $data_user_temp = $this->parseDataByDays($stock, $date_start, $date_end);
-                $data_user_temp_months = $this->parseDataByMonths($data_user_temp, $date_start, $date_end);
-
-                $month_arr = $this->getMonthArr($date_start, $date_end);
-
-                $price_count_arr = array();
-                $operate_count_arr = array();
-                foreach ($data_user_temp_months as $key => $value) {
-                    array_push($price_count_arr, $value['price_count']);
-                    array_push($operate_count_arr, $value['operate_count']);
-                }
-
-                $data_temp['data']['price_count'] = $price_count_arr;
-                $data_temp['data']['operate_count'] = $operate_count_arr;
-                $data_temp['data']['month_arr'] = $month_arr;
-                $data_temp['data']['month_range'] = $month_range;
-            }
-            
-
-            $data[] = $data_temp;
-        }
-
-        $data = array('data' => $data, 'total' => $total);
-
-        return $data;
-    }
-
-    /**
-     * 获取单用户时间范围内所有数据(Y轴数据)
-     * 按照日期归类
-     * @param timestamp $date_start : 开始时间
-     * @param timestamp $date_end   : 结束时间
-     * @param number    $object     : 用户ID
-     */
-    private function getDataByUser ($date_start, $date_end, $object) {
-        $data = array();
-        $date_index = $date_start;
-
-        $criteria = new EMongoCriteria();
-        $criteria->time('>=', $date_start);
-        $criteria->time('<', $date_end);
-        $criteria->object('==', $object);
-        $criteria->sort('time', EMongoCriteria::SORT_ASC);
-
-        $cursor = Stock::model()->findAll($criteria);
-        $rows = CommonFn::getRowsFromCursor($cursor);
-
-        $rows_count = count($rows);
-        $rows_index = 0;
-        while ($date_index < $date_end) {
-            $data_temp = array(
-                'date' => $date_index,
-                'price_count' => 0,
-                'operate_count'=> 0
-            );
-            while ($rows_index < $rows_count) {
-                if ($date_index <= $rows[$rows_index]['time'] && 
-                    $rows[$rows_index]['time'] < strtotime('+1 day', $date_index)) {
-                    $data_temp['price_count'] += $rows[$rows_index]['tot_price'];
-                    $data_temp['operate_count']++;
-                } else {
-                    break;
-                }
-
-                $rows_index++;
-            }
-
-            $data[] = $data_temp;
-            $date_index = strtotime('+1 day', $date_index);
-        }
-
-        return $data;
-    }
-
-    /**
-     * 根据查询Stock表获得的Rows整理数据,按照每天分类
-     * 减少与Mongo的交互,提高性能
-     * @param  array     $rows       : 从Stock表查询的单用户数据
-     * @param  timestamp $date_start : 开始的时间
-     * @param  timestamp $date_end   : 结束的时间
-     * @return array     $data       : 返回的数据
-     */
-    private function parseDataByDays ($rows, $date_start, $date_end) {
-        $date_index = $date_start;
-        $rows_count = count($rows);
-        $rows_index = 0;
-
-        while ($date_index < $date_end) {
-            $data_temp = array(
-                'date' => $date_index,
-                'price_count' => 0,
-                'operate_count'=> 0
-            );
-
-            while ($rows_index < $rows_count) {
-                if ($date_index <= $rows[$rows_index]['time'] && 
-                    $rows[$rows_index]['time'] < strtotime('+1 day', $date_index)) {
-                    $data_temp['price_count'] += $rows[$rows_index]['tot_price'];
-                    $data_temp['operate_count']++;
-                } else {
-                    break;
-                }
-
-                $rows_index++;
-            }
-
-            $data[] = $data_temp;
-            $date_index = strtotime('+1 day', $date_index);
-        }
-
-        return $data;
-    }
-
-    /**
-     * 按照每周整理单用户数据
-     */
-    private function parseDataByWeeks ($rows='', $date_start, $date_end, $object=0) {
-        if (empty($rows) && $object != 0) {
-            $rows = $this->getDataByUser($date_start, $date_end, $object);
-        }
-
-        $range = ($date_end - $date_start)/3600/24/7;
-        $data = array();
-
-        $rows_index = 0;
-        $day_count = 1;
-        for ($data_index=0; $data_index < $range; $data_index++) { 
-            $data_temp = array(
-                'price_count' => 0,
-                'operate_count' => 0,
-            );
-
-            while ($day_count%8 != 0) {
-                $data_temp['price_count'] += $rows[$rows_index]['price_count'];
-                $data_temp['operate_count'] += $rows[$rows_index]['operate_count'];
-                $rows_index++;
-                $day_count++;
-            }
-
-            $data[] = $data_temp;
-            $day_count = 1;
-        }
-
-        return $data;
-    }
-
-    /**
-     * 按照月份整理单用户数据
-     * @param $date_start timestamp : 开始时间
-     * @param $date_end   timestamp : 结束时间
-     * @param $object     number    : 用户ID
-     */
-    private function parseDataByMonths ($rows='', $date_start, $date_end, $object=0) {
-        if (empty($rows) && $object != 0) {
-            $rows = $this->getDataByUser($date_start, $date_end, $object);
-        }
-
-        $range = intval(date('m', $date_end)) - intval(date('m', $date_start));
-        $num_of_days = array();
-        for ($i=0; $i<$range; $i++) {
-            $num_of_days[$i] = (strtotime('+'.($i+1).' month', $date_start) - strtotime('+'.$i.' month', $date_start))/3600/24;
-        }
-
-        $data = array();
-        $data_index = 0;
-        $day_count = 0;
-        foreach ($num_of_days as $key => $value) {
-            $day_count += $value;
-            $data_temp = array(
-                'price_count' => 0,
-                'operate_count' => 0
-            );
-
-            while ($data_index < $day_count) {
-                $data_temp['price_count'] += $rows[$data_index]['price_count'];
-                $data_temp['operate_count'] += $rows[$data_index]['operate_count'];
-                $data_index++;
-            }
-
-            $data[] = $data_temp;
-        }
-
-        return $data;
-    }
-
-    /**
-     * 将数据转换为字符串
-     * @param $data array : 需要转换为字符串的数据
-     */
-    private function getDataStr ($data) {
-        $data_str = array(
-            'price_count' => '',
-            'operate_count' => ''
-        );
-
-        $price_count = '';
-        $operate_count = '';
-
-        foreach ($data as $key => $value) {
-            $price_count .= '"'.$value['price_count'].'",';
-            $operate_count .= '"'.$value['operate_count'].'",';
-        }
-
-        $price_count = substr($price_count, 0, strlen($price_count)-1);
-        $operate_count = substr($operate_count, 0, strlen($operate_count)-1);
-        $data_str['price_count'] = $price_count;
-        $data_str['operate_count'] = $operate_count;
-
-        return $data_str;
-    }
-
-    /**
-     * 将时间范围数组转换为字符串
-     * @param  array  $data     : 待转换数据
-     * @return string $data_str : 转换后数据
-     */
-    private function getTimeStr ($data) {
-        $data_str = '';
-        foreach ($data as $key => $value) {
-            $data_str .= '"'.$value.'",';
-        }
-        $data_str = substr($data_str, 0, strlen($data_str)-1);
-
-        return $data_str;
-    }
-
-    /**
-     * 获取日期数组
-     */
-    private function getDateArr ($date_start, $date_end) {
-        $date_arr = array();
-        $date_index = $date_start;
-        while ($date_index < $date_end) {
-            $date_arr[] = date('m-d', $date_index);
-            $date_index = strtotime('+1 day', $date_index);
-        }
-
-        return $date_arr;
-    }
-
-    /**
-     * 获取周数组
-     */
-    private function getWeekArr ($date_start, $date_end) {
-        $week_arr = array();
-        $date_index = $date_start;
-        do {
-            $week_temp = date('m-d', $date_index);
-            $date_index = strtotime('+7 day', $date_index);
-            $week_temp .= '至'.date('m-d', strtotime('-1 day', $date_index));
-
-            $week_arr[] = $week_temp;
-        } while ($date_index < $date_end);
-
-        return $week_arr;
-    }
-
-    /**
-     * 获取月份数组
-     */
-    private function getMonthArr ($date_start, $date_end) {
-        $month_arr = array();
-        $date_index = $date_start;
-        while ($date_index < $date_end) {
-            $month_arr[] = intval(date('m', $date_index)).'月';
-            $date_index = strtotime('+1 month', $date_index);
-        }
-
-        return $month_arr;
-    }
-
-}
-?>

+ 0 - 6
www/protected/messages/zh_cn/interest.php

@@ -1,6 +0,0 @@
-<?php
-return array(
-    'deviceId_not_exist' => '没有DeviceID的兴趣数据和你对对碰呜⊙︿⊙',	//'没有对应DeviceID的兴趣数据',
-    'pety_type_ids_illegel' => '宝贝你的宠物类型ID不合法呢 ̄0 ̄',		//'宠物类型ID不合法',
-    'pet_type_ids_empty' => '宝贝记得填宠物类型ID哟 ̄ε  ̄'				//'宠物类型ID不能为空'
-);

+ 0 - 4
www/protected/messages/zh_cn/notify.php

@@ -1,4 +0,0 @@
-<?php
-return array(
-    'notify_type_not_exist' => '咕噜咕噜没有介种通知形式咦+△+',           //通知只有固定的几种形式的消息体(回复、喜欢等);
-);

+ 0 - 19
www/protected/messages/zh_cn/shop.php

@@ -1,19 +0,0 @@
-<?php
-return array(
-    'good_not_exist' => '噗 没有介个商品( •̀ ω •́ )y',                                 //'商品不存在',
-    'level_too_low' =>  '亲,你的等级还不够参加此活动喔( ╯□╰ )',                   //'您的等级不符合此活动的要求',
-    'goods_count_empty' =>'商品被抢完勒,下次活动要眼快手快狠狠下手哦 ( ° ▽、° )',    //'商品已被抢完,请关注下次活动',
-    'score_too_low' => '喵,爪币不足呢继续努力吧 <( ̄︶ ̄)>',                        //'您的爪币已不足',
-    'address_false' => '宝贝请选择正确的收货地址哟 ̄0 ̄',                             //'请选择正确的收货地址',
-    'order_false' => '订单提交失败勒,爬起来,再来一次!(╬ ̄皿 ̄)凸',                //'订单提交失败,请重试',
-    'good_no_exchange' => '不好意思嘛介个商品不能兑换喔(╯-_-)╯╧╧',            //'此商品不允许兑换',
-    'address_not_exist' => '喵 爪爪查不到介个地址呢(°ο°)',                         //'此地址不存在',
-    'good_no_lottery' => '此商品不允许抽奖',        //'此商品不允许抽奖',
-    'bad_luckey' => '(┬_┬)您的人品不大好呦~~换个姿势再试试?',
-    'good_luckey' => '恭喜中奖啦,赶紧完善中奖信息吧',
-    'lottery_too_much' => '( ̄. ̄)亲,这件奖品您今天是不是试了太多次啦',
-    'address_less_one' => '乖啦,要保留至少一个收货地址唷 ( _ _)ノ|',
-    'haved_exchange' => '亲,你已经兑换过啦,给小伙伴留些吧( ╯□╰ )',
-    'have_too_much' => '亲,你已经得到此商品了,给小伙伴留些吧( ╯□╰ )',
-    'address_not_exist' => '您修改的这个地址不存在'
-);

+ 0 - 29
www/protected/messages/zh_cn/user.php

@@ -1,29 +0,0 @@
-<?php
-return array(
-    'user_not_exist' => '查无此人哟 (ΘдΘ)',
-    'id_not_exist' => '查无此人哟 (ΘдΘ)',
-    'id_not_empty' => "登录才有惊喜煞(●′ω`●)",
-    'email_already_registered' => '介个email已经是自己人,直接登录吧(#。ε。#)',
-    'username_already_registered' => '介个昵称被抢勒,换个名称,等会来找找是谁干的ヾ(o◕∀◕)ノ',
-    'username_or_password_error' => '宝贝,昵称还是密码错了哟(。∇^d)',
-    'login_success' => '宝贝,你成功登录么么哒 (≧ω≦)',
-    'register_success' => '恭喜你成功加入爪爪(。ω。)',
-    'register_faild' => '抱歉宝贝注册没有成功呢,再来一次(u_u#)',
-    'weixin_login_faild' => '登录遇见小故障,稍后再试不放弃么么哒(UoU*)', //'登录失败,请稍后重试',
-    'username_length_2_16' => '用户名必须在2~16个字以内呢(●U_U●)',
-    'password_length_6_20' => '密码必须在6~20个字符以内呢(@U▽U@)',
-    'email_Illegal' => '记得要输入正确的邮箱地址哟 (u▽u#)',
-    'user_post_forbidden' => '呃,你被爪爪禁言了尼╮(╯_╰)╭',
-    'username_character_illegal' => '用户名中不能含有 单双引号、空格、@符号哈  (=・ω・=)',
-    'username_length_illegal' => '用户名不能小于2个字且不能超过16个字的啦(≖ ‿ ≖)✧',
-    'petname_length_long' => '宠物名字太长啦(≖ ‿ ≖)✧',
-    'petname_empty' => '给宝贝取个名字吧(≖ ‿ ≖)✧',
-    'petavatar_empty' => '宝贝的头像呢?',
-    'username_has_badwords' => '用用户名中的内个内个不能注册啦 ( ̄y▽ ̄)~',
-    'send_message_fail' => '嗷呜 私信发送失败请再来一遍o(* ̄▽ ̄*)',
-    'no_message_self' => '私信给自己这种行为是不对哒 (>﹏<)',
-    'deviceId_not_exist' => '没有对应DeviceID的用户哦   ٩͡[๏̯͡๏]۶', //'没有对应DeviceID的用户',
-    'user_avatar_illegal' => '用户头像地址不合法',
-    'user_shop_forbidden' => '您被系统禁止抽奖跟兑换了呢',
-    'follow_success' => '成为忠心小粉丝了O(∩_∩)O',
-);

+ 0 - 19
www/protected/models/data/RUserRedis.php

@@ -1,19 +0,0 @@
-<?php
-class RUserRedis extends ARedisRecord{
-    public $id;    
-    public $score;  
-    public $level=1; 
-    public $active_value=1;
-    public $up_have_value=1;
-    public $up_need_value=1;
-
-
-    public function __construct($scenario='insert'){
-        parent::__construct($scenario);
-    }
-
-    public static function model($className=__CLASS__)
-    {
-        return parent::model($className);
-    }
-}

+ 0 - 25
www/protected/models/data/UserInteraction.php

@@ -1,25 +0,0 @@
-<?php
-class UserInteraction extends MongoAr
-{
-    public $_id; 
-    public $from_user;   
-    public $to_user;
-    public $time;
-    public $type;//at,message,reply,follow,like
-
-    public function __construct($scenario='insert'){
-        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_data'));
-        parent::__construct($scenario);
-    }
-
-    public static function model($className=__CLASS__)
-    {
-        return parent::model($className);
-    }
-
-    public function getCollectionName()
-    {
-        return 'user_interaction';
-    }
-
-}

+ 0 - 34
www/protected/models/data/Visitors.php

@@ -1,34 +0,0 @@
-<?php
-class Visitors extends MongoAr
-{
-    public $_id;
-    public $device_id;
-    public $os_version;
-    public $api_version;
-    public $channel;
-    public $app_version;
-    public $user_id;
-    public $app_client_id;
-    public $city_info;
-    public $position;
-    public $phone_type;
-    public $time;
-    public $first_time;
-
-
-    public function __construct($scenario='insert'){
-        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_data'));
-        parent::__construct($scenario);
-    }
-
-    public static function model($className=__CLASS__)
-    {
-        return parent::model($className);
-    }
-
-    public function getCollectionName()
-    {
-        return 'visitors';
-    }
-
-}

+ 0 - 83
www/protected/models/redis/GroupRecord.php

@@ -1,83 +0,0 @@
-<?php
-class GroupRecord extends ARedisRecord{
-    public $id;    
-    public $name;   
-    public $desc;   
-    public $avatar; 
-    public $can_join;  
-    public $can_find;   
-    public $can_topic; 
-    public $can_pics_view; 
-    public $can_commend_view;
-    public $can_post;   
-
-    public $admins=array();
-    public $relate_pet_types=array();
-    public $cover=array();
-    public $city_info=array();
-    public $cat = array();
-    public $tags = array();
-
-    public $topics_count;
-    public $today_topic;
-    public $posts_count;
-    public $users_count;
-    public $order;
-    public $is_follow;
-    public $keyword;
-    public $tags_str;
-    public $status;
-
-    public static $need_serialize = array('admins','relate_pet_types','cover','city_info','cat','tags');
-
-    public static $int_filed = array('can_join','can_find','can_topic','can_pics_view','can_commend_view','can_post','topics_count','posts_count','users_count','today_topic','order','is_follow');
-
-    public function __construct($scenario='insert'){
-        parent::__construct($scenario);
-    }
-
-    public static function get($id){
-        $group_info = self::model()->findByPk($id);
-        $res = array();
-        if($group_info){
-            foreach($group_info->attributeNames() as $attribute) {
-                if(in_array($attribute,GroupRecord::$need_serialize)){
-                    if(is_array($group_info->{$attribute})){
-                        $res[$attribute] = $group_info->{$attribute};
-                    }else{
-                        $res[$attribute] = unserialize($group_info->{$attribute});
-                    }
-                }elseif(in_array($attribute,GroupRecord::$int_filed)){
-                    $res[$attribute] = intval($group_info->{$attribute});
-                }else{
-                    $res[$attribute] = $group_info->{$attribute};
-                }
-            }
-        }else{
-            $group = Group::get(new MongoId($id));
-            if($group){
-                return $group->parseRow($group);
-            }else{
-                return false;
-            }
-        }
-        return $res;
-    }
-
-    public static function model($className=__CLASS__)
-    {
-        return parent::model($className);
-    }
-
-    public function beforeSave()
-    {
-        foreach($this->attributeNames() as $attribute) {
-            if(in_array($attribute,GroupRecord::$need_serialize)){
-                $this->{$attribute} = serialize($this->{$attribute});
-            }
-        }
-        return true;
-    }
-
-
-}

+ 0 - 0
www/protected/models/redis/PostRecord.php


+ 0 - 109
www/protected/models/redis/UserNodeRecord.php

@@ -1,109 +0,0 @@
-<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-
-class UserNodeRecord {
-
-    private $id;//用户id
-    private $set;//关注列表
-    private $f_set;//粉丝列表
-    private $mutual_set;//互相关注列表
-
-    public function __construct($userID) {
-        $this->id = (string)$userID;
-        $this->set = new ARedisSet($this->id);
-        $this->f_set = new ARedisSet($this->id.'_follow_by');
-    } 
-    
-    //关注某个用户
-    public function follow($user_id) {
-        $user = (string)$user_id;
-        if($user != $this->id){
-            $this->set->add($user);
-            $user_follow_by_set = new ARedisSet($user.'_follow_by'); //被关注用户粉丝列表
-            $user_follow_by_set->add($this->id);
-
-            $c_user = RUser::get(new MongoId($this->id));
-            $z_message = new ZMessage();
-            $from_user = Yii::app()->params['sys_user'];
-            $m_data = array(
-                'from_user' => $from_user,
-                'to_user' => $user,
-                'content' => '<a href="http://www.wozhua.mobi/user/'.$this->id.'">'.$c_user->user_name.'</a> 关注了你' ,
-                'pics' => array(),
-                'voice' => array(),
-                'video'=> array()
-            );
-            $z_message->addMessage($m_data);
-        }
-    }
-
-    //取消关注
-    public function unfollow($user) {
-        $user = (string)$user;
-        if ($this->is_following($user)) {
-            $this->set->remove($user);
-            $user_follow_by_set = new ARedisSet($user.'_follow_by'); //被关注用户粉丝列表
-            $user_follow_by_set->remove($this->id);
-        }
-    }
-
-    //获取关注列表
-    public function following() {
-        return $this->set->getData();
-    }
-    
-    //获取粉丝列表
-    public function followed_by() {
-        return $this->f_set->getData();
-    }
-
-    //判断是否互相关注
-    public function is_mutual($user){
-        $user = (string)$user;
-        return in_array($user,$this->mutual_set);
-    }
-
-    //判断是否关注某用户
-    public function is_following($user) {
-        $user = (string)$user;
-        return $this->set->contains($user);
-    }
-
-    //判断是否被某用户关注
-    public function is_followed_by($user) {
-        $user = (string)$user;
-        return $this->f_set->contains($user);
-    }
-
-    //获取互相关注列表
-    public function mutual_follow() {
-        return $this->set->inter($this->f_set);
-    }
-
-    //获取用户关注数
-    public function follow_count() {
-        return $this->set->getCount();
-    }
-
-    //获取粉丝数
-    public function follower_count() {
-        return $this->f_set->getCount();
-    }
-
-    //判断用户关系
-    public function relation($user){
-        $user = (string)$user;
-        if ($this->is_following($user)) {//关注
-            if($this->is_followed_by($user)){
-                return 3;
-            }else{
-                return 1;
-            }
-        }elseif ($this->is_followed_by($user)) {//被关注
-            return 2;
-        }else{
-            return 0;
-        }
-    }
-
-}

+ 0 - 66
www/protected/models/redis/UserRecord.php

@@ -1,66 +0,0 @@
-<?php
-class UserRecord{
-    public static function get($id){
-        $key = __CLASS__.$id;
-        $cache = new ARedisCache();
-        $res = $cache->getValue($key);
-        if($res){
-            return unserialize($res);
-        }else{
-            $user = RUser::get(new MongoId($id));
-            if($user){
-                $data = $user->parseRow($user);
-                $cache->setValue($key,serialize($data));
-                return $data;
-            }else{
-                return false;
-            }
-        }
-    }
-
-    public static function getCityUsers($city){
-        if(!$city){
-            return false;
-        }
-        $cache = new ARedisCache();
-        $key = 'city_users_'.md5($city);
-        $data_cache = $cache->get($key);
-        $res = array();
-        if($data_cache && false){
-            $res = unserialize($data_cache);
-        }else{
-            $criteria = new EMongoCriteria;
-            $criteria->city_info->city('==',$city);
-            $criteria->certify_status('!=',1);
-            $criteria->sort('topic_count',EMongoCriteria::SORT_DESC);
-            $criteria->limit(30);
-            $cursor = RUser::model()->findAll($criteria);
-            $res = RUser::model()->parse($cursor,true,array('id','user_name','sex','avatar','level','city_info','pets','certify_status','certify_info','can_access','last_visit_time'));
-            $cache->set($key,serialize($res),3600);
-        }
-        return $res;
-    }
-
-    public static function getCertifyUser($cerity_type = 'all'){
-        $cache = new ARedisCache();
-        $key = 'city_users_'.md5($cerity_type);
-        $data_cache = $cache->get($key);
-        $res = array();
-        if($data_cache && false){
-            $res = unserialize($data_cache);
-        }else{
-            $criteria = new EMongoCriteria;
-            if($cerity_type != 'all' && !empty($cerity_type)){
-                $criteria->certify_type('==',$cerity_type);
-            }
-            $criteria->sort('topic_count',EMongoCriteria::SORT_DESC);
-            $criteria->certify_status('==',1);
-            $criteria->limit(20);
-            $cursor = RUser::model()->findAll($criteria);
-            $res = RUser::model()->parse($cursor,true,array('id','user_name','sex','avatar','level','city_info','pets','certify_status','certify_info','can_access','last_visit_time'));
-            $cache->set($key,serialize($res),3600);
-        }
-        return $res;
-    }
-
-}

+ 0 - 1
www/themes/classic/views/.htaccess

@@ -1 +0,0 @@
-deny from all