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

+ 0 - 159
www/protected/models/data/Goods.php

@@ -1,159 +0,0 @@
-<?php
-/**
- * User: charlie
- * 闪购、抽奖、积分兑换的商品
- */
-class Goods extends MongoAr
-{
-    public $_id;
-    public $name;//商品名字
-    public $avatar;//商品封面
-    public $city_info=array();//商品城市属性,设置此属性的商品,只有此地区用户可见
-    public $desc='';//商品介绍
-    public $type;//'exchange'=>兑换   'lottery'=>抽奖  'buy'=>抢购
-
-    public $order=1;//排序权重
-    public $status=1;//0  删除    1正常  -1已过期
-    public $is_real=1;//是否是实物   1实物  0不是实物
-
-    public $market_price=0;//市场价
-    public $count=0;//库存数量
-    public $min_level=0;//无论是兑换、抽奖、抢购   最低可以参与的人的等级  0就是不限制
-    public $score;//如果是兑换  就是兑换该商品所需的爪币数;如果是抽奖  就是抽一次所需的爪币;如果是抢购  就是最多可以用多少爪币抵现金
-    public $max_exchange = 1;//一件商品允许兑换的最多次数
-    public $pics=array();//商品图片
-    public $start_time;//商品上线时间戳
-    public $end_time;//商品结束时间戳
-    public $probability=0.001;//如果是抽奖 抽中的概率
-    public $max_times_per_day=100;//如果是抽奖   每个用户每天最多抽的次数
-    public $lottertimes=0;//如果是抽奖  一共被抽的次数
-
-
-    //public $give_score=0;//如果是抢购的商品  如果购买成功   赠送的爪币
-    //public $shop_price;//如果是抢购的商品 本店售价
-
-    public static $status_option = array(
-        1 => array('name' => '正常'),
-        0 => array('name' => '删除'),
-        -1 => array('name' => '已过期'),
-        -2 => array('name' => '已下架')
-    );
-
-    public static $type_option = array(
-        'exchange' => array('name' => '兑换'),
-        'lottery' => array('name' => '抽奖'),
-        'buy' => array('name' => '抢购')
-    );
-
-
-    //无论是抽奖抽中   还是兑换  每个商品每人只能一次
-    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 'goods';
-    }
-
-    public static function get($_id) {
-        if(CommonFn::isMongoId($_id)){
-            $criteria = new EMongoCriteria();
-            $criteria->_id('==', $_id);
-            $model = self::model()->find($criteria);
-            return $model;
-        }else{
-            return false;
-        }
-    }
-
-    public function parseRow($row,$output=array()){
-        $newRow = array();
-        $newRow['id'] = (string)$row['_id'];
-
-        $newRow['name'] = CommonFn::get_val_if_isset($row,'name','');
-        $newRow['desc'] = CommonFn::get_val_if_isset($row,'desc','');
-        $newRow['type'] = CommonFn::get_val_if_isset($row,'type','');
-
-        $newRow['avatar'] = CommonFn::get_val_if_isset($row,'avatar',Yii::app()->params['defaultGoodsAvatar']);//默认图标
-        if($newRow['avatar']==''){
-            $newRow['avatar'] = Yii::app()->params['defaultGoodsAvatar'];
-        }
-
-        $newRow['city_info'] = CommonFn::get_val_if_isset($row,'city_info',array("province"=>"","city"=>"","area"=>""));
-        if(!isset($newRow['city_info']['province'])){
-            $newRow['city_info']['province'] = '';
-        }
-        if(!isset($newRow['city_info']['city'])){
-            $newRow['city_info']['city'] = '';
-        }
-        if(!isset($newRow['city_info']['area'])){
-            $newRow['city_info']['area'] = '';
-        }
-
-        $newRow['max_exchange'] = CommonFn::get_val_if_isset($row,'max_exchange',1);
-        $newRow['order'] = CommonFn::get_val_if_isset($row,'order',1);
-        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
-        $newRow['is_real'] = CommonFn::get_val_if_isset($row,'is_real',1);
-
-        $newRow['market_price'] = CommonFn::get_val_if_isset($row,'market_price',1);
-        $newRow['count'] = CommonFn::get_val_if_isset($row,'count',1);
-        if($newRow['count']<=0 && $newRow['status']==1 ){
-            $newRow['status'] = -2;
-            $model = self::get($row['_id']);
-            $model->status = -2;
-            $model->update(array('status'),true);
-        }
-        $newRow['min_level'] = CommonFn::get_val_if_isset($row,'min_level',1);
-        $newRow['score'] = CommonFn::get_val_if_isset($row,'score',1);
-
-        $newRow['pics'] = CommonFn::get_val_if_isset($row,'pics',array());
-        if(empty($newRow['pics'])){
-            $newRow['pics'] = CommonFn::$empty;
-        }
-
-        $newRow['start_time'] = CommonFn::get_val_if_isset($row,'start_time',0);
-        $newRow['end_time'] = CommonFn::get_val_if_isset($row,'end_time',0);
-
-        if($newRow['end_time']<time() && $newRow['status']==1 ){
-            $newRow['status'] = -1;
-            $model = self::get($row['_id']);
-            $model->status = -1;
-            $model->update(array('status'),true);
-        }
-
-        $newRow['start_time_str'] = CommonFn::bgmdate("Y年n月d日", $newRow['start_time'],1);
-        $newRow['end_time_str'] = CommonFn::bgmdate("Y年n月d日", $newRow['end_time'],1);
-
-        $newRow['probability'] = floatval(CommonFn::get_val_if_isset($row,'probability',0.001));
-        $newRow['max_times_per_day'] = CommonFn::get_val_if_isset($row,'max_times_per_day',100);
-        $newRow['lottertimes'] = CommonFn::get_val_if_isset($row,'lottertimes',0);
-
-        $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
-        $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
-        $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
-
-        if(APPLICATION=='api'||APPLICATION=='common'){
-            if($newRow['end_time']>time()){
-                $newRow['countdown'] = $newRow['end_time'] - time();
-            }else {
-                $newRow['countdown'] = 0;
-            }
-            unset($newRow['probability']);
-            unset($newRow['max_times_per_day']);
-            unset($newRow['lottertimes']);
-            unset($newRow['action_user']);
-            unset($newRow['action_time']);
-            unset($newRow['action_log']);
-        }
-
-        return $this->output($newRow,$output);
-    }
-
-}

+ 0 - 62
www/protected/models/data/IGtTransmissionTemplate.php

@@ -1,62 +0,0 @@
-<?php 
-require_once(APP_PATH.'/protected/vendors/getui/'.'igetui/template/IGt.BaseTemplate.php');
-class IGtTransmissionTemplate extends IGtBaseTemplate {
-
-	var $transmissionType;
-	var $transmissionContent;
-
-	public function  getActionChain() {
-
-		$actionChains = array();
-
-	
-		// 设置actionChain
-		$actionChain1 = new ActionChain();
-		$actionChain1->set_actionId(1);
-		$actionChain1->set_type(ActionChain_Type::refer);
-		$actionChain1->set_next(10030);
-	
-		//appStartUp
-		$appStartUp = new AppStartUp();
- 		$appStartUp->set_android("");
-		$appStartUp->set_symbia("");
-		$appStartUp->set_ios("");
-
-		//启动app
-		$actionChain2 = new ActionChain();
-		$actionChain2->set_actionId(10030);
-		$actionChain2->set_type(ActionChain_Type::startapp);
-		$actionChain2->set_appid("");
-		$actionChain2->set_autostart($this->transmissionType == '1'? true : false);
-		$actionChain2->set_appstartupid($appStartUp);
-		$actionChain2->set_failedAction(100);
-		$actionChain2->set_next(100);
-
-		//结束
-		$actionChain3 = new ActionChain();
-		$actionChain3->set_actionId(100);
-		$actionChain3->set_type(ActionChain_Type::eoa);
-
- 
-		array_push($actionChains, $actionChain1,$actionChain2,$actionChain3);
-
-		return $actionChains;
-	}
-
-	function  get_transmissionContent() {
-		return $this->transmissionContent;
-	}
-	
-	function  get_pushType() {
-		return 'TransmissionMsg';
-	}
-
-
-	function  set_transmissionType($transmissionType) {
-		$this->transmissionType = $transmissionType;
-	}
-
-	function  set_transmissionContent($transmissionContent) {
-		$this->transmissionContent = $transmissionContent;
-	}
-}

+ 0 - 179
www/protected/models/data/Message.php

@@ -1,179 +0,0 @@
-<?php
-/**
- * User: charlie
- * 私信
- */
-class Message extends MongoAr
-{
-    public $_id;
-    public $content;//内容
-
-    public $time;//发表时间  unix时间戳
-
-    public $from_user;//作者 object id
-    public $to_user;//作者 object id
-    public $has_read = 0;//   1已读   0  未读 私信是否已读
-
-    public $pics=array();//帖子中的图片  七牛的地址  array('url'=>'http://wozhua-avatars.qiniudn.com/1414476356856.jpg','height'=>1180,'width'=>2340)
-    public $voice=array();//帖子中的语音  七牛的地址      array('url'=>'http://wozhua-avatars.qiniudn.com/FiGWVp6E5rH_5jQM9CbxH_moN3G2','length'=>6)
-    public $video=array();//帖子中的视频  七牛的地址  array('url'=>'http://wozhua-avatars.qiniudn.com/FiGWVp6E5rH_5jQM9CbxH_moN3G2','length'=>6,'avatar'=>'http://wozhua-avatars.qiniudn.com/1414476356856.jpg')
-
-    public $status=1;//状态   1正常   0删除   -1垃圾
-    
-    public $delete_user=array();//用户删除私信标识
-
-
-    public static $status_option = array(
-        1 => array('name' => '正常'),
-        0 => array('name' => '删除'),
-        -1 => array('name' => '垃圾')
-    );
-
-    public static $type_option = array(
-        'text'  => array('name' => '文字'),
-        'image' => array('name' => '图片'),
-        'voice' => array('name' => '语音'),
-        'video' => array('name' => '视频'),
-    );
-
-    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 static function get($_id) {
-        if(CommonFn::isMongoId($_id)){
-            $criteria = new EMongoCriteria();
-            $criteria->_id('==', $_id);
-            $model = self::model()->find($criteria);
-            return $model;
-        }else{
-            return false;
-        }
-    }
-
-
-    public function getCollectionName()
-    {
-        return 'messages';
-    }
-
-    public function parseRow($row,$output=array()){
-        $cache = new ARedisCache();
-        $key = 'data_cache_'.__CLASS__.(string)$row['_id'];
-        $data_cache = $cache->get($key);
-        if($data_cache){
-            $newRow = unserialize($data_cache);
-        }else{
-            $newRow = array();
-            $newRow['id'] = (string)$row['_id'];
-            $newRow['content'] = CommonFn::get_val_if_isset($row,'content','');
-            $from_user = array();
-            $to_user = array();
-            $t_user = new ZUser();
-            if(isset($row['from_user'])){
-                $_user = $t_user->get($row['from_user']);
-                $from_user = RUser::model()->parseRow($_user->attributes,array('id','user_name','avatar','certify_status','certify_info','user_type','can_be_message','can_access','is_fake_user'));
-            }
-            if(isset($row['to_user'])){
-                $_user = $t_user->get($row['to_user']);
-                $to_user = RUser::model()->parseRow($_user->attributes,array('id','user_name','avatar','certify_status','certify_info','user_type','can_be_message','can_access','is_fake_user'));
-            }
-            $newRow['from_user'] = $from_user;
-            $newRow['to_user'] = $to_user;
-            $newRow['pics'] = CommonFn::get_val_if_isset($row,'pics',array());
-            if(empty($newRow['pics'])){
-                $newRow['pics'] = CommonFn::$empty;
-            }
-            $newRow['voice'] = CommonFn::get_val_if_isset($row,'voice',array());
-            $newRow['video'] = CommonFn::get_val_if_isset($row,'video',array());
-            $newRow['type'] = 'text';
-            $newRow['content'] = CommonFn::get_val_if_isset($row, 'content', '');
-            $cache->set($key,serialize($newRow),36000);
-        }
-        $newRow['time'] = CommonFn::get_val_if_isset($row,'time',time());
-        $newRow['time_str'] = CommonFn::sgmdate("Y年m月d日", $newRow['time'],1);
-        $newRow['has_read'] = CommonFn::get_val_if_isset($row,'has_read',0);
-        if(isset($newRow['voice']['url'])){
-            $newRow['type'] = 'voice';
-            $newRow['content_sub'] = '[语音]';
-        }else if(isset($newRow['video']['url'])){
-            $newRow['type'] = 'video';
-            $newRow['content_sub'] = '[视频]';
-        }else if(!empty($newRow['pics'])){
-            $newRow['type'] = 'image';
-            $newRow['content_sub'] = '[图片]';
-        }else{
-            $newRow['content_sub'] = $newRow['content'];
-        }
-        if(!isset($newRow['voice'])||empty($newRow['voice'])){
-            $newRow['voice']=(Object)CommonFn::$empty;
-        }
-        if(!isset($newRow['video'])||empty($newRow['video'])){
-            $newRow['video']=(Object)CommonFn::$empty;
-        }
-        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',1);
-        $newRow['status_str'] = self::$status_option[$newRow['status']]['name'];
-        if(APPLICATION=='admin'){
-            $newRow['action_user'] = CommonFn::get_val_if_isset($row,'action_user',"");
-            $newRow['action_time'] = CommonFn::get_val_if_isset($row,'action_time',"");
-            $newRow['action_log'] = CommonFn::get_val_if_isset($row,'action_log',"");
-        }
-        return $this->output($newRow,$output);
-    }
-
-    /**
-     * 根据消息的类型来返回页面显示的HTML
-     * @param $type
-     * @param $data
-     * @return string
-     */
-    public function generateMsgHtml($type,$data){
-        $html = '';
-
-        switch($type){
-            case "text":
-                $html = Topic::model()->ParseSmile($data["content"]);
-                break;
-            case "voice":
-                $html = '<audio src="'.str_replace(".amr",".mp3",$data["voice"]["url"]).'" controls="controls"></audio>';
-                break;
-            case "image":
-                if($data['pics'] && is_array($data['pics'])){
-                    foreach($data['pics'] as $image){
-                        $thumb_image = CommonFn::getQiniuImage($image['url'],133,80);
-                        $html .= '<a target="_blank" href="'.$image['url'].'"><img src="'.$thumb_image.'" border="0" /></a>';
-                    }
-                }
-                break;
-            case "video":
-                $html .= $data['video'] ? $this->pv_m($data['video']['url']) : '';
-                break;
-        }
-        return $html;
-    }
-
-    /**
-     * 视频播放网页代码
-     * @param $url
-     * @param $width
-     * @param $height
-     * @return string
-     */
-    public function pv_m($url){
-        $str = <<<EOF
-        <video controls="" name="media">
-            <source src="$url" type="audio/mpeg">
-        </video>
-EOF;
-        return $str;
-    }
-
-
-
-}

+ 0 - 176
www/protected/models/data/Order.php

@@ -1,176 +0,0 @@
-<?php
-/**
- * User: charlie
- * 订单表
- */
-class Order extends MongoAr
-{
-    public $_id;
-    public $time;  //订单生成时间
-    public $price;  //订单金额
-    public $goods = array(); //对应的Goods 的mongoid,可能一笔订单有多个商品
-    public $user;  //对应的RUser 的mongoid
-    public $status=0;//订单状态     0=>待处理    1=>已发货 2=>已完成   -1=>已退货   -2=>已取消 3=>已中奖
-    public $express_company = ''; //快递公司
-    public $express_number = '';//发货单号
-    public $express_time = 0;//发货时间
-    public $memo = '';//备注
-
-    public $address; //收货地址
-
-    public static $status_option = array(
-        0 => array('name' => '待处理'),
-        1 => array('name' => '已发货'),
-        2 => array('name' => '已完成'),
-        -1 => array('name' => '已退货'),
-        -2 => array('name' => '已取消'),
-        3 => array('name' => '已中奖'),
-
-    );
-
-    public function __construct($scenario='insert'){
-        $this->setMongoDBComponent(Yii::app()->getComponent('mongodb_data'));
-        parent::__construct($scenario);
-    }
-
-    public static function get($_id) {
-        if(CommonFn::isMongoId($_id)){
-            $criteria = new EMongoCriteria();
-            $criteria->_id('==', $_id);
-            $model = self::model()->find($criteria);
-            return $model;
-        }else{
-            return false;
-        }
-    }    
-
-
-    public static function model($className=__CLASS__)
-    {
-        return parent::model($className);
-    }
-
-    public function getCollectionName()
-    {
-        return 'orders';
-    }
-
-    public static function getOrderByOrderNu($order_num){
-        $order_time = intval(substr($order_num,0,10));
-        $user_tag = substr($order_num,10);
-        $criteria = new EMongoCriteria();
-        $criteria->time('==',$order_time);
-        $count = self::model()->count($criteria);
-        if($count<=1){
-            return self::model()->find($criteria);
-        }else{
-            $orders = self::model()->findAll($criteria);
-            $accord_num = 0;
-            foreach ($orders as $key => $order) {
-                if(hexdec(substr((string)$row['user'],-3) == $user_tag)){
-                    $accord_num += 1;
-                    $accord_res = $order;
-                }
-            }
-            if($accord_num == 1 && isset($accord_res)){
-                return $accord_res;
-            }else{
-                return false;
-            }
-        }
-    }
-
-    public function parseRow($row,$output=array()){
-        $newRow = array();
-        $newRow['id'] = (string)$row['_id'];
-        $newRow['price'] = CommonFn::get_val_if_isset($row,'price',0);
-        $newRow['time'] = CommonFn::get_val_if_isset($row,'time',time());
-        $newRow['time_str'] = CommonFn::sgmdate("Y年n月d日 H:i:s", $newRow['time'],0);
-        $newRow['order_num'] = $newRow['time'].hexdec(substr((string)$row['user'],-3));
-
-        $newRow['express_time'] = CommonFn::get_val_if_isset($row,'express_time',time());
-        $newRow['express_time_str'] = CommonFn::sgmdate("Y年n月d日", $newRow['express_time'],1);
-
-        $newRow['memo'] = CommonFn::get_val_if_isset($row,'memo','');
-        $newRow['status'] = CommonFn::get_val_if_isset($row,'status',0);
-        switch ($newRow['status']) {
-            case 1:
-                $newRow['status_str'] = '已发货';
-                $newRow['status_str_color'] = '#585c64';
-                break;
-            case 2:
-                $newRow['status_str'] = '已完成';
-                $newRow['status_str_color'] = '#585c64';
-                break;
-            case 3:
-                $newRow['status_str'] = '已中奖';
-                $newRow['status_str_color'] = '#f8a338';
-                break;
-            case 0:
-                $newRow['status_str'] = '待处理';
-                $newRow['status_str_color'] = '#999999';
-                break;
-            case -1:
-                $newRow['status_str'] = '已退货';
-                $newRow['status_str_color'] = '#ff3b30';
-                break;
-            case -2:
-                $newRow['status_str'] = '已取消';
-                $newRow['status_str_color'] = '#ff3b30';
-                break;
-            default:
-                $newRow['status_str'] = '已取消';
-                $newRow['status_str_color'] = '#ff3b30';
-                break;
-        }
-        $newRow['express_company'] = CommonFn::get_val_if_isset($row,'express_company','');
-        $newRow['express_number'] = CommonFn::get_val_if_isset($row,'express_number','');
-        $newRow['express_info'] = '';
-        if($newRow['express_company']&&$newRow['express_number']){
-            $newRow['express_info'] = 'http://m.kuaidi100.com/index_all.html?type='.urlencode($newRow['express_company']).'&postid='.$newRow['express_number'].'&callbackurl=http://www.wozhua.mobi/webOp/exit#result';
-        }
-        $user = array();
-        $t_user = new ZUser();
-        if(isset($row['user'])){
-            $_user = $t_user->get($row['user']);
-            $user = RUser::model()->parseRow($_user->attributes,array('score','user_name','id'));
-        }
-        $newRow['user'] = $user;
-        $goods = array();
-        $admin_goods_view = ''; 
-        $t_goods = new ZGoods();
-        if(isset($row['goods'])){
-            foreach ($row['goods'] as $value) {
-                $good = $t_goods->get($value['goods_id']);
-                $good_temp = Goods::model()->parseRow($good->attributes,array('id','name','avatar','type','market_price','score'));
-                $admin_goods_view = '<a href="javascript:;" onclick="parent.load_url(\'/index.php?r=goods&id='.$value['goods_id'].'\');"> '.$good_temp['name'].' </a>';
-                $good_temp['buy_count'] = $value['count'];
-                $goods[] = $good_temp;
-            }
-        }
-        $newRow['goods'] = $goods;
-        $newRow['admin_goods_view'] = $admin_goods_view;
-        $newRow['address'] = CommonFn::get_val_if_isset($row,'address',array());
-        $temp_addr = '';
-        $newRow['admin_address_view'] = '';
-        if(isset($newRow['address']['address'])){
-            $temp_addr = isset($newRow['address']['address']['province'])?$newRow['address']['address']['province']:'';
-            $temp_addr = isset($newRow['address']['address']['city'])?$temp_addr.$newRow['address']['address']['city']:$temp_addr;
-            $temp_addr = isset($newRow['address']['address']['area'])?$temp_addr.$newRow['address']['address']['area']:$temp_addr;
-            $temp_addr = isset($newRow['address']['address']['poi']['name'])?$temp_addr.$newRow['address']['address']['poi']['name']:$temp_addr;
-            $temp_addr = isset($newRow['address']['address']['detail'])?$temp_addr.$newRow['address']['address']['detail']:$temp_addr;
-        }
-        if(isset($newRow['address']['name'])){
-            $newRow['admin_address_view'] = '收货人:'.$newRow['address']['name'];
-        }
-        if(isset($newRow['address']['mobile'])){
-            $newRow['admin_address_view'] = $newRow['admin_address_view'].' 手机号:'.$newRow['address']['mobile'];
-        }
-        $newRow['admin_address_view'] = $newRow['admin_address_view'].' '.$temp_addr;
-        if(APPLICATION=='api'||APPLICATION=='common'){
-            unset($newRow['admin_goods_view']);
-        }
-        return $this->output($newRow,$output);
-    }
-
-}

+ 0 - 32
www/protected/models/data/UserShopInfo.php

@@ -1,32 +0,0 @@
-<?php
-//商城相关用户信息
-class UserShopInfo extends MongoAr
-{
-    public $_id;//使用用户id作为积分表主键
-    public $address = array(); //用户的收货地址列表
-    public $collect_goods = array(); //用户收藏的商品
-
-
-    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_shop_info';
-    }
-
-    public function parseRow($row,$output=array()){
-        $newRow = array();
-        $newRow['id'] = $row['_id'];
-        
-        return $this->output($newRow,$output);
-    }
-
-}