Exemple #1
0
 /**
  * 标签选择
  */
 public function layerAction()
 {
     $req = $this->request;
     $this->view->setVar('tags', $req->getQuery('tags', null, ''));
     $this->view->setVar('callback', $req->getQuery('callback', null, ''));
     $this->view->setVar('dataList', BeautyParlorTagInfo::query()->columns('tag_id id, tag_title title')->where('tag_state = 1')->execute());
 }
Exemple #2
0
 public function run()
 {
     $data = BeautyParlorTagInfo::query()->columns(['tag_id id', 'tag_title name'])->where('tag_state = 1 AND parent_id = 0')->orderBy('tag_id DESC')->execute()->toArray();
     foreach ($data as $k => $v) {
         $list[$k]['id'] = $v['id'];
         $list[$k]['name'] = $v['name'];
         $list[$k]['childtag'] = BeautyParlorTagInfo::query()->columns(['tag_id id', 'tag_title name'])->where('tag_state = 1 AND parent_id = :id:')->bind(['id' => $v['id']])->orderBy('tag_id DESC')->execute()->toArray();
     }
     $this->setResult($list);
 }
Exemple #3
0
 public function run()
 {
     $limit = $this->getConfig()->limit;
     //统计问答标签出现的次数 倒序获取次数最多即热门标签
     $list = QuestionTag::query()->columns('b.tag_id id,tag_name name')->join('Apps\\Common\\Models\\BeautyParlorTagInfo', 'Apps\\Common\\Models\\QuestionTag.tag_id = b.tag_id', 'b')->where('tag_state = 1 AND b.parent_id IN (SELECT s.tag_id FROM Apps\\Common\\Models\\BeautyParlorTagInfo as s WHERE tag_state>0 AND parent_id=0 ) GROUP BY Apps\\Common\\Models\\QuestionTag.tag_id')->orderBy('COUNT(Apps\\Common\\Models\\QuestionTag.tag_id) desc')->limit($limit, 0)->execute()->toArray();
     //如果热门标签不足 获取 最新标签补足
     if (count($list) < $limit) {
         $limit -= count($list);
         $temp = BeautyParlorTagInfo::query()->columns(['tag_id id', 'tag_title name'])->where('tag_state = 1 AND  parent_id IN (SELECT tag_id FROM Apps\\Common\\Models\\BeautyParlorTagInfo WHERE tag_state>0 AND parent_id=0 )')->orderBy('tag_id DESC')->limit($limit, 0)->execute()->toArray();
         //合并数据
         $list = array_merge($list, $temp);
     }
     $this->setResult($list);
 }
Exemple #4
0
 private function formatTags($tags, $bp_id)
 {
     $ds = [];
     if ($tags) {
         $ds = explode(',', $tags);
         foreach ($ds as $r) {
             $wherearr[] = "Apps\\Common\\Models\\BeautyParlorTagInfo.tag_title = '{$r}' and b.bp_id = {$bp_id}";
         }
         $where = implode(" or ", $wherearr);
         $list = BeautyParlorTagInfo::query()->columns(['Apps\\Common\\Models\\BeautyParlorTagInfo.tag_title', 'b.sort'])->leftJoin('Apps\\Common\\Models\\BeautyParlorTag', 'Apps\\Common\\Models\\BeautyParlorTagInfo.tag_id=b.tag_id', 'b')->where($where)->orderBy('b.sort asc')->execute()->toArray();
     }
     unset($ds);
     foreach ($list as $r) {
         $ds[] = $r['tag_title'];
     }
     return $ds;
 }
 /**
  * 列表
  */
 public function listAction()
 {
     $this->setLeftNav('tag_list');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $list = BeautyParlorTagInfo::query()->limit($limit, $offset)->orderBy("tag_id desc")->execute()->toArray();
     foreach ($list as $k => $v) {
         if ($list[$k]['parent_id'] != 0) {
             $tag_info = BeautyParlorTagInfo::find("tag_id = " . $list[$k]['parent_id'])->toArray();
             $list[$k]['parent_name'] = $tag_info[0]['tag_title'];
         }
     }
     $total = BeautyParlorTagInfo::count();
     $this->view->setVar('total', $total);
     $this->view->setVar('page', $page);
     $this->view->setVar('limit', $limit);
     $this->view->setVar('data', $list);
 }
Exemple #6
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $question_tag = $this->getDataItem('tag', '');
     $custom_tag = $this->getDataItem('custom_tag', '');
     $question_content = Keyword::Filter($this->getDataItem('content', ''));
     $city_code = (string) $this->getDataItem('city_code', '0');
     $up = new UploadPic();
     if ($question_pics = $up->questionPic()) {
         //            $question_pics = json_encode(array_slice($question_pics, 0, 3));
         $question_pics = json_encode($question_pics);
     } else {
         $question_pics = json_encode([]);
     }
     if (!empty($question_content) && $city_code != '0') {
         $q = new Question();
         $q->user_id = $this->getUserAuth()->userId;
         //关键字替换
         $keyword = CosQKeyword::query()->execute()->toArray();
         foreach ($keyword as $k => $v) {
             $question_content = str_replace($v['keyword'], '***', $question_content);
         }
         if ($question_tag) {
             $tag_id = '';
             $tagList = [];
             foreach ($question_tag as $k => $val) {
                 $tagList[] = $val['name'];
                 $tag_id .= $val['id'] . ',';
             }
             $tagLists = BeautyParlorTagInfo::query()->where('tag_id in(' . trim($tag_id, ',') . ')')->execute()->toArray();
             foreach ($tagLists as $val) {
                 if ($val['parent_id'] == 0) {
                     return $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, '不能选择一级标签!');
                 }
             }
             if ($custom_tag) {
                 $tagList[] = $custom_tag;
             }
             $q->question_tag = json_encode($tagList);
         }
         $q->question_content = $question_content;
         $q->question_pics = $question_pics;
         $date = date('Y-m-d H:i:s');
         $q->last_reply_time = $date;
         $q->question_addtime = $date;
         $q->city_code = $city_code;
         if ($q->save()) {
             if ($question_tag) {
                 // 保存问答的标签
                 $tagData = '';
                 foreach ($question_tag as $k => $val) {
                     $tagData .= "({$val['id']}, '{$val["name"]}', {$q->question_id}),";
                 }
                 $tagData = trim($tagData, ',');
                 $q->getReadConnection()->query("INSERT INTO question_tag (tag_id, tag_name, question_id) VALUES {$tagData}");
             }
             $this->id = $q->question_id;
             $this->success = 1;
             //                SearchASync::Instance()->noticeSync($q->question_id, SearchDataType::Question);
             //推送消息
             /*$phoneNum = [
                             	'15823522906',
                             	'13883156314',
                             	'18725873971',
                             	'15086691064',
                             	'18996156384',
                             	'13752904126',
                             	'18523066564',
                             	'15723278358',
                             	'18523989994',
                             	'15111992368',
                             	'18123640250',
                                 '18323868684',
                             ];
                             $push = new Jpush();
                             foreach($phoneNum as $k => $v){
                             	$param = array(
                             			'type' => 8,
                             			'ispushservice' => 0,
                             			'phone' => $v,
                             			'content' => '有新的问题啦:'.mb_substr($question_content,0,10,'utf-8').',快去回答吧!',
                             			'shop_id' => 0
                             	);
             
                             	$rs = $push -> setval($param);
                             	if(empty($rs)){
                             		$push -> push();
                             	}
                             	continue;
                             }*/
             // 推送测试(测试用的)
             $phoneNum = ['18723568681', '17790274639', '18225097233', '18723793180'];
             $push = new Jpush();
             foreach ($phoneNum as $k => $v) {
                 $param = array('type' => 8, 'ispushservice' => 0, 'phone' => $v, 'content' => '有新的问题啦:' . mb_substr($question_content, 0, 10, 'utf-8') . ',快去回答吧!', 'shop_id' => 0);
                 $rs = $push->setval($param);
                 if (empty($rs)) {
                     $push->push();
                 }
                 continue;
             }
         } else {
             return $this->databaseErrorLog($q);
         }
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "");
     }
     $this->setResult(['id' => $this->id, 'success' => $this->success]);
 }
Exemple #7
0
 private function getsql($keyword)
 {
     $tmp = [];
     $wherearr = [];
     $newarr = [];
     $keywordarr = explode(" ", $keyword);
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorTagInfo::query()->columns("tag_id")->where("tag_title = '" . $v . "'")->execute()->toArray();
         if (count($tmp) > 0) {
             //$arr['tag'][]=$tmp;
             $tag_id = BeautyParlorTag::query()->columns("bp_id")->where("tag_id = " . $tmp[0]['tag_id'] . " and sort < 4")->execute()->toArray();
             if (count($tag_id) > 0) {
                 foreach ($tag_id as $r) {
                     $newarr[] = $r['bp_id'];
                 }
                 $bp_ids = implode(",", $newarr);
                 $wherearr[] = "bp_id in ({$bp_ids})";
                 $order = " find_in_set(bp_id,'{$bp_ids}') ";
             }
         }
     }
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorModel::query()->columns("bp_name")->where("bp_name like '%" . $v . "%'")->execute()->toArray();
         if (count($tmp) > 0) {
             $wherearr[] = "bp_name like '%" . $v . "%'";
         }
     }
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorModel::query()->columns("bp_address")->where("bp_address like '%" . $v . "%'")->execute()->toArray();
         if (count($tmp) > 0) {
             $wherearr[] = "bp_address like '%" . $v . "%'";
         }
     }
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorModel::query()->columns("bp_intro")->where("bp_intro like '%" . $v . "%'")->execute()->toArray();
         if (count($tmp) > 0) {
             $wherearr[] = "bp_intro like '%" . $v . "%'";
         }
     }
     $where = implode(" or ", $wherearr);
     if ($where != '') {
         $data['where'] = "(" . $where . ") and (bp_state = 1)";
     } else {
         $data['where'] = "";
     }
     if ($order == '') {
         $order = " bp_id desc";
     }
     $data['order'] = $order;
     return $data;
 }
 /**
  * 预览美容院
  * @date: 2016年1月28日 
  * @author: chenxiaolin
  */
 public function beautyParlorPreviewAction()
 {
     $id = $this->request->getQuery('id');
     if (empty($id)) {
         echo '美容院不存在!';
         $this->view->disable();
         return;
     }
     //美容院
     $parlor = BeautyParlor::query()->columns(['Apps\\Common\\Models\\BeautyParlor.bp_id', 'Apps\\Common\\Models\\BeautyParlor.bp_name as name', 'Apps\\Common\\Models\\BeautyParlor.bp_address', 'Apps\\Common\\Models\\BeautyParlor.bp_medal', 'Apps\\Common\\Models\\BeautyParlor.bp_intro', 'bpAttr.low_price', 'bpAttr.open_time', 'bpAttr.close_time', 'bpAttr.open_year', 'bpAttr.shop_area', 'bpAttr.service_num', 'bpAttr.facilities'])->leftJoin('Apps\\Common\\Models\\BeautyParlorAttr', 'Apps\\Common\\Models\\BeautyParlor.bp_id = bpAttr.beauty_parlor_id', 'bpAttr')->where("Apps\\Common\\Models\\BeautyParlor.bp_id = {$id}")->execute()->getFirst();
     if ($parlor) {
         $parlor->bp_medal = \Apps\Common\Libs\BeautyParlor::getMedalVerify($parlor->bp_medal);
         $parlor->facilities = json_decode($parlor->facilities, true);
     } else {
         echo '美容院不存在!';
         $this->view->disable();
         return;
     }
     //标签
     $tag = BeautyParlorTagInfo::query()->columns(['tag_title'])->leftJoin('Apps\\Common\\Models\\BeautyParlorTag', 'bpTag.tag_id = Apps\\Common\\Models\\BeautyParlorTagInfo.tag_id', 'bpTag')->where("bpTag.bp_id = {$id} and Apps\\Common\\Models\\BeautyParlorTagInfo.tag_state = 1")->execute()->toArray();
     //轮播图片
     $photos = BeautyParlorPhotos::query()->columns(['photo_url'])->where("beauty_parlor_id = {$id} and photo_state = 1")->execute()->toArray();
     foreach ($photos as $k => $v) {
         $photos[$k]['photo_url'] = PicUrl::BeautyParlorPic($photos[$k]['photo_url'], $this->getDI());
     }
     //服务项目
     $service = BeautyParlorService::query()->columns(['service_name', 'service_price', 'service_cover'])->where("beauty_parlor_id = {$id}")->execute()->toArray();
     foreach ($service as $k => $v) {
         $service[$k]['service_cover'] = PicUrl::BeautyParlorCover($service[$k]['service_cover'], $this->getDI());
     }
     //用户评论
     $comment = BeautyParlorComment::query()->columns(['u.user_id', 'u.user_nickname', 'u.user_cover', 'comment_addtime', 'comment_info', 'comment_photos'])->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\BeautyParlorComment.user_id=u.user_id', 'u')->where("Apps\\Common\\Models\\BeautyParlorComment.beauty_parlor_id = {$id} and Apps\\Common\\Models\\BeautyParlorComment.comment_state = 1")->execute()->toArray();
     foreach ($comment as $k => $v) {
         $comment[$k]['user_cover'] = PicUrl::UserCover($comment[$k]['user_cover'], $this->getDI());
         $comment[$k]['comment_photos'] = PicUrl::BeautyParlorComment(json_decode($comment[$k]['comment_photos'], true), $this->getDI());
         if (unserialize(base64_decode($comment[$k]['comment_info']))) {
             $comment[$k]['comment_info'] = unserialize(base64_decode($comment[$k]['comment_info']));
         }
     }
     $this->view->setVar('parlor', $parlor);
     $this->view->setVar('photos', $photos);
     $this->view->setVar('service', $service);
     $this->view->setVar('tag', $tag);
     $this->view->setVar('comment', $comment);
     $this->tag->setTitle($parlor['name']);
     $this->assets->collection('footer')->addJs('/libs/zepto/zepto-1.1.6.min.js', false)->addJs('/libs/iscroll/iscroll.js', false)->addJs('/assets/frontend/js/share/bp-view.js', false);
 }