public function buyReportAction()
 {
     $serialId = $this->getParam('serialId');
     $cityid = $this->getParam('city');
     $year = $this->getParam('year');
     $typeId = $this->getParam('typeId');
     $mileage = $this->getParam('mileage');
     if (!isset($serialId) || XF_Functions::isEmpty($serialId)) {
         throw new XF_Exception('车系参数不正确');
     }
     // 当前地区名称
     $name = $this->nowCity->name;
     $this->_view->serialId = $serialId;
     // 获取车型列表
     $mod = new Auto_Model_Type();
     $types = $mod->getsBySerialId($serialId);
     // print_r($types);
     $this->_view->types = $types;
     if ((!isset($serialId) || XF_Functions::isEmpty($typeId)) && !XF_Functions::isEmpty($types)) {
         $typeId = $types[0][1][0]->id;
         $type = $mod->getsByTypeId($typeId);
     } else {
         $type = $mod->getsByTypeId($typeId);
     }
     //        获得session,存车型id
     $gpj_session = new XF_Session("gpj_session");
     $sessionAry = array();
     $sessionAry["modelId"] = $typeId;
     $sessionAry["detail_model"] = $type->detail_model;
     $sessionAry["detail_price"] = $type->price_bn;
     $this->_view->type = $type;
     //        获取评估报告投票
     $vote = new Report_Model_Vote();
     $reportVote = $vote->getVoteByTypeId($typeId);
     if ($reportVote) {
         $this->_view->goodNum = $reportVote->right_vote;
         $this->_view->noGoodNum = $reportVote->noright_vote;
         $this->_view->totalNum = $reportVote->right_vote + $reportVote->noright_vote;
     } else {
         $this->_view->goodNum = 0;
         $this->_view->noGoodNum = 0;
         $this->_view->totalNum = 0;
     }
     $cityModel = new Application_Model_City();
     $cities = $cityModel->getsByCity($this->nowCity->id);
     if (!isset($cityid) || XF_Functions::isEmpty($cityid) || !is_numeric($cityid) || $cityid <= 0) {
         $cityid = $this->nowCity->id;
     }
     $cityObj = $cityModel->get($cityid);
     $this->_view->cities = $cities;
     $this->_view->cityName = $cityObj->name;
     $this->_view->cityId = $cityid;
     $this->_view->cityPinYin = $cityObj->pinyin;
     $sessionAry["province"] = $cityid;
     $d_model = $type->id;
     $year = $year > 0 ? $year : $type->listed_year;
     $mile = floatval($mileage) > 0 ? floatval($mileage) : date("Y") - $type->listed_year;
     $intent = 'buy';
     $this->_view->mileage = $mile;
     $this->_view->year = $year;
     $mod = new Report_Model_Valuation();
     $V = $mod->getValuation($cityid, $d_model, $year, '', $mile, $intent);
     $this->_view->V = $V;
     $sessionAry["detail_year"] = $year;
     $sessionAry["detail_mile"] = $mile;
     $sessionAry["serialId"] = $serialId;
     $gpj_session->write($sessionAry);
     // 随机抽取6辆车型
     $carTypeModel = new Auto_Model_Type();
     $serialCars = $carTypeModel->getsByCityAndSerialId($cityid, $typeId);
     foreach ($serialCars as $key => $val) {
         $val->mile = round($val->mile);
         if (!XF_Functions::isEmpty($val->year)) {
             $val->car_age = date("Y") - $val->year;
         }
         if (!XF_Functions::isEmpty($val->source_type)) {
             $val->source_val = $this->source_type[$val->source_type];
         }
         if (!XF_Functions::isEmpty($val->thumbnail)) {
             $val->thumbnail = $val->thumbnail . "?imageView2/1/w/296/h/193";
         } else {
         }
     }
     $this->_view->serialCars = $serialCars;
     $this->setLayout(new Layout_Default());
     $this->_view->headTitle("买二手车价格评估-买二手车估价-买二手车技巧流程-公平价");
     $this->_view->headMeta("买二手车车评估,买二手车估价,买二手车流程,买二手车技巧");
     $this->_view->headMeta("公平价-买车评估频道为您提供:二手车买车估值、二手车买车估价、二手车买车估价计算器,给您所选爱车一个精准、公平、公道的价格。二手车买车服务就上公平价!");
     // 设置页面资源
     $this->_view->headStylesheet('/css/report/report.css');
     $this->_view->headStylesheet('/css/valid.css');
     $this->_view->headScript('/js/pagejs/buyreport.js');
 }
 public function getValuaModelAction()
 {
     if ($this->_request->isPost() && $this->_request->isXmlHttpRequest()) {
         $report = new Report_Model_Valuation();
         $dmodelId = $this->getParam("dmodel_id");
         $year = $this->getParam("year");
         $mile = $this->getParam("mile");
         $usedId = $this->getParam("used_id");
         $valua = $report->getValuation($this->nowCity->id, $dmodelId, $year, "", $mile, "buy");
         die('{"code":"200","usedId":"' . $usedId . '","dealPrice":"' . $valua->deal_price . '"}');
     }
 }