public function run()
 {
     $page = intval($this->getDataItem('page', 1));
     $keyword = $this->getDataItem('keyword');
     $city_code = trim($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;
     }
     //根据城市编码 获取 城市区
     $city = SysAreaZipDistrictPhonecode::query()->columns(['K_ID'])->where("PHONE_CODE = {$city_code}")->execute()->toArray();
     foreach ($city as $k) {
         $citys[] = $k['K_ID'];
     }
     $citys = implode(',', $citys);
     $count = $this->getConfig()->limit;
     if (empty($keyword)) {
         $offset = ($page - 1) * $count;
         $list = BeautyParlorServiceModel::query()->columns(['service_id id', 'service_cover cover', 'service_name name', 'service_price price', 'service_unit unit', 'service_description description', 'b.bp_id', 'b.bp_name'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\BeautyParlorService.beauty_parlor_id = b.bp_id', 'b')->where("Apps\\Common\\Models\\BeautyParlorService.service_state = 1 and b.bp_state = 1 AND b.bp_district in ({$citys})")->limit($count, $offset)->execute()->toArray();
         foreach ($list as $k => $v) {
             $unit = $v['unit'];
             unset($v['unit']);
             $list[$k]['price_show'] = '';
             if ($v['price'] > 0) {
                 $list[$k]['price_show'] = $v['price'] . '元' . ($unit ? '/' . $unit : '');
             }
             $list[$k]['cover'] = PicUrl::BeautyParlorCover($list[$k]['cover'], $this->getDi());
         }
         $this->setResult($list);
     } else {
         /*多关键字搜索*/
         $keywordarr = explode(" ", trim($keyword));
         foreach ($keywordarr as $r) {
             $wherearr[] = "Apps\\Common\\Models\\BeautyParlorService.service_name like '%" . $r . "%'";
         }
         $where = implode(" or ", $wherearr);
         ////////////////////////////////////////////////////////////////
         /* $limit = $this->getConfig()->limit;
            $offset = ($page-1) * $limit;
            $data = $this->searchBPS($keyword, $limit, $offset);
            $this->setResult($data); */
         $offset = ($page - 1) * $count;
         $list = BeautyParlorServiceModel::query()->columns(['service_id id', 'service_cover cover', 'service_name name', 'service_price price', 'service_unit unit', 'service_description description', 'b.bp_id', 'b.bp_name'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\BeautyParlorService.beauty_parlor_id = b.bp_id', 'b')->where("{$where} and Apps\\Common\\Models\\BeautyParlorService.service_state = 1 and b.bp_state = 1 AND b.bp_district in ({$citys})")->limit($count, $offset)->execute()->toArray();
         foreach ($list as $k => $v) {
             $unit = $v['unit'];
             unset($list[$k]['unit']);
             $list[$k]['price_show'] = '';
             if ($v['price'] > 0) {
                 $list[$k]['price_show'] = $v['price'] . '元' . ($unit ? '/' . $unit : '');
             }
             $list[$k]['cover'] = PicUrl::BeautyParlorCover($list[$k]['cover'], $this->getDi());
         }
         $this->setResult($list);
     }
 }
 public function question_recommend_listAction()
 {
     $this->setLeftNav('thumbs');
     $req = $this->request;
     $filterCity = intval($req->getQuery('filterCity', null, 0));
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $count = CosPointquestion::count(['conditions' => "addr = {$filterCity}"]);
     $list = CosPointquestion::query()->where("addr = {$filterCity}")->limit($limit, $offset)->execute()->toArray();
     foreach ($list as $k => $v) {
         if (!empty($list[$k]['addr'])) {
             $tmp = SysOpenCity::findFirst("city_id = " . $list[$k]['addr'])->toArray();
             $list[$k]['city_name'] = $tmp['city_name'];
         }
     }
     $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->setVar('openCity', $this->openCityList());
     $this->view->pick("question_recommend/list");
 }
 public function homelistAction()
 {
     $this->setLeftNav('homelist');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     if ($req->getQuery("cityid")) {
         $wherearr[] = "Apps\\Common\\Models\\CosPointCanon.open_city_id = " . $req->getQuery("cityid");
         $this->view->setVar("cityid", $req->getQuery("cityid"));
     }
     $wherearr[] = "c.state <> 3";
     $where = implode(" and ", $wherearr);
     $list = CosPointCanon::query()->columns(['c.img_url', 'c.title', 'c.id', 'c.assist', 'Apps\\Common\\Models\\CosPointCanon.sort as sort', 'Apps\\Common\\Models\\CosPointCanon.open_city_id as cityid'])->leftJoin("Apps\\Common\\Models\\CosBeautyCanon", 'Apps\\Common\\Models\\CosPointCanon.canon_id = c.id', 'c')->where($where)->orderBy("Apps\\Common\\Models\\CosPointCanon.open_city_id desc")->limit($limit, $offset)->execute()->toArray();
     foreach ($list as $k => $v) {
         $list[$k]['img_url'] = "http://img.meelier.com/" . $list[$k]['img_url'];
         $list[$k]['city_name'] = SysOpenCity::findFirst("city_id = " . $list[$k]['cityid'])->toArray();
     }
     $this->view->setVar("total", count($list));
     $this->view->setVar("limit", $limit);
     $this->view->setVar("page", $page);
     $this->view->setVar("list", $list);
     $this->view->setVar('openCity', $this->openCityList());
 }
 public function question_recommend_listAction()
 {
     $this->setLeftNav('thumbs');
     $req = $this->request;
     $filterCity = intval($req->getQuery('filterCity', null, -1));
     $filterContent = $req->getQuery('qcontent', null, '');
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     if ($filterContent != '') {
         $where[] = "question_content like '%{$filterContent}%'";
     }
     if ($filterCity > -1) {
         $where[] = "addr = {$filterCity}";
     }
     $whereStr = implode(" and ", $where);
     $columns = ['id', 'q_id', 'img_url', 'addr', 'sort', 'question_content'];
     $count = CosPointquestion::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\Question', 'q_id = qa.question_id', 'qa')->where($whereStr)->execute()->count();
     $list = CosPointquestion::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\Question', 'q_id = qa.question_id', 'qa')->where($whereStr)->limit($limit, $offset)->execute()->toArray();
     foreach ($list as $k => $v) {
         if (!empty($list[$k]['addr']) && $list[$k]['addr'] != 0) {
             $tmp = SysOpenCity::findFirst("city_id = " . $list[$k]['addr'])->toArray();
             $list[$k]['city_name'] = $tmp['city_name'];
         } else {
             $list[$k]['city_name'] = '全国';
         }
     }
     $this->view->setVar("qcontent", $filterContent);
     $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->setVar('openCity', $this->openCityList());
     $this->view->pick("question_recommend/list");
 }
Exemple #5
0
 public function run()
 {
     //判断城市是否开通 未开通城市  banner 广告位显示全国 美容院不显示
     $banners = [];
     //首页banner
     $questionlists = [];
     //首页推荐问答
     $city_code = $this->getDataItem('city_code', 0);
     $userid = $this->getDataItem('user_id', 0);
     $is_open = SysOpenCity::findFirst(['columns' => "city_id", 'conditions' => "city_code = {$city_code} AND city_state = 1"]);
     $city_id = $is_open->city_id > 0 ? $is_open->city_id : 0;
     $alllimit = $this->getConfig()->national;
     //属于全国的banner条数
     //获取全国banner
     $banners = $this->getBanner($alllimit, 0);
     //获取属于全国的广告
     $advert = $this->getAdvert(0, null, "addtime desc", "position");
     //获取城市问答
     $limit_q = $this->getConfig()->question;
     $questionlists = $this->getQuestion(0, $limit_q, $userid, "sort DESC");
     //城市未开通
     if (!$city_id) {
         foreach ($advert as $k => $v) {
             $advert[$k]['advertisement_cover'] = PicUrl::ActivityCover($v['advertisement_cover'], $this->getDi());
         }
         $lists['banner'] = $banners;
         $lists['question'] = $questionlists;
         $lists['parlors'] = null;
         $lists['adverts'] = empty($advert) ? null : $advert;
         $this->setResult($lists);
     } else {
         $citylimit = $this->getConfig()->city;
         //获取城市banner
         $citybanner = $this->getBanner($citylimit, $city_id);
         $banners = array_merge($banners, $citybanner);
         //获取城市问答
         if (count($questionlists) < $limit_q) {
             //如果全国的问答条数不足 则查询城市问答补充
             $limit_c = $limit_q - count($questionlists);
             $questionlist = $this->getQuestion($city_id, $limit_c, $userid, "sort DESC");
             $questionlists = array_merge($questionlists, $questionlist);
         }
         /*************************************************获取城市广告**********************************/
         $pos_ids = array_column($advert, 'position');
         //如果没有全国的位置1的广告 则 查询是否有全国位置为1的广告
         if (!in_array(1, $pos_ids)) {
             $temp = $this->getAdvert($city_id, "position = 1", "addtime desc");
             if (count($temp)) {
                 $advert = array_merge($advert, $temp);
             }
         }
         //如果没有全国的位置2的广告 则 查询是否有全国位置为2的广告
         if (!in_array(2, $pos_ids)) {
             $temp = $this->getAdvert($city_id, "position = 2", "addtime desc");
             if (count($temp)) {
                 $advert = array_merge($advert, $temp);
             }
         }
         //如果没有全国的位置3的广告 则 查询是否有全国位置为3的广告
         if (!in_array(3, $pos_ids)) {
             $temp = $this->getAdvert($city_id, "position = 3", "addtime desc");
             if (count($temp)) {
                 $advert = array_merge($advert, $temp);
             }
         }
         $advert = $this->multi_array_sort($advert, 'position');
         foreach ($advert as $k => $v) {
             $advert[$k]['advertisement_cover'] = PicUrl::ActivityCover($v['advertisement_cover'], $this->getDi());
         }
         /*************************************************美容院*****************************************/
         //获取位置固定的美容院
         $parlor = $this->getParlor($city_id, 3, "show_start_time DESC,id DESC", "sort");
         $sortids = array_column($parlor, 'sort');
         if (count($sortids) < 3) {
             //当固定位置的首页推荐美容院不足时,随机获取没有固定位置的推荐数据
             $limit_r = 3 - count($sortids);
             $parlor_r = $this->getParlorRand($city_id, $limit_r);
             $parlor = array_merge($parlor, $parlor_r);
         }
         $parlor = $this->multi_array_sort($parlor, 'sort');
         foreach ($parlor as $k => $v) {
             if ($v) {
                 $parlor[$k]['cover'] = PicUrl::BeautyParlorCover($v['cover'], $this->getDi());
                 $parlor[$k]['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($v['bp_medal']);
                 unset($parlor[$k]['bp_medal']);
                 $tag = BeautyParlorTag::query()->columns(['i.tag_title'])->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'Apps\\Common\\Models\\BeautyParlorTag.tag_id = i.tag_id', 'i')->where('i.tag_state=1 and bp_id=:bid:')->bind(['bid' => $v['id']])->orderBy('sort desc,bp_tag_addtime asc')->execute()->toArray();
                 $tags = array_column($tag, 'tag_title');
                 $parlor[$k]['tags'] = empty($tags) ? null : $tags;
             }
         }
         /***************************************************返回结果集******************************************/
         $lists['banner'] = empty($banners) ? null : $banners;
         $lists['question'] = empty($questionlists) ? null : $questionlists;
         $lists['parlors'] = empty($parlor) ? null : $parlor;
         $lists['adverts'] = empty($advert) ? null : $advert;
         $this->setResult($lists);
     }
 }
Exemple #6
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);
 }
Exemple #7
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;
     }
 }
Exemple #8
0
 /**
  * 设置开通城市的排序值1.0
  * @return $this|ResponseResult
  */
 public function openCitySetOrderAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $order = intval($req->getPost('order', null, 0));
         if ($order < 0) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = SysOpenCity::findFirst('city_id=' . $id);
         if ($info) {
             $info->update(['city_order' => $order]);
         }
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }