/** * 美容院列表 */ public function listAction() { $this->setLeftNav('bp_list'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $filterProvince = $req->getQuery('filterProvince', null, ''); $filterCity = $req->getQuery('filterCity', null, ''); $filterDistrict = intval($req->getQuery('filterDistrict', null, -10000)); $filterState = intval($req->getQuery('filterState', null, -10000)); $filterSell = intval($req->getQuery('filterSell', null, -10000)); $filterMedal = intval($req->getQuery('filterMedal', null, -10000)); $filterName = $req->getQuery('filterName', null, ''); $columns = ['bp_id', 'bp_name', 'bp_cover', 'bp_address', 'bp_district', 'FULL_NAME district', 'bp_coordinate', 'bp_tel', 'bp_intro', 'bp_state', 'bp_is_sell', 'bp_medal', 'bp_addtime']; $where = []; $bind = []; $medal = []; if (!!$filterName) { $where[] = 'bp_name LIKE :fname:'; $bind['fname'] = '%' . $filterName . '%'; } if ($filterState > -10000) { $where[] = 'bp_state = :state:'; $bind['state'] = $filterState; } if ($filterSell > -10000) { $where[] = 'bp_is_sell = :sell:'; $bind['sell'] = $filterSell; } // 勋章 switch ($filterMedal) { case 1: $medal = ['10', '11']; break; case 2: $medal = ['01', '11']; break; case 3: $where[] = 'bp_medal = :medal:'; $bind['medal'] = '11'; } $districts = []; // 地区 if ($filterDistrict > -10000) { $where[] = 'bp_district = :district:'; $bind['district'] = $filterDistrict; } elseif (!empty($filterCity)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :province: AND C_NM = :city:', ['province' => $filterProvince, 'city' => $filterCity])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } elseif (!empty($filterProvince)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :p:', ['p' => $filterProvince])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } if (count($medal) > 0) { $where[] = 'bp_medal IN(' . implode(', ', $medal) . ')'; } if (count($districts) > 0) { $where[] = 'bp_district IN(' . implode(', ', $districts) . ')'; } $whereStr = implode(' AND ', $where); $query = BeautyParlor::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'K_ID=bp_district', 'area'); if (!empty($whereStr)) { $query = $query->where($whereStr); } if (count($bind) > 0) { $query = $query->bind($bind); } $bpList = $query->orderBy('bp_id DESC')->limit($limit, $offset)->execute(); // 总数 $total = BeautyParlor::count(['conditions' => $whereStr, 'bind' => $bind]); $this->view->setVar('filterProvince', $filterProvince); $this->view->setVar('filterCity', $filterCity); $this->view->setVar('filterDistrict', $filterDistrict); $this->view->setVar('filterState', $filterState); $this->view->setVar('filterName', $filterName); $this->view->setVar('filterSell', $filterSell); $this->view->setVar('filterMedal', $filterMedal); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('bpList', $bpList); $this->view->setVar('bpStateList', \Apps\Common\Enum\BeautyParlor::valuesExplain()); }
/** * 首页推荐美容院列表 * @date: 2016-1-8 * @author: futao */ public function bannerBpAction() { $this->setLeftNav('bannerbp'); $key = 'index_bp'; $req = $this->request; if (!$req->isPost()) { $filterCity = intval($req->getQuery('City', null, 0)); $this->view->setVar('openCity', $this->openCityList()); $this->view->setVar('filterCity', $filterCity); $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $count = CosPointBp::count(['conditions' => "addr = {$filterCity}"]); $list = CosPointBp::query()->where("addr = '{$filterCity}'")->limit($limit, $offset)->execute()->toArray(); foreach ($list as $k => $v) { $tmp = SysOpenCity::findFirst("city_id = " . $list[$k]['addr'])->toArray(); $list[$k]['city_name'] = $tmp['city_name']; $list[$k]['img_url'] = "http://img.meelier.com/" . $list[$k]['img_url']; } $this->view->setVar("total", $count); $this->view->setVar("limit", $limit); $this->view->setVar("page", $page); $this->view->setVar("list", $list); $this->view->setVar('filterCity', $filterCity); $this->view->pick('bp/bannerBp'); return; } else { //1.0版本代码,2.0没使用 $response = new ResponseResult(); $bpId = intval($req->getPost('bpid', null, 0)); $city = intval($req->getPost('city', null, 0)); //判断参数是否合法 if ($bpId < 1 || $city < 1) { return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常'); } // 查询美容院是否存在 if (BeautyParlor::count('bp_id = ' . $bpId) == 0) { return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '美容院不存在!'); } $bannerData = OmBanner::query()->where('city_id = :cid: AND banner_name = :key:', ['cid' => $city, 'key' => $key])->execute()->getFirst(); if ($bannerData) { $bannerData->update(['banner_data' => $bpId, 'banner_update_time' => new RawValue('NOW()')]); $response->sendResult($bannerData->banner_id); } else { $bannerData = new OmBanner(); $bannerData->city_id = $city; $bannerData->banner_name = $key; $bannerData->banner_data = $bpId; if ($bannerData->save() == false) { $this->databaseErrorLog($bannerData); $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常'); } else { $response->sendResult($bannerData->banner_id); } } return $response; } }
/** * 1.0版本 * * @return $this|ResponseResult */ public function addBpAction() { $this->setLeftNav('bp_list'); $req = $this->request; $id = intval($req->getQuery('id', null, 0)); $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $filterProvince = $req->getQuery('filterProvince', null, ''); $filterCity = $req->getQuery('filterCity', null, ''); $filterDistrict = intval($req->getQuery('filterDistrict', null, -10000)); $filterName = $req->getQuery('filterName', null, ''); $columns = ['bp_id', 'bp_name', 'bp_cover', 'bp_address', 'bp_district', 'FULL_NAME district', 'bp_coordinate', 'bp_tel', 'bp_intro', 'bp_state', 'bp_is_sell', 'bp_medal', 'bp_addtime']; $where = ['bp_state > 0']; $bind = []; if (!!$filterName) { $where[] = 'bp_name LIKE :fname:'; $bind['fname'] = '%' . $filterName . '%'; } $districts = []; // 地区 if ($filterDistrict > -10000) { $where[] = 'bp_district = :district:'; $bind['district'] = $filterDistrict; } elseif (!empty($filterCity)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :province: AND C_NM = :city:', ['province' => $filterProvince, 'city' => $filterCity])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } elseif (!empty($filterProvince)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :p:', ['p' => $filterProvince])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } if (count($districts) > 0) { $where[] = 'bp_district IN(' . implode(', ', $districts) . ')'; } $whereStr = implode(' AND ', $where); $query = BeautyParlor::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'K_ID=bp_district', 'area'); if (!empty($whereStr)) { $query = $query->where($whereStr); } if (count($bind) > 0) { $query = $query->bind($bind); } $bpList = $query->orderBy('bp_id DESC')->limit($limit, $offset)->execute()->toArray(); // 总数 $total = BeautyParlor::count(['conditions' => $whereStr, 'bind' => $bind]); // 查看是否已经在此活动中 // 查询所有参与的列表 $joinList = ActivityBeautyParlor::find('state > 0 AND activity_id = ' . $id); $joinBpIds = []; foreach ($joinList as $j) { $joinBpIds[] = strval($j->beauty_parlor_id); } for ($i = 0; $i < count($bpList); $i++) { if (in_array(strval($bpList[$i]['bp_id']), $joinBpIds)) { $bpList[$i]['bp_state'] = 1; } else { $bpList[$i]['bp_state'] = 0; } } $this->view->setVar('id', $id); $this->view->setVar('filterProvince', $filterProvince); $this->view->setVar('filterCity', $filterCity); $this->view->setVar('filterDistrict', $filterDistrict); $this->view->setVar('filterName', $filterName); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('data', $bpList); }
/** *1.1版本: 首页推荐美容院 */ public function bannerBpAction() { $this->setLeftNav('bannerBp'); $key = 'index_bp'; $req = $this->request; if (!$req->isPost()) { $filterCity = intval($req->getQuery('City', null, 0)); $this->view->setVar('openCity', $this->openCityList()); $this->view->setVar('filterCity', $filterCity); $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $count = CosPointBp::count(['conditions' => "addr = {$filterCity}"]); $list = CosPointBp::query()->where("addr = '{$filterCity}'")->limit($limit, $offset)->execute()->toArray(); foreach ($list as $k => $v) { $tmp = SysOpenCity::findFirst("city_id = " . $list[$k]['addr'])->toArray(); $list[$k]['city_name'] = $tmp['city_name']; $list[$k]['img_url'] = "http://img.meelier.com/" . $list[$k]['img_url']; } $this->view->setVar("total", $count); $this->view->setVar("limit", $limit); $this->view->setVar("page", $page); $this->view->setVar("list", $list); /* $data = null; $bpData = []; if($filterCity > 0) { $bannerData = OmBanner::query() ->columns('banner_data') ->where('city_id = :cid: AND banner_name = :key:', ['cid' => $filterCity, 'key' => $key]) ->execute() ->getFirst(); if($bannerData) { $data = $bannerData->banner_data; } } if($data != null) { $columns = [ 'bp_id', 'bp_name', 'bp_cover', 'bp_address', 'bp_district', 'FULL_NAME district', 'bp_coordinate', 'bp_tel', 'bp_intro', 'bp_state', 'bp_is_sell', 'bp_medal', 'bp_addtime' ]; $bpData = BeautyParlor::query() ->columns($columns) ->leftJoin('Apps\Common\Models\SysAreaZipDistrictPhonecode', 'K_ID=bp_district', 'area') ->where('bp_id = :id:', ['id'=>$data]) ->execute(); } $this->view->setVar('data', $data); $this->view->setVar('bpData', $bpData); */ $this->view->setVar('filterCity', $filterCity); return; } else { $response = new ResponseResult(); $response = new ResponseResult(); $bpId = intval($req->getPost('bpid', null, 0)); $city = intval($req->getPost('city', null, 0)); if ($bpId < 1 || $city < 1) { return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常'); } // 查询美容院是否存在 if (BeautyParlor::count('bp_id = ' . $bpId) == 0) { return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '美容院不存在!'); } $bannerData = OmBanner::query()->where('city_id = :cid: AND banner_name = :key:', ['cid' => $city, 'key' => $key])->execute()->getFirst(); if ($bannerData) { $bannerData->update(['banner_data' => $bpId, 'banner_update_time' => new RawValue('NOW()')]); $response->sendResult($bannerData->banner_id); } else { $bannerData = new OmBanner(); $bannerData->city_id = $city; $bannerData->banner_name = $key; $bannerData->banner_data = $bpId; if ($bannerData->save() == false) { $this->databaseErrorLog($bannerData); $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常'); } else { $response->sendResult($bannerData->banner_id); } } return $response; } }