예제 #1
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     if (0 < $id) {
         $this->activity = Activity::query()->columns(['activity_id id', 'city_id city', 'activity_type type', 'activity_title as title', 'activity_intro as intro', '0 beauty_parlors'])->where('activity_id=:id:')->bind(['id' => $id])->execute()->getFirst();
         if ($this->activity) {
             $parlor = ActivityBeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', '0 as tags', 'bp_medal as medal'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\ActivityBeautyParlor.beauty_parlor_id=bp.bp_id', 'bp')->where('bp.bp_state > 0 and activity_id = :id:')->bind(['id' => $id])->execute()->toArray();
             $this->activity->beauty_parlors = $parlor;
         }
     }
     $this->activity = $this->activity ? $this->activity : null;
     if ($this->activity) {
         //$this->activity->cover = PicUrl::ActivityCover($this->activity->cover, $this->getDi());
         for ($i = 0; $i < count($this->activity->beauty_parlors); $i++) {
             $this->activity->beauty_parlors[$i]['cover'] = PicUrl::BeautyParlorCover($this->activity->beauty_parlors[$i]['cover'], $this->getDi());
             $medal = $this->activity->beauty_parlors[$i]['medal'];
             unset($this->activity->beauty_parlors[$i]['medal']);
             $this->activity->beauty_parlors[$i]['medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($medal);
             $this->activity->beauty_parlors[$i]['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($medal);
             $this->activity->beauty_parlors[$i]['tags'] = \Apps\Common\Libs\BeautyParlor::getTags($this->activity->beauty_parlors[$i]['id']);
         }
         $this->activity->intro = \Apps\Common\Libs\BeautyParlor::formatServiceIntro($this->activity->intro, $this->getDi(), true);
     }
     $this->setResult($this->activity);
 }
예제 #2
0
 private function syncActivity($id)
 {
     $info = Activity::findFirst('activity_id = ' . $id);
     if (!$info) {
         return false;
     }
     // 删除数据
     if ($info->activity_state <= 0) {
         $this->delete(SearchDataType::Activity, $info->activity_id);
         return true;
     }
     // 同步数据
     $title = $info->activity_title;
     $searchContent = \Apps\Common\Libs\BeautyParlor::formatServiceIntro($info->activity_intro, $this->getDI());
     $tagInt = $info->city_id;
     $tagStr = strval($info->activity_type);
     $showData = json_encode(['id' => $info->activity_id, 'type' => $info->activity_type, 'title' => $info->activity_title, 'cover' => $info->activity_cover, 'state' => $info->activity_state]);
     $this->save(SearchDataType::Activity, $id, $showData, $title, $searchContent, $tagInt, $tagStr);
     return true;
 }
예제 #3
0
 public function run()
 {
     $city_code = $this->getDataItem('city_code', 0);
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $cityId = $this->getCityId($city_code);
     if ($cityId <= 0) {
         //return $this->errorLog(ResultStatus::CITY_NOT_OPEN, '城市未开通');
         $cityId = 2;
     }
     $this->activity = Activity::query()->columns(['activity_id id', 'activity_type type', 'activity_title as title', 'activity_cover as cover', 'activity_state as state', 'activity_end_time - NOW() AS ts'])->where('activity_state > 0 and city_id=:city_id:')->bind(['city_id' => $cityId])->limit($limit, $offset)->execute()->toArray();
     $this->activity = $this->activity ? $this->activity : [];
     for ($i = 0; $i < count($this->activity); $i++) {
         $this->activity[$i]['cover'] = PicUrl::ActivityCover($this->activity[$i]['cover'], $this->getDi());
         $this->activity[$i]['state'] = $this->activity[$i]['ts'] > 0 ? $this->activity[$i]['state'] : 2;
         unset($this->activity[$i]['ts']);
     }
     $data = ['recommend' => $this->getRecommend($cityId), 'activity' => $this->activity];
     $this->setResult($data);
 }
예제 #4
0
 public function run()
 {
     $city_code = $this->getDataItem('city_code', 0);
     $page = intval($this->getDataItem('page', 1));
     $state = $this->getDataItem('state', 1);
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $city = $this->getCity($city_code);
     if (!$city || $city['city_id'] <= 0) {
         $where = "activity_state = 1 and city_id = 0";
         //            return $this->errorLog(ResultStatus::CITY_NOT_OPEN, '城市未开通');
         //            $cityId = 2;
     } else {
         //            $cityId = $city['city_id'];
         $where = "activity_state = 1 and city_id in({$city['city_id']}, 0)";
     }
     $date = date('Y-m-d H:i:s');
     if ($state == 1) {
         // 进行中
         $where .= " and activity_start_time <= '{$date}' and activity_end_time >= '{$date}'";
     } else {
         // 即将开始
         $where .= " and activity_start_time >= '{$date}'";
     }
     $this->activity = Activity::query()->columns(['city_id', 'activity_id id', 'activity_type type', 'activity_title as title', 'activity_cover as cover', 'activity_start_time', 'activity_end_time', 'activity_intro', 'out_link', 'views', 'comments'])->where($where)->orderBy("IF(city_id=0, activity_update_time, 1) DESC,activity_update_time DESC")->limit($limit, $offset)->execute()->toArray();
     foreach ($this->activity as $k => $val) {
         if ($val['city_id'] == 0) {
             $this->activity[$k]['city_name'] = '全国';
         } else {
             $this->activity[$k]['city_name'] = $city['city_name'] ?: '';
         }
         $this->activity[$k]['cover'] = PicUrl::ActivityCover($this->activity[$k]['cover'], $this->getDi());
         unset($this->activity[$k]['city_id']);
     }
     $this->setResult($this->activity);
 }
예제 #5
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     if (0 < $id) {
         $this->indexInfo = Activity::query()->columns(['activity_intro', 'activity_cover'])->where('activity_state = 1 and activity_type = 1 and activity_id = ' . $id)->execute()->getFirst();
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '参数异常');
     }
     if ($this->indexInfo) {
         if ($this->indexInfo->activity_intro == null) {
             $this->indexInfo->activity_intro = null;
         }
         if ($this->indexInfo->activity_cover == null) {
             $this->indexInfo->activity_cover = null;
         } else {
             //处理图片
             $this->indexInfo->activity_cover = "http://img.meelier.com/" . $this->indexInfo->activity_cover;
             $this->indexInfo->activity_intro = str_replace('src="/ueditor/php/upload/image/', 'src="http://meelier.com/ueditor/php/upload/image/', $this->indexInfo->activity_intro);
         }
     } else {
         $this->indexInfo = null;
     }
     $this->setResult($this->indexInfo);
 }
예제 #6
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     $user_id = intval($this->getDataItem('user_id', 0));
     if ($id == 0) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全');
     }
     $Activity = new Activity();
     $ActivityViewsUser = new ActivityViewsUser();
     $data = $Activity->query()->columns(['activity_id id', 'activity_type type', 'activity_title as title', 'activity_cover as cover', 'activity_start_time', 'activity_end_time', 'activity_intro', 'views', 'comments'])->where("activity_id = {$id}")->execute()->toArray();
     $data = $data ? $data[0] : [];
     $data['user_views_list'] = $ActivityViewsUser->getViewsUserList($id, 0, 7);
     $data['cover'] = $data['cover'] ? PicUrl::ActivityCover($data['cover'], $this->getDi()) : '';
     $this->setResult($data);
     $count = 1;
     $Activity->getReadConnection()->query("UPDATE activity SET views = views + {$count} WHERE activity_id = {$id}");
     if ($user_id) {
         $ActivityViewsUser->addData($id, $user_id);
     }
     /*if(0 < $id) {
                 $this->activity = Activity::query()
                     ->columns(['activity_id id',
                         'city_id city',
                         'activity_type type',
                         'activity_title as title',
                         'activity_intro as intro',
                         '0 beauty_parlors',
                     ])
                     ->where('activity_id=:id:')
                     ->bind(['id'=>$id])
                     ->execute()->getFirst();
                 if($this->activity){
                     $parlor = ActivityBeautyParlor::query()
                         ->columns([
                             'bp_id as id',
                             'bp_name as name',
                             'bp_cover as cover',
                             'bp_address as address',
                             '0 as tags',
                             'bp_medal as medal'])
                         ->leftJoin('Apps\Common\Models\BeautyParlor',
                             'Apps\Common\Models\ActivityBeautyParlor.beauty_parlor_id=bp.bp_id','bp')
                         ->where('bp.bp_state > 0 and activity_id = :id:')
                         ->bind(['id' => $id])
                         ->execute()->toArray();
                     $this->activity->beauty_parlors = $parlor;
                 }
             }
     
             $this->activity = $this->activity ? $this->activity : null;
             if($this->activity) {
                 //$this->activity->cover = PicUrl::ActivityCover($this->activity->cover, $this->getDi());
                 for($i = 0; $i < count($this->activity->beauty_parlors); $i++) {
                     $this->activity->beauty_parlors[$i]['cover'] = PicUrl::BeautyParlorCover($this->activity->beauty_parlors[$i]['cover'], $this->getDi());
     
                     $medal = $this->activity->beauty_parlors[$i]['medal'];
                     unset($this->activity->beauty_parlors[$i]['medal']);
                     $this->activity->beauty_parlors[$i]['medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($medal);
                     $this->activity->beauty_parlors[$i]['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($medal);
                     $this->activity->beauty_parlors[$i]['tags'] = \Apps\Common\Libs\BeautyParlor::getTags($this->activity->beauty_parlors[$i]['id']);
                 }
     
                 $this->activity->intro = \Apps\Common\Libs\BeautyParlor::formatServiceIntro($this->activity->intro, $this->getDi(), true);
             }
             $this->setResult($this->activity);*/
 }
예제 #7
0
 /**
  * 活动预览
  * @date: 2016年1月12日 
  * @author: chenxiaolin
  */
 public function activityPreviewAction()
 {
     $id = $this->request->getQuery('id');
     if (empty($id)) {
         echo '活动不存在!';
         $this->view->disable();
         return;
     }
     //活动内容
     $date = date('Y-m-d H:i:s');
     $activity = Activity::query()->columns(['Apps\\Common\\Models\\Activity.activity_id', 'activity_title', 'activity_cover', 'activity_intro', 'out_link', 'activity_addtime', 'views', 'comments'])->where("activity_id = {$id} and activity_state in (0,1)")->execute()->getFirst();
     if (!$activity) {
         echo '活动不存在!';
         $this->view->disable();
         return;
     } else {
         $activity = $activity->toArray();
     }
     $activity['activity_cover'] = PicUrl::ActivityCover($activity['activity_cover'], $this->getDI());
     //活动回复
     $comment = ActivityComment::query()->columns(['comment_content', 'user.user_nickname', 'user.user_cover', 'user.user_gender'])->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\ActivityComment.comment_user_id = user.user_id', 'user')->where("Apps\\Common\\Models\\ActivityComment.activity_id = {$id} and Apps\\Common\\Models\\ActivityComment.state = 1")->order('addtime desc')->execute()->toArray();
     foreach ($comment as $k => $v) {
         $comment[$k]['user_cover'] = PicUrl::UserCover($comment[$k]['user_cover'], $this->getDI());
     }
     $lastTime = ActivityComment::maximum(array("activity_id = {$id} and state = 1", 'column' => 'addtime'));
     //美人儿已阅处显示的头像
     $covers = ActivityComment::query()->columns(['distinct comment_user_id', 'user.user_cover'])->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\ActivityComment.comment_user_id = user.user_id', 'user')->where("Apps\\Common\\Models\\ActivityComment.activity_id = {$id} and Apps\\Common\\Models\\ActivityComment.state = 1")->order('addtime desc')->limit(7)->execute()->toArray();
     foreach ($covers as $k => $v) {
         $covers[$k]['user_cover'] = PicUrl::UserCover($covers[$k]['user_cover'], $this->getDI());
     }
     $this->view->setVar('activity', $activity);
     $this->view->setVar('comment', $comment);
     $this->view->setVar('lastTime', $lastTime);
     $this->view->setVar('covers', $covers);
     $this->tag->setTitle($activity->activity_title);
 }
예제 #8
0
 /**
  * 发布/结束活动
  * @date: 2016年1月5日 
  * @author: chenxiaolin
  */
 public function setStateAction()
 {
     $req = $this->request;
     if (!$req->isPost()) {
         $id = intval($req->getQuery('id', null, 0));
         $state = intval($req->getQuery('state'));
         $this->view->setVar('id', $id);
         $this->view->setVar('state', $state);
         $this->view->setVar("action", '/activity/setState');
         return;
     }
     if ($req->isPost()) {
         $response = new ResponseResult();
         $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
         $response->callbackJavascriptTag = true;
         $id = intval($req->getPost('id', null, 0));
         $state = intval($req->getPost('state', null, -10000));
         $activity_start_time = $req->getPost('activity_start_time');
         $activity_end_time = $req->getPost('activity_end_time');
         //发布时:开始时间不能>=结束时间
         if ($state == 1 && $activity_start_time >= $activity_end_time) {
             $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '开始时间不能大于等于结束时间!');
             return $response;
         }
         if (!in_array($state, [0, 1, 2])) {
             return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = Activity::findFirst('activity_id = ' . $id);
         //活动存在
         if ($info) {
             if ($state == 1) {
                 //发布活动:修改活动的开始时间,结束时间,状态等信息
                 $info->update(['activity_state' => $state, 'activity_update_time' => date('Y-m-d H:i:s'), 'activity_start_time' => $activity_start_time, 'activity_end_time' => $activity_end_time]);
                 SearchASync::Instance()->noticeSync($id, SearchDataType::Activity);
                 return $response->sendResult('ok');
             } else {
                 //结束活动
                 $info->update(['activity_state' => $state, 'activity_update_time' => date('Y-m-d H:i:s')]);
                 SearchASync::Instance()->noticeSync($id, SearchDataType::Activity);
                 return (new ResponseResult())->sendResult('ok');
                 /* $arr=[
                        'status'=>10000
                    ];
                    echo json_encode($arr);
                    exit; */
             }
         }
     } else {
         return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
예제 #9
0
 public function run()
 {
     /* $page = intval($this->getDataItem('page',1));
       	$keyword = $this->getDataItem('keyword');
       	$city_code = $this->getDataItem('city_code',023); */
     $param = $_POST['post_body'];
     $param = str_replace("}", '', $param);
     $param = str_replace("{", '', $param);
     $paramarr = explode(",", $param);
     foreach ($paramarr as $k => $v) {
         $tmparr = explode(":", $paramarr[$k]);
         $tmp = $tmparr[0];
         $newarrs[$tmp] = $tmparr[1];
     }
     //var_dump($newarrs);
     //exit;
     foreach ($newarrs as $k => $v) {
         if ($k == '"page"') {
             $page = str_replace('"', '', $v);
         } elseif ($k == '"city_code"') {
             $city_code = str_replace('"', '', $v);
         } elseif ('"keyword"') {
             $keyword = str_replace('"', '', $v);
         }
     }
     $cityId = $this->getCityId($city_code);
     if ($cityId == 0) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '城市代码错误或城市未开通!');
     }
     if (empty($keyword) || $keyword == '""') {
         $offset = ($page - 1) * 10;
         $list = ActivityModel::query()->where("city_id = {$cityId} and activity_state = 1")->limit(10, $offset)->execute()->toArray();
         foreach ($list as $arr) {
             foreach ($arr as $k => $v) {
                 $k = str_replace("activity_", "", $k);
                 $arrs[$k] = $v;
             }
             $newarr[] = $arrs;
         }
         $list = $newarr;
         foreach ($list as $k => $v) {
             $list[$k]['cover'] = "http://img.meelier.com/" . $list[$k]['cover'];
         }
         $this->setResult($list);
     } else {
         /* $limit = $this->getConfig()->limit;
            $offset = ($page-1) * $limit;
            $data = $this->searchActivity($cityId, $keyword, $limit, $offset);
            $this->setResult($data); */
         $offset = ($page - 1) * 10;
         $list = ActivityModel::query()->where("city_id = '" . $cityId . "' and activity_title like '%" . $keyword . "%' and activity_state = 1")->limit(10, $offset)->execute()->toArray();
         foreach ($list as $arr) {
             foreach ($arr as $k => $v) {
                 $k = str_replace("activity_", "", $k);
                 $arrs[$k] = $v;
             }
             $newarr[] = $arrs;
         }
         $list = $newarr;
         foreach ($list as $k => $v) {
             $list[$k]['cover'] = "http://img.meelier.com/" . $list[$k]['cover'];
         }
         $this->setResult($list);
     }
 }
예제 #10
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, 2])) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = Activity::findFirst('activity_id = ' . $id);
         /* if ($info) {
         				$info->update ( [ 
         						'activity_state' => $state 
         				] );
         			} */
         $end_time = strtotime($info->activity_end_time);
         //活动结束时间
         $current_time = time();
         //当前时间
         $numTime = $end_time - $current_time;
         //活动结束的时候,将活动结束时间设置为当前时间
         if ($info) {
             //判断活动结束时间是否大于当前时间:大于-->活动结束时间设置为当前时间;小于:--> 活动已结束
             if ($state == 2 && $numTime > 0) {
                 $info->update(['activity_state' => $state, 'activity_end_time' => date('Y-m-d H:i:s')]);
             } else {
                 $info->update(['activity_state' => $state]);
             }
         }
         SearchASync::Instance()->noticeSync($id, SearchDataType::Activity);
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
예제 #11
0
 /**
  * 活动
  */
 public function activityAction()
 {
     $id = $this->request->getQuery('id');
     if (empty($id)) {
         echo '活动不存在!';
         $this->view->disable();
         return;
     }
     $activity = Activity::query()->columns(['activity_id id', 'city_id city', 'activity_type type', 'activity_title as title', 'activity_intro as intro', '0 beauty_parlors'])->where('activity_id=:id:')->bind(['id' => $id])->execute()->getFirst();
     if (!$activity) {
         echo '活动不存在!';
         $this->view->disable();
         return;
     }
     $this->view->setVar('activity', $activity);
     $this->tag->setTitle($activity->title);
     $parlors = ActivityBeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', '0 as tags', 'bp_medal as medal'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\ActivityBeautyParlor.beauty_parlor_id=bp.bp_id', 'bp')->where('bp.bp_state > 0 and activity_id = :id:')->bind(['id' => $id])->execute()->toArray();
     for ($i = 0; $i < count($parlors); $i++) {
         $parlors[$i]['cover'] = PicUrl::BeautyParlorCover($parlors[$i]['cover'], $this->getDi());
         $medal = $parlors[$i]['medal'];
         unset($parlors[$i]['medal']);
         $parlors[$i]['medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($medal);
         $parlors[$i]['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($medal);
         $parlors[$i]['tags'] = \Apps\Common\Libs\BeautyParlor::getTags($parlors[$i]['id']);
     }
     $this->view->setVar('parlors', $parlors);
 }