Exemplo n.º 1
0
 /**
  * 开通的城市
  * @return \Phalcon\Mvc\Model\Criteria
  */
 private function openCityList()
 {
     return SysOpenCity::find("city_state = 1");
 }
Exemplo n.º 2
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.º 3
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.º 4
0
 /**
  * 开通的城市
  * @return \Phalcon\Mvc\Model\Criteria
  */
 private function openCityList()
 {
     return SysOpenCity::find();
 }
Exemplo n.º 5
0
 /**
  * 开通城市管理列表
  * @date: 2016年1月6日 
  * @author: chenxiaolin
  */
 public function openCityListAction()
 {
     $this->setLeftNav('openCityList');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $filterCity = $req->getQuery('filterCity', null, -10000);
     $filterState = $req->getQuery('filterState', null, -10000);
     $where = [];
     if ($filterCity > -10000) {
         $where[] = " city_id = {$filterCity} ";
     }
     if ($filterState > -10000) {
         $where[] = " city_state = {$filterState} ";
     }
     $whereStr = implode(' AND ', $where);
     $data = SysOpenCity::query()->where($whereStr)->execute();
     $this->view->setVar('openCity', SysOpenCity::find());
     $this->view->setVar('filterCity', $filterCity);
     $this->view->setVar('filterState', $filterState);
     //$this->view->setVar('data', SysOpenCity::find($where));
     $this->view->setVar('data', $data);
 }
Exemplo n.º 6
0
 /**
  * 开放车管你是列表
  */
 public function openCityListAction()
 {
     $this->setLeftNav('openCityList');
     $this->view->setVar('data', SysOpenCity::find());
 }
Exemplo n.º 7
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] : [];
 }