Пример #1
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);
 }
Пример #2
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);
 }
Пример #3
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;
 }
Пример #4
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]);
 }
Пример #5
0
 /**
  * 添加问题
  * @date: 2016-1-15 
  * @author: futao
  */
 public function addquestionAction()
 {
     $this->setLeftNav('addquestion');
     $req = $this->request;
     if (!$req->isPost()) {
         $userList = UserBase::find("is_manage = 1");
         $tag = BeautyParlorTagInfo::find("parent_id != 0 and tag_state = 1");
         $this->view->setVar('city_list', $this->openCityList());
         $this->view->setVar('userlist', $userList);
         $this->view->setVar('tag', $tag);
         $this->view->pick("question/add");
         return;
     }
     $this->view->disable();
     $echo = function ($msg, $state = false) {
         echo '<script type="text/javascript">';
         echo 'parent.formResult("' . $msg . '", ' . ($state ? 1 : 0) . ')';
         echo '</script>';
     };
     $questionContent = $req->getPost('question_content', null, '');
     $questionTag = $req->getPost('question_tag', null, '');
     $questionBrowsers = intval($req->getPost('question_browsers', null, 0));
     $userId = intval($req->getPost('user_id', null, 0));
     $cityCode = intval($req->getPost('city_id', null, 0));
     if ($userId < 0 || $questionBrowsers < 0) {
         $echo("添加失败!");
         return;
     }
     if (is_array($questionTag)) {
         foreach ($questionTag as $val) {
             $tagArr = explode(',', $val);
             $tagName = $tagArr[1];
             $tagNameArr[] = $tagName;
         }
     } else {
         $echo("标签必选!");
         return;
     }
     $questionModel = new Question();
     //保存图片
     if ($_FILES['q_photos']['name'][0] != '') {
         $uploadFile = new UploadPic();
         $uploadFile->request = $req;
         $questionPics = $uploadFile->questionPic();
         $questionModel->question_pics = json_encode($questionPics);
     } else {
         $questionModel->question_pics = json_encode([]);
     }
     $questionModel->question_content = $questionContent;
     $questionModel->city_code = $cityCode;
     $questionModel->question_browsers = $questionBrowsers;
     $questionModel->question_tag = json_encode($tagNameArr);
     $questionModel->user_id = $userId;
     if (!$questionModel->save()) {
         $echo("添加失败!");
         return;
     }
     if ($questionTag != '' && is_array($questionTag)) {
         unset($tagNameArr);
         unset($tagName);
         unset($tagArr);
         foreach ($questionTag as $val) {
             unset($tagId);
             unset($tagName);
             $tagArr = explode(',', $val);
             $tagId = $tagArr[0];
             $tagName = $tagArr[1];
             $tagNameArr[] = $tagName;
             $questionTagModel = new QuestionTag();
             $questionTagModel->question_id = $questionModel->question_id;
             $questionTagModel->tag_id = $tagId;
             $questionTagModel->tag_name = $tagName;
             if ($questionTagModel->save()) {
                 $echo("添加成功!", true);
             }
         }
     } else {
         $echo("添加失败!");
         return;
     }
 }
Пример #6
0
 /**
  * 更新数据
  * @return ResponseResult
  */
 private function updateSave()
 {
     $req = $this->request;
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $id = intval($req->getPost('bp_id'));
     if ($id < 1) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     $name = $req->getPost('bp_name');
     $district = intval($req->getPost('bp_district', null, 0));
     $address = $req->getPost('bp_address');
     $coordinate = $req->getPost('bp_coordinate');
     $tel = $req->getPost('bp_tel');
     $isSell = intval($req->getPost('bp_is_sell', null, 0));
     $medalRefund = intval($req->getPost('bp_medal_refund', null, 0));
     $medalVerify = intval($req->getPost('bp_medal_verify', null, 0));
     $tags = $req->getPost('bp_tags');
     $ownerMobile = $req->getPost('bp_owner_mobile');
     $intro = $req->getPost('bp_intro');
     // 判断空数据
     if (empty($name) || $district <= 0 || empty($address) || empty($coordinate) || empty($tel) || empty($tags) || empty($intro) || empty($ownerMobile)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     // 保存封面
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->beautyParlorCover();
     if ($cover == false || !is_array($cover) || count($cover) == 0 || $cover[0] == false) {
         $bpCover = null;
     } else {
         $bpCover = $cover[0];
     }
     // 保存基础数据
     $coordinate = str_replace(',', ' ', $coordinate);
     $bp = BeautyParlor::findFirst('bp_id = ' . $id);
     $data = [];
     if ($bp->bp_name != $name) {
         $data['bp_name'] = $name;
     }
     if (!!$bpCover) {
         $data['bp_cover'] = $bpCover;
     }
     if ($bp->bp_address != $address) {
         $data['bp_address'] = $address;
     }
     if ($bp->bp_district != $district) {
         $data['bp_district'] = $district;
     }
     $data['bp_coordinate'] = new RawValue("GeomFromText('POINT({$coordinate})')");
     if ($bp->bp_tel != $tel) {
         $data['bp_tel'] = $tel;
     }
     if ($bp->bp_owner_mobile != $ownerMobile) {
         $data['bp_owner_mobile'] = $ownerMobile;
     }
     if ($bp->bp_intro != $intro) {
         $data['bp_intro'] = $intro;
     }
     if ($bp->bp_is_sell != $isSell) {
         $data['bp_is_sell'] = $isSell;
     }
     $data['bp_medal'] = strval($medalRefund) . strval($medalVerify);
     $bp->update($data);
     /*标签排序  */
     $tagsarr = explode(",", $tags);
     $status = BeautyParlorTag::find("bp_id = {$id}")->delete();
     if (!$status) {
         $response->sendError(ResponseResultStatus::PARAM_ERROR, '保存标签失败!');
     }
     foreach ($tagsarr as $k => $tag) {
         $taginfo = BeautyParlorTagInfo::find("tag_id = {$tag} and tag_state = 1")->toArray();
         $count = count($taginfo);
         if ($count < 1) {
             $response->sendError(ResponseResultStatus::PARAM_ERROR, '没有ID为' . $tag . '的标签!');
         }
         $tagDb = new BeautyParlorTag();
         $tagDb->bp_id = $id;
         $tagDb->tag_id = $tag;
         $tagDb->sort = $k + 1;
         if ($tagDb->save() == false) {
             $this->databaseErrorLog($tagDb);
         }
     }
     /* 
             $tagsArr = explode(',', $tags);
            	foreach($tagsArr as $tag) {
                 $tagDb = BeautyParlorTag::query()
                     ->columns('bp_tag_id, bp_id, tag_id')
                     ->where('bp_id = :bid: AND tag_id = :tid:')
                     ->bind(['bid'=>$id, 'tid'=>$tag])
                     ->execute()->getFirst();
                 if(!$tagDb) {
                     $tagDb = new BeautyParlorTag();
                     $tagDb->bp_id = $id;
                     $tagDb->tag_id = $tag;
                     if ($tagDb->save() == false) {
                         $this->databaseErrorLog($tagDb);
                     }
                 }
             } */
     // 获取所有的标签
     /* $tagList = BeautyParlorTag::query()
            ->where('bp_id = :bid:')
            ->bind(['bid'=>$id])
            ->execute();
        foreach($tagList as $t) {
            if(in_array(strval($t->tag_id), $tagsArr) == false) {
                $t->delete();
            }
        } */
     // 保存轮播图片
     // 轮播图片
     $pics = $uploadFile->beautyParlorPics();
     if ($pics) {
         foreach ($pics as $pic) {
             $picDb = new BeautyParlorPhotos();
             $picDb->beauty_parlor_id = $id;
             $picDb->photo_url = $pic;
             if ($picDb->save() == false) {
                 $this->databaseErrorLog($picDb);
             }
         }
     }
     SearchASync::Instance()->noticeSync($id, SearchDataType::BeautyParlors);
     $response->sendResult('ok');
     return $response;
 }
Пример #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;
 }
Пример #8
0
 /**
  * 设置成专家信息
  * @date: 2016-1-6 
  * @author: futao
  */
 public function setExpertinfoAction()
 {
     $req = $this->request;
     if (!$req->isPost()) {
         $userId = $req->getQuery('userid', null, 0);
         if (!$userId) {
             echo "用户不存在";
             return;
         }
         $tagList = BeautyParlorTagInfo::find("tag_state = 1 and parent_id !=0");
         $this->view->setVar("userId", $userId);
         $this->view->setVar("tagList", $tagList);
         $this->view->pick('user/setexpertinfo');
         return;
     }
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     //$response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!');
     /* $response->sendResult(1);
       	return $response; */
     $experience = $req->getPost("experience", null, '');
     //从业经验
     $userId = $req->getPost("userId", null, '');
     $field = $req->getPost("field", null, '');
     //擅长领域
     $experttitle = $req->getPost("experttitle", null, '');
     //专家头衔
     //验证数据
     if ($field == "" || !is_array($field)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '擅长领域必填!');
         return $response;
     }
     if ($userId == "") {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数错误!');
         return $response;
     }
     $userInfo = UserBase::findFirst($userId);
     if (!$userInfo) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数错误!');
         return $response;
     }
     $data = ['experience' => $experience, 'experttitle' => $experttitle, 'field' => $field];
     $datajson = json_encode($data);
     $userAttr = new UserAttribute();
     $userAttr->attr_value_json = $datajson;
     $userAttr->user_id = $userId;
     $userAttr->attr_type = 103;
     $userAttr->attr_state = 1;
     $userAttr->attr_key = time();
     $userAttrId = $userAttr->save();
     if (!$userAttrId) {
         $response->sendError(ResponseResultStatus::ERROR, '设置失败!');
         return $response;
     }
     $userInfo->user_expert = 1;
     if ($userInfo->save()) {
         $response->sendResult(1);
     } else {
         $response->sendError(ResponseResultStatus::ERROR, '设置失败!');
     }
     return $response;
 }
Пример #9
0
 /**
  * 预览美容院
  * @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);
 }
Пример #10
0
 public function updateAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $title = $req->getPost('title', null, null);
         if (empty($title)) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         // 查询是否存在了
         if ($this->getTagIsExist($title)) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_ERROR, '此标签名称已经存在!');
         }
         $info = BeautyParlorTagInfo::findFirst('tag_id=' . $id);
         if ($info) {
             $info->update(['tag_title' => $title]);
         }
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
Пример #11
0
 /**
  * 修改标签信息
  * @date: 2016年1月19日 
  * @author: futao
  */
 public function updateAction()
 {
     $req = $this->request;
     $echo = function ($msg, $state = false) {
         echo '<script type="text/javascript">';
         echo 'parent.formResult("' . $msg . '", ' . ($state ? 1 : 0) . ')';
         echo '</script>';
     };
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $title = $req->getPost('tag_name', null, null);
         $parent_id = intval($req->getPost('parent_id', null, 0));
         if ($id < 0 || $parent_id < 0) {
             $echo("请求异常");
         }
         if (empty($title)) {
             $echo("请求异常");
         }
         // 查询是否存在了
         if ($this->getTagIsExist($title)) {
             $echo("此标签名称已经存在!");
         }
         $info = BeautyParlorTagInfo::findFirst('tag_id=' . $id);
         if ($info) {
             $info->update(['tag_title' => $title, 'parent_id' => $parent_id]);
         }
         $echo("ok", true);
     } else {
         if ($req->getQuery('id')) {
             $id = intval($req->getQuery('id', null, 0));
             if ($id < 1) {
                 echo "error!";
                 return;
             }
             $info = BeautyParlorTagInfo::findFirst("tag_id = {$id} and tag_state = 1");
             if (!$info) {
                 $echo("标签不存在或被删除!");
                 return;
             }
             $list = BeautyParlorTagInfo::find("tag_state = 1 and parent_id = 0");
             $this->view->setVar('list', $list);
             $this->view->setVar('info', $info);
             $this->view->pick('bptag/edit');
         } else {
             $echo("请求异常");
         }
     }
 }