/**
  * wap站搜索
  * @return array
  */
 public function actionIndex()
 {
     $size = 10;
     $request = \Yii::$app->request;
     if ($request->isGet) {
         $key = $request->get('key');
         $tab = $request->get('tab');
         if (!empty($key)) {
             //关键词搜索
             $select = 'id,name,description,pinyin_initial';
             $where = array();
             if (!empty($tab)) {
                 //根据tab,判断搜索条件
                 if ($tab == 't1') {
                     $where = array('tmp_source_id' => array(1));
                     //只搜索疾病
                 } else {
                     if ($tab == 't2') {
                         $where = array('tmp_source_id' => array(2));
                         //只搜索症状
                     }
                 }
             }
             $paging = $this->helpPaging('wap_pager_search')->setSize($size)->setPageSetSize(7);
             $offset = $paging->getOffset();
             $res = Search::search_disease_symptom_merge($key, $offset, $size, 0, $where);
             //数据集合
             $paging->setTotal($res['total']);
             if (empty($res['list'])) {
                 //判断条件为空,转为站内搜索
                 return $this->redirect('http://sousuo.9939.com/cse/search?s=2200337477999120096&isNeedCheckDomain=1&jump=1&q=' . $key);
             }
             $data = array('res' => $res['list'], 'paging' => $paging, 'tab' => $tab, 'key' => $key, 'explain_words' => $res['explain_words']);
             return $this->render('keyword_index', $data);
         } else {
             $commonDisease = $this->seek->getCommonDisease();
             //查询相关疾病数据
             $departmentLevel1 = $this->department->getDepartmentLevel1();
             //获取页面的一级科室
             $partlevel1 = $this->part->getPartLevel1();
             //获取页面的一级部位
             $data = array('DepartmentLevel1' => $departmentLevel1, 'partlevel1' => $partlevel1, 'commonDisease' => $commonDisease);
             return $this->render('index', $data);
         }
     }
 }
 /**
  * 关键词搜索操作
  * @param string keyword 关键词名称
  * @param string typeId 标识 t1疾病 t2症状
  * @param int offset 分页 开始条数
  * @param int size 每页显示的条数 
  * @param array orderBy 排序
  * @param return_count_flag  是否统计总条数 false不统计
  * @return array res视图数据集合 int total 数据总条数
  */
 public function keywordSearch($keyword = '', $typeId, $offset = 0, $size = 0, $orderBy = array(), $return_count_flag = false)
 {
     $select = 'id,name,description,pinyin_initial';
     $where = array();
     if (!empty($typeId)) {
         if ($typeId == 't1') {
             $where = array('tmp_source_id' => array(1));
         } else {
             if ($typeId == 't2') {
                 $where = array('tmp_source_id' => array(2));
             }
         }
     }
     $res = Search::search_disease_symptom_merge($keyword, $offset, $size, 0, $where);
     //$res = DiseaseSymptomMerge::search($where,$offset,$size,$orderBy,true);
     foreach ($res['list'] as $k => $val) {
         $sql = "select symptom.id,symptom.name,symptom.pinyin_initial from `9939_disease_symptom_rel` disease_symptom ,`9939_symptom` symptom where disease_symptom.symptomid =  symptom.id and disease_symptom.diseaseid = " . $val['id'] . " limit 0,5";
         $res['list'][$k]['relevance'] = Seek::findBySql($sql)->asArray(true)->all();
     }
     return array('list' => $res['list'], 'total' => $res['total'], 'explain_words' => $res['explain_words']);
 }