コード例 #1
0
ファイル: Recommend.php プロジェクト: fu-tao/meelier_c
 public function run()
 {
     $city_code = $this->getDataItem('citycode', 0);
     $cityId = $this->getCityId($city_code);
     if ($cityId <= 0) {
         return $this->errorLog(ResultStatus::CITY_NOT_OPEN, '城市未开通');
         //$cityId=2;
     }
     $list = CosPointBp::query()->columns(['b.bp_name', 'Apps\\Common\\Models\\CosPointBp.img_url  as bp_cover', 'b.bp_address', 'b.bp_medal', 'b.bp_id'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\CosPointBp.bp_id=b.bp_id', 'b')->where('Apps\\Common\\Models\\CosPointBp.addr = "' . $cityId . '"')->orderBy('Apps\\Common\\Models\\CosPointBp.sort desc')->execute()->toArray();
     foreach ($list as $k => $v) {
         $list[$k]['medal_refund'] = substr($list[$k]['bp_medal'], 0, 1);
         $list[$k]['medal_verify'] = substr($list[$k]['bp_medal'], 1, 1);
         $list[$k]['bp_cover'] = "http://img.meelier.com/" . $list[$k]['bp_cover'];
         $list[$k]['tag'] = BeautyParlorTag::query()->columns('i.tag_title')->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'Apps\\Common\\Models\\BeautyParlorTag.tag_id = i.tag_id', 'i')->where("Apps\\Common\\Models\\BeautyParlorTag.bp_id = " . $list[$k]['bp_id'])->orderby("Apps\\Common\\Models\\BeautyParlorTag.sort asc")->limit(3, 0)->execute()->toArray();
     }
     foreach ($list as $k => $v) {
         unset($list[$k]['bp_medal']);
     }
     if (count($list) == 0) {
         unset($list);
     }
     $this->setResult($list);
 }
コード例 #2
0
ファイル: AppIndex.php プロジェクト: fu-tao/meelier_c2.0
 private function getParlorRand($city_id, $limit)
 {
     $where = "ISNULL(show_start_time) AND ISNULL(show_end_time) and b.bp_state = 1 AND ISNULL(sort) AND addr = :id:";
     $parlor = CosPointBp::query()->columns(['b.bp_id id', 'b.bp_name name', 'sort', 'img_url cover', 'b.bp_address address', 'b.bp_medal'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'b.bp_id = Apps\\Common\\Models\\CosPointBp.bp_id', 'b')->where($where)->bind(['id' => $city_id])->orderBy('rand()')->limit($limit, 0)->execute()->toArray();
     return $parlor;
 }
コード例 #3
0
ファイル: BpController.php プロジェクト: fu-tao/meelier_c2.0
 /**
  * 首页推荐美容院列表
  * @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;
     }
 }
コード例 #4
0
ファイル: OmController.php プロジェクト: fu-tao/meelier_c2.0
 /**
  *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;
     }
 }