Beispiel #1
0
 public function run()
 {
     $city_code = $this->getDataItem('city_code', '');
     $type = $this->getDataItem('type', '1');
     // banner位id 1:首页 2:问答 3:美容院
     if (!in_array($type, ['1', '2', '3'])) {
         return $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, 'type类型错误');
     }
     if ($city_code) {
         $city_id = $this->getCityId($city_code) ?: '0';
         $where = "banner_name = {$type} and state = 1 and city_id in(0, {$city_id})";
     } else {
         $where = 'state = 1 and city_id = 0 and banner_name = ' . $type;
     }
     $list = OmBanner::query()->columns(['banner_id', 'banner_data'])->where($where)->orderBy('sort')->execute()->toArray();
     $qz = $this->getDi()->get('appConfig')->application->domainPic;
     $result = [];
     foreach ($list as $k => $val) {
         $val['banner_data'] = json_decode($val['banner_data'], true);
         $val['banner_data']['banner_id'] = $val['banner_id'];
         $val['banner_data']['link_data'] = json_decode($val['banner_data']['link_data'], true) ?: [];
         $val['banner_data']['url'] = $qz . $val['banner_data']['url'];
         $result[] = $val['banner_data'];
     }
     $this->setResult($result);
 }
Beispiel #2
0
 private function getRecommend($cityId)
 {
     $bannerBp = OmBanner::query()->columns('banner_data')->where('city_id = :cid: AND banner_name = :key:', ['cid' => $cityId, 'key' => 'index_bp'])->execute()->getFirst();
     if ($bannerBp) {
         $data = BeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', 'bp_medal as medal'])->where('bp_state>0 and bp_id=:id:')->bind(['id' => $bannerBp->banner_data])->execute()->getFirst();
         $bpData = ["id" => $data->id, "name" => $data->name, "cover" => PicUrl::BeautyParlorCover($data->cover, $this->getDi()), "address" => $data->address, "tags" => $this->getBeautyParlorTags($data->id), "medal_refund" => \Apps\Common\Libs\BeautyParlor::getMedalRefund($data->medal), "medal_verify" => \Apps\Common\Libs\BeautyParlor::getMedalVerify($data->medal)];
     } else {
         $bpData = null;
     }
     $pics = OmBanner::query()->columns('banner_data')->where('city_id = :cid: AND banner_name = :key:', ['cid' => $cityId, 'key' => 'index_pics'])->execute()->getFirst();
     if ($pics) {
         $picsData = json_decode($pics->banner_data, true);
     } else {
         $picsData = [];
     }
     for ($i = 0; $i < count($picsData); $i++) {
         $picsData[$i]['url'] = PicUrl::DefaultPics($picsData[$i]['url'], $this->getDi());
     }
     return ['pic' => $picsData, 'beauty_parlor' => $bpData];
 }
Beispiel #3
0
 /**
  * 设置美容院状态
  * @return $this|ResponseResult
  */
 public function setStateAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $state = intval($req->getPost('state', null, -10000));
         if (!in_array($state, [-1, 0, 1])) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         if ($state == -1) {
             // 查询美容院是否在首页推荐!
             $bannerBp = OmBanner::query()->columns('banner_data')->where('city_id > 0 AND banner_name = :key:', ['key' => 'index_bp'])->execute();
             foreach ($bannerBp as $bb) {
                 if (intval($bb->banner_data) == $id) {
                     return (new ResponseResult())->sendError(ResponseResultStatus::BUSINESS, '此美容院在首页推荐,不能删除!');
                 }
             }
         }
         $info = BeautyParlor::findFirst('bp_id=' . $id);
         if ($info) {
             $info->update(['bp_state' => $state]);
         }
         $syncMap = new BeautyParlorSyncLocation();
         if ($state == 1) {
             $syncMap->sync($id);
         } else {
             $syncMap->delete($id);
         }
         SearchASync::Instance()->noticeSync($id, SearchDataType::BeautyParlors);
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
Beispiel #4
0
 /**
  * 获取banner
  * @date: 2016年1月22日 
  * @author: 545
  */
 private function getBanner($limit, $city_id)
 {
     $banner = OmBanner::query()->columns(['banner_data'])->where('state = 1 AND banner_name =1 AND city_id = ' . $city_id)->limit($limit, 0)->orderBy('banner_update_time desc')->execute()->toArray();
     foreach ($banner as $k => $v) {
         $data = json_decode($v['banner_data']);
         $temp[$k]['url'] = PicUrl::DefaultPics($data->url, $this->getDi());
         $temp[$k]['link_type'] = $data->link_type;
         $temp[$k]['link_data'] = json_decode($data->link_data);
     }
     return $temp;
 }
Beispiel #5
0
 public function run()
 {
     //先验证城市是否开通 modify by tanjinyun 2016/01/11
     $city_code = $this->getDataItem('city_code');
     if ($city_code == null || $city_code == '') {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "城市编码为空");
         exit;
     }
     $is_open = SysOpenCity::findFirst(['columns' => "city_id", 'conditions' => "city_code = {$city_code} AND city_state = 1"]);
     if (!$is_open->city_id > 0) {
         return $this->errorLog(ResultStatus::CITY_NOT_OPEN, "城市未开通");
         exit;
     }
     $longitude = $this->getDataItem('longitude', 0);
     $latitude = $this->getDataItem('latitude', 0);
     $page = intval($this->getDataItem('page', 1));
     $medal = intval($this->getDataItem('medal', 0));
     $keyword = trim($this->getDataItem('keyword', null));
     $limit = $this->getConfig()->limit;
     //                $longitude = 106.515605;
     //                $latitude = 29.539727;
     $config = $this->getDi()->get('appConfig')->amap->lbs_cloud;
     $key = $config->key;
     $signKey = $config->sign_key;
     $tableId = $config->table_id;
     $syncLogTableName = 'beauty_parlor_amap_sync_log';
     //v2.0新增 筛选
     $filter = $medal == 1 ? "medal_verify:1" : null;
     $keywords = $keyword != null ? $keyword : null;
     $lbs = new LBSCloud($key, $signKey, $tableId, $syncLogTableName);
     $result = $lbs->around($latitude, $longitude, $limit, $page, $filter, $keywords);
     if ($result->status) {
         //         	var_dump($result);exit;
         foreach ($result->response as $data) {
             /**
              * modify by jinyu
              * 查询美容院扩展信息
              */
             $info = BeautyParlorAttr::query()->columns(['b.bp_id', 'b.bp_name', 'b.bp_address', 'b.bp_cover', 'b.bp_tel', 'b.bp_medal', 'open_time', 'close_time', 'low_price', 'open_year', 'shop_area', 'service_num', 'facilities'])->rightJoin('Apps\\Common\\Models\\BeautyParlor', 'b.bp_id = Apps\\Common\\Models\\BeautyParlorAttr.beauty_parlor_id', 'b')->where('beauty_parlor_id=:bp_id: AND bp_state >0')->bind(['bp_id' => $data['bp_id']])->execute()->getFirst();
             if ($info) {
                 $this->parlors[] = ['id' => $info['bp_id'], 'name' => $info['bp_name'], 'cover' => PicUrl::BeautyParlorCover($info['bp_cover'], $this->getDi()), 'address' => $info['bp_address'], 'tel' => $info['bp_tel'], 'tags' => $this->formatTagsV2($info['bp_id']), 'distance' => $this->formatDistance($data['_distance']), 'medal_verify' => \Apps\Common\Libs\BeautyParlor::getMedalVerify($info['bp_medal']), 'open_time' => $info['open_time'] == null ? '' : $info['open_time'], 'close_time' => $info['close_time'] == null ? '' : $info['close_time'], 'low_price' => $info['low_price'] == null ? '' : $info['low_price'], 'open_year' => $info['open_year'] == null ? '' : $info['open_year'], 'shop_area' => $info['shop_area'] == null ? '' : $info['shop_area'], 'service_num' => $info['service_num'] == null ? '' : $info['service_num'], 'facilities' => $info['facilities'] == null ? null : (json_decode($info['facilities']) ?: null)];
             } else {
                 continue;
             }
         }
     }
     /**
      * 第一页获取banner
      */
     if ($page == 1) {
         $banner = OmBanner::query()->columns(['banner_data'])->where('state = 1 AND banner_name =3 AND city_id =:city_id:')->bind(['city_id' => $is_open->city_id])->execute()->toArray();
         foreach ($banner as $k => $v) {
             $data = json_decode($v['banner_data']);
             $temp[$k]['url'] = PicUrl::DefaultPics($data->url, $this->getDi());
             $temp[$k]['link_type'] = $data->link_type;
             $temp[$k]['link_data'] = !empty(json_decode($data->link_data)) ? json_decode($data->link_data) : null;
         }
     }
     $list['banner'] = $temp;
     $list['parlors'] = empty($this->parlors) ? null : $this->parlors;
     $this->setResult($list);
 }
Beispiel #6
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;
     }
 }
Beispiel #7
0
 /**
  * 删除banner
  * @date: 2016年1月8日 
  * @author: chenxiaolin
  */
 public function bannerDeleteAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $response = new ResponseResult();
         $response->callbackJavascriptTag = true;
         $id = intval($req->getPost('id', null, 0));
         $state = $req->getPost('state', null, 0);
         $info = OmBanner::findFirst('banner_id = ' . $id);
         if ($info) {
             $info->update(['state' => $state]);
         }
         $arr = ['status' => 10000];
         echo json_encode($arr);
     } else {
         $arr = ['status' => 0, 'error' => '请求异常!'];
         echo json_encode($arr);
     }
 }
Beispiel #8
0
 /**
  * 首页推荐美容院
  */
 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;
     }
 }