Exemplo n.º 1
0
 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");
 }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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());
 }
Exemplo n.º 4
0
 /**
  * 通过区县标识获取开通城市ID
  * @param $district
  * @return int
  */
 public static function districtToOpenCityId($district)
 {
     // 获取地区的区号
     $area = SysAreaZipDistrictPhonecode::findFirst('K_ID = ' . $district);
     if (!$area) {
         return 0;
     }
     $phoneCode = $area->PHONE_CODE;
     $openCityInfo = SysOpenCity::query()->where('city_code = :code:', ['code' => $phoneCode])->execute()->getFirst();
     if (!$openCityInfo) {
         return 0;
     }
     return $openCityInfo->city_id;
 }
Exemplo n.º 5
0
 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");
 }
Exemplo n.º 6
0
 /**
  * 添加美粒宝典
  * @date: 2016年1月4日 
  * @author: chenxiaolin
  */
 public function addAction()
 {
     $this->setLeftNav('add');
     $req = $this->request;
     if (!$req->isPost()) {
         $this->view->setVar('openCity', SysOpenCity::find('city_state = 1'));
         $this->view->setVar("action", '/beautycanon/add');
         return;
     }
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->beautyParlorCover();
     //保存封面图片
     if ($cover == false || !is_array($cover) || count($cover) == 0 || $cover[0] == false) {
         if ($_FILES['bp_cover']['error'] == 1) {
             $response->sendError(ResponseResultStatus::UPLOAD_FILE_ERROR, '封面大小超过了1M!');
         } else {
             $response->sendError(ResponseResultStatus::UPLOAD_FILE_ERROR, '封面必须上传!');
         }
         return;
     }
     $title = $req->getPost("title");
     $content = $req->getPost("content");
     $fit = $req->getPost("fit");
     $assist = $req->getPost("assist");
     $city = $req->getPost("city");
     $summary = $req->getPost('summary');
     $url = $cover[0];
     $state = 1;
     //循环添加数据
     foreach ($city as $k => $v) {
         $beautyCanon = new CosBeautyCanon();
         $beautyCanon->content = $content;
         $beautyCanon->img_url = $url;
         $beautyCanon->title = $title;
         $beautyCanon->state = $state;
         $beautyCanon->fit = $fit;
         $beautyCanon->assist = $assist;
         $beautyCanon->settime = date("Y-m-d H:i:s");
         $beautyCanon->summary = $summary;
         $beautyCanon->city_id = $v;
         $status = $beautyCanon->save();
         //添加数据失败
         if ($status == false) {
             $this->databaseErrorLog($status);
             $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常!');
         }
     }
     $response->sendResult('ok');
     return $response;
 }
Exemplo n.º 7
0
 /**
  * 开通的城市
  * @return \Phalcon\Mvc\Model\Criteria
  */
 private function openCityList()
 {
     return SysOpenCity::find("city_state = 1");
 }
Exemplo n.º 8
0
 /**
  * 获取开通城市的ID
  * @param $code
  * @return int
  */
 public function getCityId($code)
 {
     $city = SysOpenCity::query()->columns('city_id')->where('city_code=:code: and city_state = 1')->bind(['code' => $code])->limit(1)->execute()->getFirst();
     return $city ? $city->city_id : 0;
 }
Exemplo n.º 9
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);
     }
 }
Exemplo n.º 10
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);
 }
Exemplo n.º 11
0
 /**
  * 跟新活动基础信息
  * @date: 2016年1月5日 
  * @author: chenxiaolin
  */
 public function updateAction()
 {
     $this->setLeftNav('update');
     $req = $this->request;
     if (!$req->isPost()) {
         $id = intval($req->getQuery('id', null, 0));
         $this->view->setVar('id', $id);
         $this->view->setVar('openCity', SysOpenCity::find());
         $this->view->setVar('info', Activity::findFirst('activity_id = ' . $id));
         $this->view->setVar('positionList', Position::valuesExplain());
         return;
     }
     //修改
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $id = intval($req->getPost('activity_id'));
     if ($id < 1) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     $type = intval($req->getPost('activity_type', null, 0));
     $title = $req->getPost('activity_title', null, '');
     $views = $req->getPost('views');
     //$cityId = intval ( $req->getPost ( 'city_id', null, 0 ) );
     //$posion_banner = intval ( $req->getPost ( 'posion_banner', null, 0 ) );
     //$time = $req->getPost ( 'activity_time', null, '' );
     $intro = $req->getPost('activity_intro', null, '');
     $out_link = $req->getPost('out_link', null, '');
     // 判断空数据
     if ($type <= 0 || empty($title)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     //判断是图文,还是外链地址
     if ($type == 1 && empty($intro)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     if ($type == 2 && empty($out_link)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     //判断外链地址是否合法
     if ($type == 2 && !Util::CheckUrl($out_link)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '外链地址不合法!');
         return $response;
     }
     //$timeArr = explode ( ' 至 ', $time );
     // 保存封面
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->activityCover();
     if ($cover == false || !is_array($cover) || count($cover) == 0 || $cover[0] == false) {
         if ($_FILES['activity_cover']['error'] == 1) {
             $response->sendError(ResponseResultStatus::UPLOAD_FILE_ERROR, '文件大小超过了2M!');
             return $response;
         }
     }
     $cover = $cover[0];
     /* if ($cover == false || ! is_array ( $cover ) || count ( $cover ) == 0 || $cover [0] == false) {
     			$cover = null;
     		} else {
     			$cover = $cover [0];
     		} */
     // 保存基础数据
     $info = Activity::findFirst('activity_id = ' . $id);
     $data = [];
     if ($info->activity_type != $type) {
         $data['activity_type'] = $type;
     }
     if ($info->activity_title != $title) {
         $data['activity_title'] = $title;
     }
     /* if ($info->city_id != $cityId) {//其他城市
     			//判断广告位是否存在
     			//$activity2 = Activity::findFirst('city_id = '.$cityId.' and posion_banner = '.$posion_banner);
     			$activity2 = Activity::findFirst("city_id = $cityId and posion_banner = $posion_banner and activity_state in ('1','0')");
     			if($activity2){//广告位已存在
     				$response->sendError ( ResponseResultStatus::BUSINESS, '当前城市的此广告位已存在!' );
     				return $response;
     			}
     			$data ['city_id'] = $cityId;
     			$data ['posion_banner'] = $posion_banner;
     			//推荐到其他城市时:活动状态设置
     			$curTime = time();
     			$startTime = strtotime($timeArr[0]);
     			$endTime = strtotime($timeArr[1]);
     			//1、活动开始时间大于当前时间:未发布--0
     			if(($startTime - $curTime) > 0){
     				$data ['activity_state'] = 0;
     			}elseif(($endTime - $curTime) < 0 ){
     				//2、活动结束时间小于当前时间:已结束--2
     				$data ['activity_state'] = 2;
     			}else{
     				//3、当前时间大于开始时间,小于结束时间:正常--1
     				$data ['activity_state'] = 1;
     			}
     					
     		}else{//本城市			
     			//根据城市id和广告位编号判断该城市的此广告位是否已存在
     			if($info -> posion_banner != $posion_banner){
     				//$activity = Activity::findFirst('city_id = '.$cityId.' and posion_banner = '.$posion_banner);
     				$activity = Activity::findFirst("city_id = $cityId and posion_banner = $posion_banner and activity_state in ('1','0')");
     				if($activity){//广告位已存在
     					$response->sendError ( ResponseResultStatus::BUSINESS, '当前城市的此广告位已存在!' );
     					return $response;
     				}else{//广告位可用
     					$data ['posion_banner'] = $posion_banner;
     				}
     			}			
     			$curTime = time();
     			$startTime = strtotime($timeArr[0]);
     			$endTime = strtotime($timeArr[1]);
     			//1、活动开始时间大于当前时间:未发布--0
     			if(($startTime - $curTime) > 0){
     				$data ['activity_state'] = 0;
     			}elseif(($endTime - $curTime) < 0 ){
     				//2、活动结束时间小于当前时间:已结束--2
     				$data ['activity_state'] = 2;
     			}else{
     				//3、当前时间大于开始时间,小于结束时间:正常--1
     				$data ['activity_state'] = 1;
     			}
     		} */
     if ($type == 1 && $info->activity_intro != $intro) {
         $data['activity_intro'] = $intro;
         $data['out_link'] = "";
     }
     if ($type == 2 && $info->out_link != $out_link) {
         $data['out_link'] = $out_link;
         $data['activity_intro'] = "";
     }
     if ($info->views != $views) {
         $data['views'] = $views;
     }
     /* $data ['activity_start_time'] = $timeArr [0];
     		$data ['activity_end_time'] = $timeArr [1]; */
     if ($cover != null) {
         $data['activity_cover'] = $cover;
     }
     $data['activity_update_time'] = date("Y-m-d H:i:s");
     $info->update($data);
     SearchASync::Instance()->noticeSync($id, SearchDataType::BeautyParlorService);
     $response->sendResult('ok');
     return $response;
 }
Exemplo n.º 12
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;
     }
 }
Exemplo n.º 13
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, '请求异常');
     }
 }
 /**
  * 开通的城市
  * @return \Phalcon\Mvc\Model\Criteria
  */
 private function openCityList()
 {
     return SysOpenCity::find();
 }
Exemplo n.º 15
0
 public function run()
 {
     $data = SysOpenCity::query()->columns(['city_code code', 'city_name name'])->where('city_state = 1')->orderBy('city_order DESC, city_id ASC')->execute()->toArray();
     $this->setResult($data);
 }
Exemplo n.º 16
0
 /**
  * 获取一个开通城市的信息
  * @param $code
  * @return mixed
  */
 public function getCity($code)
 {
     $data = SysOpenCity::find(['conditions' => 'city_code=' . $code . ' and city_state = 1'])->toArray();
     return $data ? $data[0] : [];
 }