|
@@ -14,348 +14,6 @@ class IndexController extends ApiBaseController {
|
|
|
return $this->verify();
|
|
|
}
|
|
|
|
|
|
- public function actionV3(){
|
|
|
- //根据自定义参数生成缓存key
|
|
|
- $user_id = Yii::app()->request->getParam('user_id','');
|
|
|
- $device_id = Yii::app()->request->getParam('device_id','0');
|
|
|
- $city_info = json_decode(Yii::app()->request->getParam('city_info'),true);
|
|
|
- $province = isset($city_info['province'])?$city_info['province']:'';
|
|
|
- $position_city_info = json_decode(Yii::app()->request->getParam('position_city_info'),true);
|
|
|
- $position_province = isset($position_city_info['province'])?$position_city_info['province']:'';
|
|
|
- $get_new = Yii::app()->request->getParam('get_new',0);
|
|
|
- $z_User = new ZUser();
|
|
|
- $host = ENVIRONMENT=='product'?'www.wozhua.mobi':'wwwtest.wozhua.mobi';
|
|
|
- $f_host = ENVIRONMENT=='product'?'f.wozhua.mobi':'ftest.wozhua.mobi';
|
|
|
- $user = $z_User->idExist($user_id);
|
|
|
- //$new_user_coupons = 0;
|
|
|
- $no_recommond_groups = Yii::app()->params['no_recommond_groups'];
|
|
|
- //登陆用户根据上次访问时间,关注圈子,页数,当前时间生成唯一key
|
|
|
- if($user){
|
|
|
- $add_score = $this->today_first_login($user_id);
|
|
|
- $last_visit_hours = CommonFn::get_user_last_visit_hours($user['last_visit_time']);
|
|
|
- $group_ids = $user['groups'];
|
|
|
- $sort_group = array();
|
|
|
- foreach ($group_ids as $key => $value) {
|
|
|
- $sort_group[] = (string)$value;
|
|
|
- }
|
|
|
- sort($sort_group);
|
|
|
- $stamp = '3';
|
|
|
- foreach ($sort_group as $key => $value) {
|
|
|
- $stamp.=$value;
|
|
|
- }
|
|
|
- $cache_key = md5($stamp.$last_visit_hours.$get_new);
|
|
|
- //未登录用户根据页数,默认获取推荐关注圈子七天内帖子
|
|
|
- }elseif($device_id){
|
|
|
- $cache = new ARedisCache();
|
|
|
- $key = 'guest_last_visit_time_'.$device_id;
|
|
|
- $guest_last_visit_time = $cache->get($key);
|
|
|
- if($guest_last_visit_time){
|
|
|
- $last_visit_hours = CommonFn::get_user_last_visit_hours($guest_last_visit_time);
|
|
|
- }else{
|
|
|
- $last_visit_hours = 168;
|
|
|
- }
|
|
|
- $cache->set($key,time());
|
|
|
- //未登录用户获取获取推荐的圈子
|
|
|
- $default_follow_group = Service::factory('VariableService')->getVariable('default_follow_group');
|
|
|
- $groups = explode(',',trim($default_follow_group,','));
|
|
|
- if(isset($city_info['province'])){
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->status('==',1);
|
|
|
- $criteria->addCond('city_info.province','==',$city_info['province']);
|
|
|
- $cursor = Group::model()->findAll($criteria);
|
|
|
- foreach ($cursor as $value) {
|
|
|
- $groups[] = (string)$value->_id;
|
|
|
- }
|
|
|
- }
|
|
|
- $stamp = '3';
|
|
|
- foreach ($groups as $key => $value) {
|
|
|
- if(!CommonFn::isMongoId($value)){
|
|
|
- unset($groups[$key]);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $groups[$key] = new MongoId($value);
|
|
|
- $stamp.=$value;
|
|
|
- }
|
|
|
- $group_ids = array_values($groups);
|
|
|
- $cache_key = md5($stamp.$last_visit_hours.$get_new);
|
|
|
- }else{
|
|
|
- $default_follow_group = Service::factory('VariableService')->getVariable('default_follow_group');
|
|
|
- $groups = explode(',',trim($default_follow_group,','));
|
|
|
- $stamp = '3';
|
|
|
- foreach ($groups as $key => $value) {
|
|
|
- if(!CommonFn::isMongoId($value)){
|
|
|
- unset($groups[$key]);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $groups[$key] = new MongoId($value);
|
|
|
- $stamp.=$value;
|
|
|
- }
|
|
|
- $group_ids = array_values($groups);
|
|
|
- $last_visit_hours = 168;
|
|
|
- $cache_key = md5($stamp.$last_visit_hours.$get_new);
|
|
|
- }
|
|
|
- foreach ($group_ids as $key => $value) {
|
|
|
- if(in_array((string)$value,$no_recommond_groups)){
|
|
|
- unset($group_ids[$key]);
|
|
|
- }
|
|
|
- }
|
|
|
- $group_ids = array_values($group_ids);
|
|
|
- $cache = new ARedisCache();
|
|
|
- $cache_data = $cache->get($cache_key);
|
|
|
- if($cache_data && !YII_DEBUG){
|
|
|
- $cache_res = unserialize($cache_data);
|
|
|
- $data = $cache_res['data'];
|
|
|
- }else{
|
|
|
- //按钮链接
|
|
|
- $link_button[] = array(
|
|
|
- 'title'=>'买宠物',
|
|
|
- 'link_text'=>'有保障/大礼包',
|
|
|
- 'icon_url'=>'http://7oxep6.com1.z0.glb.clouddn.com/huotijiaoyi.png',
|
|
|
- 'link'=>'http://'.$host.'/o2o/web/index/deal?need_header=0'
|
|
|
- );
|
|
|
- $link_button[] = array(
|
|
|
- 'title'=>'问专家',
|
|
|
- 'link_text'=>'看病/训犬/养护',
|
|
|
- 'icon_url'=>'http://7oxep6.com1.z0.glb.clouddn.com/doctorhij.png',
|
|
|
- 'link'=>'http://'.$host.'/group/54a0fa1f0eb9fb17308b47a6'
|
|
|
- );
|
|
|
- $data['link_button'] = $link_button;
|
|
|
|
|
|
- //活体交易部分
|
|
|
- $deal['type'] = 'deal';
|
|
|
- $deal['title'] = '放心、有保障的宠物交易';
|
|
|
- $deal['more'] = 'http://'.$host.'/o2o/web/index/deal?need_header=0';
|
|
|
- //todo pettype
|
|
|
- $new_pets = DealPet::getNewPet();
|
|
|
- foreach ($new_pets as $key => $value) {
|
|
|
- $new_pets[$key]['url'] = 'http://'.$host.'/o2o/web/index/deal?need_header=0/#!/detail/'.$value['id'];
|
|
|
- }
|
|
|
- $deal['pets'] = $new_pets;
|
|
|
- $data['modules'][] = $deal;
|
|
|
-
|
|
|
- $res_topics = array();
|
|
|
- $conditions = array(
|
|
|
- 'group'=>array('in',$group_ids),
|
|
|
- 'status'=>array('==',1),
|
|
|
- 'time'=>array('>=',time()-3600*$last_visit_hours)
|
|
|
- );
|
|
|
- //最新最热帖排序规则
|
|
|
- $order = $get_new?['_id'=>'desc']:['like_count'=>'desc'];
|
|
|
- $model = new Topic();
|
|
|
- $pagedata = CommonFn::getPagedata($model,1,20,$conditions,$order,false);
|
|
|
- $topics = $pagedata['res'];
|
|
|
- foreach($topics as $topic){
|
|
|
- $_topic = $model->parseRow($topic,array('id','content','city_info','city_info_str','city_topic_str','time','time_str','group','visit_count','reply_count','fav_count','like_count','user','pics','voice','video','last_post_time','last_post_time_str'));
|
|
|
- if($user){
|
|
|
- $z_like = new ZLike();
|
|
|
- $like = $z_like->getLikeByLikeObj((string)$user['_id'],$_topic['id']);
|
|
|
- if(empty($like)){
|
|
|
- $_topic['is_liked'] = false;
|
|
|
- }else{
|
|
|
- $_topic['is_liked'] = true;
|
|
|
- }
|
|
|
- }else{
|
|
|
- $_topic['is_liked'] = false;
|
|
|
- }
|
|
|
- $res_topics[] = $_topic;
|
|
|
- }
|
|
|
- $data['topics'] = $res_topics;
|
|
|
- $cache_data = array();
|
|
|
- $cache_data['data'] = $data;
|
|
|
- $cache->set($cache_key,serialize($cache_data),3600);
|
|
|
- }
|
|
|
- //首页轮播图
|
|
|
- $province_tag = isset($city_info['province'])?$city_info['province']:'no';
|
|
|
- $slide = Slide::getIndexSlide($province_tag);
|
|
|
- $data['slide'] = $slide;
|
|
|
- if(isset($add_score['status'])){
|
|
|
- $score_info['score_change'] = $add_score['score'];
|
|
|
- $score_info['current_score'] = $add_score['current_score'];
|
|
|
- $score_info['score_type'] = '签到';
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data,303,$score_info);
|
|
|
- }else{
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data,200,array('last_visit_hours' =>$last_visit_hours));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function actionV4(){
|
|
|
- //根据自定义参数生成缓存key
|
|
|
- $user_id = Yii::app()->request->getParam('user_id','');
|
|
|
- $device_id = Yii::app()->request->getParam('device_id','0');
|
|
|
- $page = intval(Yii::app()->request->getParam('page',1));
|
|
|
- $city_info = json_decode(Yii::app()->request->getParam('city_info'),true);
|
|
|
- $province = isset($city_info['province'])?$city_info['province']:'';
|
|
|
- $position_city_info = json_decode(Yii::app()->request->getParam('position_city_info'),true);
|
|
|
- $position_province = isset($position_city_info['province'])?$position_city_info['province']:'';
|
|
|
- $get_new = Yii::app()->request->getParam('get_new',0);
|
|
|
- $z_User = new ZUser();
|
|
|
- $host = ENVIRONMENT=='product'?'www.wozhua.mobi':'wwwtest.wozhua.mobi';
|
|
|
- $f_host = ENVIRONMENT=='product'?'f.wozhua.mobi':'ftest.wozhua.mobi';
|
|
|
- $user = $z_User->idExist($user_id);
|
|
|
- //$new_user_coupons = 0;
|
|
|
- $no_recommond_groups = Yii::app()->params['no_recommond_groups'];
|
|
|
- //登陆用户根据上次访问时间,关注圈子,页数,当前时间生成唯一key
|
|
|
- if($user){
|
|
|
- $add_score = $this->today_first_login($user_id);
|
|
|
- $last_visit_hours = CommonFn::get_user_last_visit_hours($user['last_visit_time']);
|
|
|
- $group_ids = $user['groups'];
|
|
|
- $sort_group = array();
|
|
|
- foreach ($group_ids as $key => $value) {
|
|
|
- $sort_group[] = (string)$value;
|
|
|
- }
|
|
|
- sort($sort_group);
|
|
|
- $stamp = '3';
|
|
|
- foreach ($sort_group as $key => $value) {
|
|
|
- $stamp.=$value;
|
|
|
- }
|
|
|
- $cache_key = md5($stamp.$last_visit_hours.$get_new);
|
|
|
- //未登录用户根据页数,默认获取推荐关注圈子七天内帖子
|
|
|
- }elseif($device_id){
|
|
|
- $cache = new ARedisCache();
|
|
|
- $key = 'guest_last_visit_time_'.$device_id;
|
|
|
- $guest_last_visit_time = $cache->get($key);
|
|
|
- if($guest_last_visit_time){
|
|
|
- $last_visit_hours = CommonFn::get_user_last_visit_hours($guest_last_visit_time);
|
|
|
- }else{
|
|
|
- $last_visit_hours = 168;
|
|
|
- }
|
|
|
- $cache->set($key,time());
|
|
|
- //未登录用户获取获取推荐的圈子
|
|
|
- $default_follow_group = Service::factory('VariableService')->getVariable('default_follow_group');
|
|
|
- $groups = explode(',',trim($default_follow_group,','));
|
|
|
- if(isset($city_info['province'])){
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->status('==',1);
|
|
|
- $criteria->addCond('city_info.province','==',$city_info['province']);
|
|
|
- $cursor = Group::model()->findAll($criteria);
|
|
|
- foreach ($cursor as $value) {
|
|
|
- $groups[] = (string)$value->_id;
|
|
|
- }
|
|
|
- }
|
|
|
- $stamp = '3';
|
|
|
- foreach ($groups as $key => $value) {
|
|
|
- if(!CommonFn::isMongoId($value)){
|
|
|
- unset($groups[$key]);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $groups[$key] = new MongoId($value);
|
|
|
- $stamp.=$value;
|
|
|
- }
|
|
|
- $group_ids = array_values($groups);
|
|
|
- $cache_key = md5($stamp.$last_visit_hours.$get_new);
|
|
|
- }else{
|
|
|
- $default_follow_group = Service::factory('VariableService')->getVariable('default_follow_group');
|
|
|
- $groups = explode(',',trim($default_follow_group,','));
|
|
|
- $stamp = '3';
|
|
|
- foreach ($groups as $key => $value) {
|
|
|
- if(!CommonFn::isMongoId($value)){
|
|
|
- unset($groups[$key]);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $groups[$key] = new MongoId($value);
|
|
|
- $stamp.=$value;
|
|
|
- }
|
|
|
- $group_ids = array_values($groups);
|
|
|
- $last_visit_hours = 168;
|
|
|
- $cache_key = md5($stamp.$last_visit_hours.$get_new);
|
|
|
- }
|
|
|
- foreach ($group_ids as $key => $value) {
|
|
|
- if(in_array((string)$value,$no_recommond_groups)){
|
|
|
- unset($group_ids[$key]);
|
|
|
- }
|
|
|
- }
|
|
|
- $group_ids = array_values($group_ids);
|
|
|
- $cache = new ARedisCache();
|
|
|
- $cache_data = $cache->get($cache_key.'v4');
|
|
|
- if($cache_data && !YII_DEBUG){
|
|
|
- $cache_res = unserialize($cache_data);
|
|
|
- $data = $cache_res['data'];
|
|
|
- }else{
|
|
|
-
|
|
|
- //按钮链接
|
|
|
- $link_button[] = array(
|
|
|
- 'title'=>'买宠物',
|
|
|
- 'link_text'=>'有保障/大礼包',
|
|
|
- 'icon_url'=>'http://7oxep6.com1.z0.glb.clouddn.com/huotijiaoyi.png',
|
|
|
- 'link'=>'http://'.$host.'/o2o/web/index/deal?need_header=0'
|
|
|
- );
|
|
|
- $link_button[] = array(
|
|
|
- 'title'=>'问专家',
|
|
|
- 'link_text'=>'看病/训犬/养护',
|
|
|
- 'icon_url'=>'http://7oxep6.com1.z0.glb.clouddn.com/doctorhij.png',
|
|
|
- 'link'=>'http://'.$host.'/group/54a0fa1f0eb9fb17308b47a6'
|
|
|
- );
|
|
|
- $data['link_button'] = $link_button;
|
|
|
-
|
|
|
- //活体交易部分
|
|
|
- $deal['type'] = 'deal';
|
|
|
- $deal['title'] = '放心、有保障的宠物交易';
|
|
|
- $deal['more'] = 'http://'.$host.'/o2o/web/index/deal?need_header=0';
|
|
|
- //todo pettype
|
|
|
- $new_pets = DealPet::getNewPet();
|
|
|
- foreach ($new_pets as $key => $value) {
|
|
|
- $new_pets[$key]['url'] = 'http://'.$host.'/o2o/web/index/deal?need_header=0/#!/detail/'.$value['id'];
|
|
|
- }
|
|
|
- $deal['pets'] = $new_pets;
|
|
|
- $data['modules'][] = $deal;
|
|
|
-
|
|
|
- $res_topics = array();
|
|
|
- $conditions = array(
|
|
|
- 'group'=>array('in',$group_ids),
|
|
|
- 'status'=>array('==',1),
|
|
|
- 'time'=>array('>=',time()-3600*$last_visit_hours)
|
|
|
- );
|
|
|
- //最新最热帖排序规则
|
|
|
- $order = $get_new?['_id'=>'desc']:['like_count'=>'desc'];
|
|
|
- $model = new Topic();
|
|
|
- $pagedata = CommonFn::getPagedata($model,1,200,$conditions,$order,false);
|
|
|
- $topics = $pagedata['res'];
|
|
|
- foreach($topics as $topic){
|
|
|
- $res_topics[] = $topic['_id'];
|
|
|
- }
|
|
|
- $data['topics'] = $res_topics;
|
|
|
- $cache_data = array();
|
|
|
- $cache_data['data'] = $data;
|
|
|
- $cache->set($cache_key.'v4',serialize($cache_data),3600);
|
|
|
- }
|
|
|
- $res_topics = array();
|
|
|
- $topics = $data['topics'];
|
|
|
- $skip = 20*$page-20;
|
|
|
- if($skip+20 >= count($topics)){
|
|
|
- $has_more = 0;
|
|
|
- }else{
|
|
|
- $has_more = 1;
|
|
|
- }
|
|
|
- $topics_ids = array_slice($topics,$skip,20);
|
|
|
- $model = new Topic();
|
|
|
- foreach ($topics_ids as $key => $topic_id) {
|
|
|
- $_topic = $model->parseRow(Topic::get(new MongoId($topic_id)),array('id','content','city_info','city_info_str','city_topic_str','time','time_str','group','visit_count','reply_count','fav_count','like_count','user','pics','voice','video','last_post_time','last_post_time_str'));
|
|
|
- if($user){
|
|
|
- $z_like = new ZLike();
|
|
|
- $like = $z_like->getLikeByLikeObj((string)$user['_id'],$_topic['id']);
|
|
|
- if(empty($like)){
|
|
|
- $_topic['is_liked'] = false;
|
|
|
- }else{
|
|
|
- $_topic['is_liked'] = true;
|
|
|
- }
|
|
|
- }else{
|
|
|
- $_topic['is_liked'] = false;
|
|
|
- }
|
|
|
- $res_topics[] = $_topic;
|
|
|
- }
|
|
|
- $data['topics'] = $res_topics;
|
|
|
- //首页轮播图
|
|
|
- $province_tag = isset($city_info['province'])?$city_info['province']:'no';
|
|
|
- $slide = Slide::getIndexSlide($province_tag);
|
|
|
- $data['slide'] = $slide;
|
|
|
- if(isset($add_score['status'])){
|
|
|
- $score_info['score_change'] = $add_score['score'];
|
|
|
- $score_info['current_score'] = $add_score['current_score'];
|
|
|
- $score_info['score_type'] = '签到';
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data,303,$score_info);
|
|
|
- }else{
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data,200,array('has_more'=>$has_more,'last_visit_hours' =>$last_visit_hours));
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
}
|