Esempio n. 1
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;
     }
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 /**
  * 列表
  */
 public function listAction()
 {
     $this->setLeftNav('tag_list');
     $list = BeautyParlorTagInfo::find();
     $this->view->setVar('data', $list);
 }
Esempio n. 4
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;
 }
Esempio n. 5
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("请求异常");
         }
     }
 }