public function viewDetail($pid)
 {
     $modelProduct = M('Product');
     $modelProductInfo = M('ProductInfo');
     $modelProductPrice = M('product_price');
     $modelCustom = M('custom');
     //
     $isshow = I('isshow');
     //分享的订单ID
     $customid = I('customid');
     $where = array('id' => $pid);
     $resultProduct = $modelProduct->where($where)->find();
     if (empty($resultProduct)) {
         $this->error('此众筹项目不存在');
     } else {
         if (!$isshow && ($resultProduct['uid'] != is_login() && $resultProduct['status'] != 9)) {
             $this->error('此众筹项目不存在');
         } else {
             if (!$isshow && ($resultProduct['uid'] != is_login() && $resultProduct['stage'] < 1)) {
                 $this->error('此众筹项目不存在');
             }
         }
     }
     $resultInfo = $modelProductInfo->where(array('pid' => $pid))->find();
     $resultPrice = $modelProductPrice->where(array('pid' => $pid))->order('id')->select();
     $resultSupport = $modelProductPrice->where(array('pid' => $pid))->sum('sell_count');
     //获取支持人列表
     $supportlist = M('Custom')->where(array('pid' => $pid, 'status' => 1))->order('create_time desc')->limit(3)->select();
     $data['read_record'] = $resultProduct['read_record'] + 1;
     $resultLA = $modelProduct->where(array('id' => $pid))->save($data);
     $this->pageTitle = $resultProduct['name'];
     //热门
     $projects = M('Project')->where(array('status' => 9, 'stage' => array(array('gt', 0), array('lt', 8), 'and')))->order('stage desc, is_top desc, create_time desc')->limit(3)->select();
     //进度条
     $finishProgressNum = round($resultProduct['finish_amount'] / $resultProduct['amount'], 2) * 100;
     // $finishProgressNum = 120;
     if ($finishProgressNum > 100) {
         $finishProgressBar = 100;
     } else {
         $finishProgressBar = $finishProgressNum;
     }
     $resultProduct['finish_progress_num'] = $finishProgressNum;
     $resultProduct['finish_progress_bar'] = $finishProgressBar;
     if (isMobile()) {
         $cmt = M('ProductComments')->order('create_time desc')->where(array('project_id' => $pid))->select();
         $resultProduct['comments'] = get_format_comment($cmt, 5);
         //$model->getComments($id,5);
         $recomendList = recommendMBDetailFundings();
     } else {
         //获取评论信息
         $commentCount = M('ProductComments')->where(array('project_id' => $pid))->count();
         $commentpage = new \Think\Page($commentCount, 10);
         $commentshow = $commentpage->show();
         $resultProduct['comment'] = D('Product')->getDetailComments($pid, $commentpage->firstRow, $commentpage->listRows);
         $resultProduct['product']['com_count'] = $commentCount;
         $recomendList = recommendFoundings();
     }
     $this->assign($resultProduct);
     $this->assign('commentshow', $commentshow);
     $this->assign('projects', $projects);
     // 赋值数据集
     $this->assign('resultSupport', $resultSupport);
     $this->assign('resultPrice', $resultPrice);
     $this->assign('resultInfo', $resultInfo);
     $this->assign('supportlist', $supportlist);
     $this->assign('customid', $customid);
     $this->assign('pid', $pid);
     //返回跳转
     $this->assign("backurl", U('Index/index'));
     $this->assign('recomendList', $recomendList);
     $this->display('viewdetail');
 }
 public function detail()
 {
     $id = $_GET['id'];
     $model = D('Project');
     $userScores = $model->getUserScoresInfo($id);
     if (isMobile()) {
         $project = $model->getProjectInfo($id);
         if ($project == false) {
             $this->error($model->getError());
         } else {
             if ($project['uid'] != is_login()) {
                 if ($project['status'] != 9) {
                     $this->error('指定项目不存在');
                 } else {
                     if ($project['stage'] < 0) {
                         $this->error('该页面不存在。');
                     }
                 }
             }
         }
         $model->where(array('id' => $id))->setInc('read_record');
         $dynamicInfo = D('ProjectDynamicInfo')->getPublishedDynamicInfoByPID($id);
         $project['fund'] = $model->getProjectFundInfo($id);
         $project['averageScores'] = $model->getProjectScoresInfo($id);
         $project['leader'] = $model->getProjectLeaderInfo($id);
         $project['investors'] = $model->getInvestorsInfo($id, 3);
         $model->addProjectStatis($project);
         //pass by reference
         $cmt = M('ProjectComment')->order('create_time desc')->where(array('project_id' => $id))->select();
         $project['comments'] = get_format_comment($cmt, 5);
         //$model->getComments($id,5);
         $recomendList = recommendMBDetailFundings();
         $this->project = $project;
         $this->pageTitle = $project['project_name'];
         $this->assign('pageTitle', $project['project_name']);
         $this->assign('recomendList', $recomendList);
     } else {
         $project = $model->getdetail($id);
         $commentCount = M('CommentReply')->where(array('project_id' => $id))->count();
         $commentpage = new \Think\Page($commentCount, 10);
         $commentshow = $commentpage->show();
         $project['comment'] = $model->getDetailComments($id, $commentpage->firstRow, $commentpage->listRows);
         $project['project']['com_count'] = $commentCount;
         if ($project == false) {
             $this->error($model->getError());
         } else {
             if ($project['project']['uid'] != is_login()) {
                 if ($project['project']['status'] != 9) {
                     $this->error('指定项目不存在');
                 } else {
                     if ($project['project']['stage'] < 0) {
                         $this->error('该页面不存在。');
                     }
                 }
             }
         }
         //获取团队信息
         $team = M('ProjectTeam')->where(array('project_id' => $id, 'status' => 0))->order('member_type,sort')->select();
         $model->where(array('id' => $id))->setInc('read_record');
         $recomendFundingProjectList = D('Project')->getFundingProjects('6', array('status' => 9, 'stage' => array('between', array('1', '4'))), $order = 'create_time desc,stage desc');
         $dynamicInfo = D('ProjectDynamicInfo')->getPublishedDynamicInfoByPID($id);
         $recomendList = recommendFoundings();
         $this->project = $project;
         $this->pageTitle = $project['project']['project_name'];
         $this->assign('recomendFundingProjectList', $recomendFundingProjectList);
         $this->assign('recomendList', $recomendList);
         $this->assign('dynamicInfo', $dynamicInfo);
         $this->assign('commentshow', $commentshow);
         $this->assign('uid', is_login());
         $this->assign('team', $team);
     }
     $this->assign('backurl', U('Index/index'));
     $this->assign('userScores', $userScores);
     $this->display('detail');
 }