Example #1
0
 /**
  * Action Tag
  * @param $id int 标签id
  */
 public function actionTag($id, $page = 1)
 {
     //获取资讯列表信息
     $pagesize = Post::PAGE_SIZE;
     $start = ($page - 1) * $pagesize;
     $mNewsMes = new Post();
     $mNewsMessage = $mNewsMes->getTagnews($id, '', $pagesize, $start);
     $count = $mNewsMes->getTagnews($id, "true");
     $totalpage = ceil($count / $pagesize);
     // $pages = new Pagination([
     //     'totalCount' => $mNewsMessage->count(),
     //     'pageSize' => Post::PAGE_SIZE
     // ]);
     // $mNewsMessage = $mNewsMessage->asArray()->all();
     // 获取首页标签信息
     $mTag = new Tag();
     $tags = $mTag->getTags();
     $condition = array('tag_id' => $id);
     $tag_name = $mTag->getTagsBycond($condition);
     $tag_result = $mTag->findOne($id);
     $tag_des = isset($tag_result->tag_des) && $tag_result->tag_des ? $tag_result->tag_des : '让我们一起发现美丽与你共创美好的生活';
     // 获取热门活动
     $mPageBlock = new PageCustomBlock();
     $slideOption['customId'] = PageCustomBlock::NEWS_PAGE_ACTIVITIES;
     $activity = $mPageBlock->block($slideOption);
     // 获取热门产品
     $mProductStat = new IProductStat();
     $HotProducts = $mProductStat->getHotProduct();
     // 获取热门文章
     $mPostStat = new PostAttrStat();
     $HotArticles = $mPostStat->getHotArticle();
     // 获取关注用户
     $mFollow = new FollowTag();
     $followUser = $mFollow->getFollowUser($id);
     $follow = ['tag_follow' => false];
     if ($user = Yii::$app->util->isLogin()) {
         // 获取用户是否喜欢/Like
         $mFollow = new Follow();
         $follow['tag_follow'] = $mFollow->getUserTagFollow($id, $user['uid']);
     }
     return $this->render('tag', ['data' => $mNewsMessage, 'tags' => $tags, 'activity' => $activity, 'products' => $HotProducts, 'article' => $HotArticles, 'tag_name' => $tag_name[0], 'tag_des' => $tag_des, 'tag_id' => $id, 'follow_user' => $followUser, 'totalpage' => $totalpage, 'follow' => $follow]);
 }
Example #2
0
 public function choose($uid, $type = 0, $stat = 0, $order = 0)
 {
     if (isset($uid)) {
         //状态筛选条件
         $typeMap = ['2' => self::STATUS_VERIFING, '3' => self::STATUS_VERIFIED, '4' => self::STATUS_VERIFEND, '5' => self::STATUS_FIRST, '6' => self::STATUS_NOTHROUGH];
         if (in_array($type, array_keys($typeMap))) {
             $conditions = [self::tableName() . '.status' => $type];
         } else {
             $conditions = [];
         }
         $activeMap = ['1' => ProductStat::tableName() . '.has_unstart_activity', '2' => ProductStat::tableName() . '.has_started_activity', '3' => ProductStat::tableName() . '.has_ended_activity'];
         if (in_array($stat, array_keys($activeMap))) {
             $conditions[$activeMap[$stat]] = 1;
         }
         //排序
         $orderMap = ['1' => self::tableName() . '.create_time', '2' => IProductStat::tableName() . '.support_num', '3' => self::tableName() . '.update_time'];
         //默认排序
         $orderBy[self::tableName() . '.status'] = SORT_DESC;
         if (in_array($order, array_keys($orderMap))) {
             $orderBy[$orderMap[$order]] = SORT_DESC;
         } else {
             $orderBy[self::tableName() . '.id'] = SORT_DESC;
         }
         // print_r($conditions);exit;
         // echo "zhanglu";
         // print_r($orderBy);exit;
         //data
         $return = self::find()->joinWith(['stat', 'extra', 'aproduct' => function ($query) {
             return $query->with('apstat')->orderBy(['id' => SORT_DESC]);
         }])->andWhere(self::tableName() . '.status != :status', [':status' => 0])->andWhere([self::tableName() . '.uid' => $uid])->andWhere($conditions)->orderBy($orderBy)->asArray()->all();
     } else {
         $return = false;
     }
     // print_r($return);exit;
     return $return;
 }
Example #3
0
 /**
  * [产品详情]
  * @param  int $id 产品id
  * @return array     产品信息渲染到页面view
  */
 public function actionView($id)
 {
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     //判断产品是否发布
     $base = IProductBase::find()->select('status,uid')->where('id = :id', [':id' => $id])->asArray()->one();
     if (!empty($_SESSION['user'])) {
         if ($base['status'] != IProductBase::STATUS_VERIFEND) {
             if ($base['uid'] != $_SESSION['user']['uid']) {
                 return $this->redirect(['index']);
                 //跳转到完善信息
             }
         }
     } else {
         if ($base['status'] != IProductBase::STATUS_VERIFEND) {
             return $this->redirect(['index']);
             //跳转到完善信息
         }
     }
     //增加总访问量
     $mProductStat = new IProductStat();
     $mProductStat->modify('page_views', $id, 1, true);
     //访问日志
     $mViewsLog = new ViewsLog();
     $mViewsLog->modify($id, ViewsLog::PRODUCT_TYPE);
     //增加周访问量,月访问量
     $week_num = $mViewsLog->ViewsNum($id, ViewsLog::PRODUCT_TYPE, 7);
     $month_num = $mViewsLog->ViewsNum($id, ViewsLog::PRODUCT_TYPE, 30);
     $mProductStat->modifyviewnum('week_views', $id, $week_num);
     $mProductStat->modifyviewnum('month_views', $id, $month_num);
     //基础数据和扩展数据查询
     $re = IProductBase::find()->With('extra', 'stat')->where(IProductBase::tableName() . '.id = :id', [':id' => $id])->asArray()->one();
     //该产品用户共发布产品数
     $presentNum = IProductBase::find()->where(['uid' => $re['uid'], 'status' => IProductBase::STATUS_VERIFEND])->count();
     //喜欢此产品用户
     $model = new ProductFollow();
     $loves = $model->getFollowUsers($id);
     //产品发布人头像及姓名
     $model = new Member();
     $user = $model->find()->select(['avatar', 'nickname'])->where(['uid' => $re['uid']])->asArray()->one();
     //参加活动
     $model = new ActivityProduct();
     //        print_r($id);exit;
     $actives = $model->getActivityDetail($id);
     // $actives = $model->getActivitiseById($id);
     // print_r($actives);exit;
     foreach ($actives as $key => $value) {
         if ($value['acti_id'] == 8) {
             $mBaiyingShare = new BaiyingShare();
             $number = $mBaiyingShare->getShareNum($value['id']);
         }
         if ($value['acti_id'] == 9) {
             $rel_id = $value['id'];
         }
     }
     //活动map
     $activityBase = new ActivityBase();
     $activesMap = $activityBase->getActivityMap();
     if (isset($rel_id)) {
         //投票信息
         $city = "上海";
         $poll_type_id = PollType::GOODPRODUCT_TYPE;
         $mpoll = new poll();
         $pollone = $mpoll->getPollByCity($city, $poll_type_id);
         //投票项信息
         $moption = new polloption();
         $optione = $moption->getOptionByowner($pollone['poll_id'], $rel_id);
     }
     return $this->render('view', ['re' => $re, 'present_num' => $presentNum, 'actives' => $actives, 'now' => time(), 'number' => isset($number) ? intval($number) : '', 'loves' => $loves, 'user' => $user, 'activesMap' => $activesMap, 'optione' => isset($optione) ? $optione : '']);
 }