Server : nginx/1.20.1 System : Linux iZ2ze9ojcl78uluczwag69Z 4.18.0-240.22.1.el8_3.x86_64 #1 SMP Thu Apr 8 19:01:30 UTC 2021 x86_64 User : www ( 1000) PHP Version : 7.3.28 Disable Function : passthru,exec,system,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /www/wwwroot/0531yanglao.com/app/index/controller/ |
<?php namespace app\index\controller; use app\common\model\Article; use app\common\model\Dictionary; use app\common\model\Recommend; use app\common\utils\Arr; use think\facade\Db; use think\facade\View; class NursingHome extends Controller { public function index() { $area = $this->request->param('area'); $param = $this->request->param('params'); //数据字典 $dict = Dictionary::getCacheData(); $a = $t = $c = $n = $s = ''; $a_name = $t_name = $c_name = $n_name = $s_name = ''; if($area) { $a = $area; $a_name = Dictionary::getDataAttr(7, $area, 'string'); } if($param) { if(empty($area)) { if(preg_match("/[a-zA-Z]{3,}/i", $param, $matches)) { $a = $matches[0]; $a_name = Dictionary::getDataAttr(7, $a, 'string'); } } if(strpos($param, 't') !==false) { preg_match("/t(\d+)+/", $param, $matches); if(isset($matches[1])) { $t = $matches[1]; $t_name = Dictionary::getDataAttr(2, $t, 'string'); } } if(strpos($param, 'c') !==false) { preg_match("/c(\d+)+/", $param, $matches); if(isset($matches[1])) { $c = $matches[1]; $c_name = Dictionary::getDataAttr(9, $c, 'string'); } } if(strpos($param, 'n') !==false) { preg_match("/n(\d+)+/", $param, $matches); if(isset($matches[1])) { $n = $matches[1]; $n_name = Dictionary::getDataAttr(3, $n, 'string'); } } if(strpos($param, 's') !==false) { preg_match("/s(\d+)+/", $param, $matches); if(isset($matches[1])) { $s = $matches[1]; $s_name = Dictionary::getDataAttr(8, $s, 'string'); } } /*var_dump($a,$t,$c,$n,$s); var_dump($a_name,$t_name,$c_name,$n_name,$s_name);*/ } //lixiaqu //养老列表 $where = []; $keyword = $this->request->param('keyword', ''); $location = $this->request->param('location', ''); $service = $this->request->param('service', ''); $type = $this->request->param('type', ''); $lnstitutional_nature = $this->request->param('lnstitutional_nature', ''); $price = $this->request->param('price', ''); //$location && $where[] = ['location', 'find in set', $location]; $a && $where[] = ['location', 'find in set', $a]; $keyword && $where[] = ['title', 'like', "%{$keyword}%"]; //$service && $where[] = ['service', '=', $service]; $s && $where[] = ['service', '=', $s]; //$type && $where[] = ['type', '=', $type]; $t && $where[] = ['type', '=', $t]; //$lnstitutional_nature && $where[] = ['lnstitutional_nature', '=', $lnstitutional_nature]; $n && $where[] = ['lnstitutional_nature', '=', $n]; $location && $a = Dictionary::getDataAttr(7, $location, 'string'); $type && $t = Dictionary::getDataAttr(2, $type, 'string'); $lnstitutional_nature && $n = Dictionary::getDataAttr(3, $lnstitutional_nature, 'string'); $service && $s = Dictionary::getDataAttr(8, $service, 'string'); if($c) { //$c = Dictionary::getDataAttr(9, $price, 'string'); switch ($c) { case 1: $where[] = ['min_price', '<', 1000]; break; case 2: $where[] = ['min_price', 'between', [1000, 2000]]; break; case 3: $where[] = ['min_price', 'between', [2000, 3000]]; break; case 4: $where[] = ['min_price', 'between', [3000, 4000]]; break; case 5: $where[] = ['min_price', 'between', [4000, 5000]]; break; case 6: $where[] = ['min_price', 'between', [5000, 6000]]; break; case 7: $where[] = ['min_price', '>', 6000]; break; } } $list = \app\common\model\NursingHome::getList($where, $this->limit, ['sort'=>'asc','create_time'=>'desc']); $list->append(['tags_name','city_name']); $listArr = $list->toArray(); $page = []; $page['total'] = $list->total(); $page['listRows'] = $list->listRows(); $page['currentPage'] = $list->currentPage(); $page['lastPage'] = $list->lastPage(); $ids = Arr::array_col_values($listArr['data'], 'nid'); $where = []; $where[] = ['nid', 'in', $ids]; /*$min_price = \app\common\model\NursingHome::where($where)->min('min_price'); $max_price = \app\common\model\NursingHome::where($where)->min('max_price');*/ //统计 $statistics = []; $statistics['total'] = \app\common\model\NursingHome::count(); $statistics['min_price'] = \app\common\model\NursingHome::where($where)->min('min_price'); $statistics['max_price'] = \app\common\model\NursingHome::where($where)->max('max_price'); //热门推荐 $recommend_1 = Recommend::getRecommendList('nursinghome', 1, 8); if($recommend_1) { foreach ($recommend_1 as $item) { $item->append(['location_name', 'service_name']); } } //最新动态 $article_1 = Article::getAll(['type'=>'news'], 8, ['create_time'=>'desc']); //政法政策 $article_3 = Article::getAll(['type'=>'regulations'], 8, ['create_time'=>'desc']); View::assign(compact('dict','list','statistics','recommend_1','article_1','article_3', 'a','t','c','n','s','page','a_name','t_name','c_name','n_name','s_name')); return \view(); } public function detail($id) { $data = \app\common\model\NursingHome::detail($id, ['comments']); $data->append(['tags_name','lnstitutional_nature_name','type_name','institutional_characteristics_name','retract_objects_name']); $data->inc('click_num')->update(); $recommend_1 = Recommend::getRecommendList('nursinghome', 1, 4); if($recommend_1) { foreach ($recommend_1 as $item) { $item->append(['location_name', 'service_name']); } } $relation_nursing = $relation_article = []; if($data['relation_nursing']) { $where = []; $where[] = ['nid', 'in', $data['relation_nursing']]; $relation_nursing = \app\common\model\NursingHome::where($where)->select()->append(['location_name', 'service_name']);; } if($data['relation_nursing']) { $where = []; $where[] = ['article_id', 'in', $data['relation_article']]; $relation_article = Article::where($where)->select(); } View::assign(compact('data', 'recommend_1','relation_nursing','relation_article')); return \view(); } }