/**
  * 好产品详细页
  * @author song
  * @param int $rel_id 活动产品id
  *
  * @return
  * */
 public function actionDetail()
 {
     $rel_id = Yii::$app->request->get('rel_id');
     $rel_id = intval($rel_id);
     if ($rel_id > 0) {
         //查询活动产品详细
         $mActivityProduct = new ActivityProduct();
         $actproduct = $mActivityProduct->getDetailBypk($rel_id);
         if (!$actproduct && $actproduct['status'] != 3) {
             Yii::$app->util->msg('审核未通过,请联系管理员!');
             exit;
         }
         //查询活动产品属性
         $mapattrval = new ActivityProductAttrVal();
         $attrval = $mapattrval->getRealAttrVals($rel_id, ActivityBase::GOOD_PRODUCT);
         //投票信息
         $city = isset($attrval['division']['val']) ? $attrval['division']['val'] : '';
         $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);
         //var_dump($optione);
         //exit;
         //增加页面访问量
         $ActivityProductStat_model = new ActivityProductStat();
         $ActivityProductStat_model->incr($rel_id, 'page_views');
         //产品类型
         $IProductType = new IProductType();
         $Ptype = $IProductType->product_type_list();
         $Ptype = ArrayHelper::map($Ptype, 'id', 'name');
         $Ptype[6] = "";
         //页面当name为『其他』时,不然显示
         // print_r($Ptype);exit;
         //            echo '<pre>';
         //            print_r($actproduct);
         // print_r($attrval);
         // exit;
         //数据过滤
         if (isset($attrval['pokedex']['val']) && is_array($attrval['pokedex']['val'])) {
             $tmp = [];
             foreach ($attrval['pokedex']['val'] as $v) {
                 if (!empty($v['title']) && !empty($v['desc']) && !empty($v['url'])) {
                     $tmp[] = $v;
                 }
             }
             $attrval['pokedex']['val'] = $tmp;
         }
         $this->layout = false;
         return $this->render('detail', ['attrval' => $attrval, 'product' => $actproduct, 'optione' => $optione, 'type' => $Ptype, 'goodproduct_city' => ActivityBase::GOODPRODUCT_CITY]);
     }
 }
Example #2
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 : '']);
 }