示例#1
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $questionId = intval($this->getDataItem('question_id', 0));
     $answer_id = intval($this->getDataItem('answer_id', 0));
     $content = Keyword::Filter($this->getDataItem('content', ''));
     $user_id = intval($this->getDataItem('user_id', 0));
     $to_user_id = intval($this->getDataItem('to_user_id', 0));
     if ($questionId == 0 || empty($content) || $user_id == 0 || $to_user_id == 0 || $user_id == $to_user_id) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '缺少参数或参数错误,请检查!');
     }
     if (mb_strlen($content) > 300) {
         return $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, '回复内容长度不能超过300字符');
     }
     // 身份检查
     if ($Question = Question::findFirst('question_id = ' . $questionId)) {
         $questionData = $Question->toArray();
     } else {
         $questionData = [];
     }
     $UserBase = new UserBase();
     if (!($questionData['user_id'] == $user_id || $UserBase->is_expert($user_id))) {
         return $this->errorLog(ResultStatus::QUERY_DATA_NOT_EXIST, '您没有权限评论!');
     }
     //关键字替换
     $keyword = CosQKeyword::query()->execute()->toArray();
     foreach ($keyword as $k => $v) {
         $content = str_replace($v['keyword'], '***', $content);
     }
     if (!$answer_id) {
         // 获取回复的id
         $QuestionAnswer = \Apps\Common\Models\QuestionAnswer::query()->where("question_id = {$questionId} and user_id = {$user_id}")->execute()->getFirst();
         $answer_id = $QuestionAnswer->answer_id ?: 0;
     }
     $up = new UploadPic();
     $data = ['question_id' => $questionId, 'answer_id' => $answer_id, 'content' => $content, 'pics' => json_encode($up->questionPic()), 'user_id' => $user_id, 'to_user_id' => $to_user_id, 'add_time' => date('Y-m-d H:i:s')];
     $QuestionAnswerComments = new QuestionAnswerComments();
     if ($QuestionAnswerComments->save($data)) {
         $this->setResult(['success' => 1, 'message' => '评论成功!']);
     } else {
         return $this->errorLog(ResultStatus::DATABASE_ERROR, '服务器异常!');
     }
 }
示例#2
0
 public function run()
 {
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $mobile = $this->getDataItem('mobile', '');
     //帐号
     $smsCode = $this->getDataItem('sms_code', '');
     //短信验证
     $password = $this->getDataItem('password', '');
     if (empty($mobile) || empty($smsCode) || empty($password)) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '缺少必传参数或者参数格式错误!');
     }
     if ($this->userInfoByAccount($mobile)) {
         $this->setResult(['success' => 100, 'message' => '手机号码已经使用过了.']);
         return false;
     }
     if (!MobileSMS::Check('update_mobile', $smsCode, $mobile, $this->apiAccessToken->id)) {
         $this->setResult(['success' => 101, 'message' => '短信验证码错误']);
         return false;
     }
     $UserBase = UserBase::findFirst('user_id = ' . $this->getUserAuth()->userId);
     if ($UserBase->user_account) {
         return $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, '已经绑定过的账号无法初始化账号信息!');
     }
     $UserBase->user_account = $mobile;
     $UserBase->bind_phone = $mobile;
     $UserBase->user_password = $this->hashPassword($password);
     if ($UserBase->save()) {
         $this->setResult(['success' => 1, 'message' => '绑定手机号码成功.']);
     } else {
         $this->setResult(['success' => 0, 'message' => '保存数据异常.']);
     }
 }
示例#3
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $area = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'user_mobile', 'persional_sign'];
     $fields = $this->getDataItem('fields');
     //字段
     $fields = explode(',', $fields);
     foreach ($fields as $f) {
         if (!in_array($f, $area)) {
             return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '字段名不存在.');
         }
     }
     $user = UserBase::find('user_id=' . $this->getUserAuth()->userId)->toArray();
     $user = $user[0];
     $fieldsArr = ['user_cover' => 'user_cover', 'user_nickname' => 'user_nickname', 'user_gender' => 'user_gender', 'user_birthday' => 'user_birthday', 'user_realname' => 'user_realname', 'user_district' => 'user_district', 'user_money' => 'user_money', 'user_money_virtual' => 'user_money_virtual', 'user_mobile' => 'user_account', 'persional_sign' => 'persional_sign'];
     $result = [];
     foreach ($fields as $field) {
         $key = $fieldsArr[$field];
         $value = $user[$key];
         if ($field == 'user_cover') {
             $value = PicUrl::UserCover($value, $this->getDi());
         }
         if ($field == 'persional_sign' && unserialize(base64_decode($value))) {
             $value = unserialize(base64_decode($value));
         }
         $result[$key] = $value;
     }
     $this->setResult($result);
 }
示例#4
0
 public function run()
 {
     /**
      * 验证用户权限,但不抛错
      */
     /*$this->verifyUserAuth(false);
      	$user_id = $this->getUserAuth()->userId;*/
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     if ($user_id > 0) {
         $list = UserBase::query()->columns(['Apps\\Common\\Models\\UserBase.user_id', 'user_nickname', 'user_cover', 'expert_follow_count', 'f.to_user_id', 'a.attr_value_json'])->leftJoin('Apps\\Common\\Models\\UserFollow', "Apps\\Common\\Models\\UserBase.user_id = f.to_user_id and f.user_id = {$user_id} and f.type = 2", 'f')->leftJoin('Apps\\Common\\Models\\UserAttribute', 'a.user_id = f.to_user_id and a.attr_type = 103 and a.attr_state = 1', 'a')->where('user_expert = 1 and user_state = 1')->orderBy('f.id DESC, expert_follow_count DESC')->limit($limit, $offset)->execute()->toArray();
     } else {
         $list = UserBase::query()->columns(['Apps\\Common\\Models\\UserBase.user_id', 'user_nickname', 'user_cover', 'expert_follow_count', 'a.attr_value_json'])->leftJoin('Apps\\Common\\Models\\UserAttribute', 'a.user_id = Apps\\Common\\Models\\UserBase.user_id and a.attr_type = 103 and a.attr_state = 1', 'a')->where('user_expert = 1 and user_state = 1')->orderBy('expert_follow_count DESC')->limit($limit, $offset)->execute()->toArray();
     }
     foreach ($list as $k => $val) {
         $list[$k]['user_cover'] = PicUrl::ActivityCover($val['user_cover'], $this->getDi());
         // 获取专家的扩展信息
         $info = $val['attr_value_json'] ? json_decode($val['attr_value_json']) : [];
         $list[$k]['experience'] = $info->experience ?: '0';
         // 从业经验
         $list[$k]['experttitle'] = $info->experttitle ?: '';
         // 擅长领域
         $list[$k]['field'] = $info->field ?: [];
         // 专家头衔(array)
         $list[$k]['is_follow'] = $val['to_user_id'] ? '1' : '0';
         unset($list[$k]['to_user_id'], $list[$k]['attr_value_json']);
     }
     $this->setResult($list);
 }
示例#5
0
 public function run()
 {
     $to_user_id = $this->getDataItem('user_id');
     if (!(is_numeric($to_user_id) && $to_user_id > 0)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '用户id不能为空.');
     }
     /**
      * 验证用户权限
      */
     /*if(!empty($this->parameters->userToken) && $this->verifyUserAuth() && $this->getUserAuth()->userId == $userid){
           return $this->errorLog(111, '请跳转我的问答.');
       }*/
     $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_expert'];
     $info = UserBase::query()->columns($field)->where('user_id=' . $to_user_id)->execute()->getFirst()->toArray();
     // 获取城市信息
     $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
     $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
     $info['user_district'] = $city['FULL_NAME'] ?: '';
     // 加入关注数和粉丝数
     $UserFollow = new UserFollow();
     $info['follow_count'] = $UserFollow->getFollowCount($to_user_id, 1);
     $info['fans_count'] = $UserFollow->getToFollowCount($to_user_id, 1);
     $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
     $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
     $this->verifyUserAuth(false);
     if ($user_id = $this->getUserAuth()->userId) {
         $info['is_follow'] = $UserFollow->is_follow($user_id, $to_user_id, 1) ? '1' : '0';
     } else {
         $info['is_follow'] = '0';
     }
     $this->setResult($info);
 }
示例#6
0
 public function run()
 {
     $type = $this->getDataItem('type', null);
     $number = $this->getDataItem('number', null);
     if (empty($type) || empty($number) || !preg_match("/^1\\d{10}/", $number)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '');
     }
     // 验证手机号码是否存在
     if (in_array($type, ['register', 'update_password', 'update_mobile'])) {
         $exist = UserBase::query()->where('user_account = :m:', ['m' => $number])->execute()->getFirst();
         if ($type == 'register' && $exist == true) {
             $this->setResult(['id' => 0, 'success' => 2, 'errmsg' => '手机号码已经注册过了!']);
             return false;
         }
         if ($type == 'update_password' && $exist == false) {
             $this->setResult(['id' => 0, 'success' => 3, 'errmsg' => '手机号码还未注册!']);
             return false;
         }
     }
     $id = MobileSMS::Send($type, $number, $this->apiAccessToken->id);
     if ($id === false) {
         $this->setResult(['id' => 0, 'success' => 0, 'errmsg' => '发送失败,请重试!']);
     } else {
         $this->setResult(['id' => $id, 'success' => 1, 'errmsg' => '']);
     }
 }
示例#7
0
 public function run()
 {
     if (!$this->verifyUserAuth()) {
         return false;
     }
     $id = intval($this->getDataItem('id', 0));
     $user_id = intval($this->getDataItem('user_id', 0));
     $content = $this->getDataItem('content', '');
     if ($id == 0 || $user_id == 0) {
         $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全');
         return false;
     }
     $contentLenth = $this->utf8_strlen($content);
     if ($contentLenth < 1 || $contentLenth > 100) {
         $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, '评论字符应在1~100之间.');
         return false;
     }
     $ActivityComment = new ActivityComment();
     $date = date('Y-m-d H:i:s');
     $data = ['comment_user_id' => $user_id, 'comment_content' => $content, 'addtime' => $date, 'activity_id' => $id];
     if ($ActivityComment->save($data)) {
         $ActivityComment->getReadConnection()->query("UPDATE activity SET comments = comments + 1 WHERE activity_id = {$id}");
         $userInfo = UserBase::getOne($user_id);
         $this->setResult(['comment_id' => $ActivityComment->comment_id, 'user_id' => $user_id, 'comment_content' => $content, 'addtime' => $date, 'user_gender' => $userInfo['user_gender'], 'user_cover' => PicUrl::ActivityCover($userInfo['user_cover'], $this->getDi())]);
     } else {
         $this->errorLog(ResultStatus::ERROR, '评论失败.');
     }
 }
示例#8
0
 /**
  * 验证用户账号和密码
  * @param string $account
  * @param string $password
  * @return bool
  */
 private function verifyAccount($account, $password)
 {
     //根据账号查询用户是否存在
     $this->userInfo = UserBase::query()->where('user_account=' . $account)->execute()->getFirst();
     if (!$this->userInfo) {
         //未注册
         $this->success = 2;
         $this->message = '账户未注册!';
         return false;
     }
     if ($this->userInfo) {
         //账户存在
         if ($this->userInfo->user_state != 1) {
             //账户已被停用
             $this->success = 3;
             $this->message = '账户已被停用,请联系管理员!';
             return false;
         } elseif ($this->userInfo->user_password != $this->hashPassword($password)) {
             //密码错误
             $this->success = 4;
             $this->message = '密码不正确!';
             return false;
         }
     }
     return true;
 }
 /**
  * 美容院评论列表
  * @date: 2016年1月19日 
  * @author: chenxiaolin
  */
 public function listAction()
 {
     $this->setLeftNav('comment_list');
     $req = $this->request;
     $id = intval($req->getQuery('id', null, 0));
     if ($id <= 0) {
         $this->view->disable();
         echo '美容院不存在!';
         return;
     }
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $user_name = $req->getQuery('user_name');
     $comment_addtime = $req->getQuery('comment_addtime');
     $timeSlotarr = explode("至", $comment_addtime);
     $where = [];
     if ($user_name != '') {
         $user = UserBase::query()->columns(['user_id'])->where("user_nickname like '%" . $user_name . "%'")->execute();
         foreach ($user as $k => $v) {
             $user_id .= $v['user_id'] . ',';
         }
         $user_id = rtrim($user_id, ",");
         if (!empty($user_id)) {
             $where[] = "Apps\\Common\\Models\\BeautyParlorComment.user_id in ( {$user_id} )";
         } else {
             $where[] = "Apps\\Common\\Models\\BeautyParlorComment.user_id in ( 0 )";
         }
         $this->view->setVar("user_name", $user_name);
     }
     if ($comment_addtime != '') {
         $where[] = "comment_addtime > '" . $timeSlotarr[0] . "'";
         $where[] = "comment_addtime < '" . $timeSlotarr[1] . "'";
         $this->view->setVar("comment_addtime", $comment_addtime);
     }
     $where[] = "beauty_parlor_id = {$id}";
     $whereStr = implode(' AND ', $where);
     $list = BeautyParlorComment::query()->columns(['comment_id', 'ub.user_id', 'ub.user_nickname', 'ub.user_cover', 'ub.user_gender', 'comment_info', 'comment_photos', 'comment_state', 'comment_addtime', 'comment_reply', 'comment_reply_addtime'])->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\BeautyParlorComment.user_id', 'ub')->where($whereStr)->limit($limit, $offset)->orderBy('comment_id DESC')->execute()->toArray();
     foreach ($list as $k => $v) {
         if (unserialize(base64_decode($v['comment_info']))) {
             $list[$k]['comment_info'] = unserialize(base64_decode($v['comment_info']));
         }
     }
     //$total = BeautyParlorComment::count('beauty_parlor_id = ' . $id);
     $total = BeautyParlorComment::count($whereStr);
     $this->view->setVar('commentList', $list);
     $this->view->setVar('total', $total);
     $this->view->setVar('page', $page);
     $this->view->setVar('limit', $limit);
     $this->view->setVar('id', $id);
 }
示例#10
0
 public function run()
 {
     $account = $this->getDataItem('account', 1);
     //帐号
     $password = $this->getDataItem('password', 1);
     //密码
     $nickname = Keyword::Filter($this->getDataItem('nickname', 1));
     //昵称
     $smsCode = $this->getDataItem('sms_code', '');
     //短信验证
     if ($this->userInfoByAccount($account)) {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => '账户名已存在']);
         return;
     }
     if (!MobileSMS::Check('register', $smsCode, $account, $this->apiAccessToken->id)) {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => '短信验证码错误']);
         return;
     }
     if (empty($password) || empty($nickname)) {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => '密码和昵称不能为空']);
         return;
     }
     $this->userInfo = new UserBase();
     $this->userInfo->user_account = $account;
     $this->userInfo->user_password = $this->hashPassword($password);
     $this->userInfo->user_nickname = $nickname;
     $this->userInfo->user_cover = $this->getConfig()->defaultCover;
     //'default.jpg';
     if ($this->userInfo->save()) {
         $this->success = 1;
         $this->message = '注册成功';
         $this->saveUserAuth($this->apiAccessToken->id, $this->userInfo->user_id);
         $this->userToken = $this->getUserAuth()->userToken;
     } else {
         $this->message = '注册失败';
         $this->databaseErrorLog($this->userInfo);
     }
     $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userInfo->user_id]);
 }
示例#11
0
 private function register($type, $attrType, $openId, $nickname, $cover, $otherData)
 {
     // 添加基础信息
     $base = new UserBase();
     $base->user_account = '';
     $base->user_password = '';
     $base->user_nickname = $nickname;
     /* if($cover!=''){
       	$base->user_cover = $this->getConfig()->defaultCover; //'default.png';
        } */
     //$config=$this->Config()->aliyun->oss;
     $img = file_get_contents($cover);
     file_put_contents('img/1.jpg', $img);
     $oss = new OSS('dUBfr1wNHjgMnJsd', '1U6ZSbOKhGBffxsopuMIKN6xCpSzUe', 'oss-cn-beijing.aliyuncs.com');
     $options = array();
     $object_name = time() . rand(10000, 99999);
     $file_path = "user-cover/" . date("Y/m/d") . "/" . $object_name . ".jpg";
     $response = $oss->upload_file_by_file('meelier', $file_path, 'img/1.jpg');
     unlink('img/1.jpg');
     $url = $response->header['_info']['url'];
     $url = str_replace("http://oss-cn-beijing.aliyuncs.com/meelier/", "", $url);
     $base->user_cover = $url;
     // $base->user_cover=$this->getConfig()->defaultCover;
     if (!$base->save()) {
         $this->databaseErrorLog($base);
         return false;
     }
     $userId = $base->user_id;
     // 保存第三方登录信息
     $attr = new UserAttribute();
     $attr->user_id = $userId;
     $attr->attr_type = 100;
     $attr->attr_key = $type;
     $attr->attr_value_json = $openId;
     if (!$attr->save()) {
         $this->databaseErrorLog($attr);
         return false;
     }
     $attr2 = new UserAttribute();
     $attr2->user_id = $userId;
     $attr2->attr_type = $attrType;
     $attr2->attr_key = $openId;
     $attr2->attr_value_json = $otherData;
     if (!$attr2->save()) {
         $this->databaseErrorLog($attr2);
         return false;
     }
     return $userId;
 }
 /**
  * 问答详情
  * @date: 2016-1-16 
  * @author: futao
  */
 public function infoAction()
 {
     $this->setLeftNav("info");
     $req = $this->request;
     $questionId = intval($req->getQuery('id', null, 0));
     if ($questionId < 0) {
         echo "参数错误!";
         return;
     }
     $questionColumns = ['ub.user_id', 'ub.user_nickname', 'ub.user_cover', 'Apps\\Common\\Models\\Question.user_id', 'Apps\\Common\\Models\\Question.question_content', 'Apps\\Common\\Models\\Question.question_pics', 'Apps\\Common\\Models\\Question.question_addtime', 'Apps\\Common\\Models\\Question.question_browsers', 'Apps\\Common\\Models\\Question.question_id'];
     $info = Question::query()->columns($questionColumns)->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\Question.user_id', 'ub')->where("Apps\\Common\\Models\\Question.question_id = {$questionId} and Apps\\Common\\Models\\Question.question_state = 1")->execute()->getFirst();
     if (!$info) {
         echo "问题不存在!";
         exit;
     }
     $info->user_cover = PicUrl::UserCover($info->user_cover, $this->di);
     if (unserialize(base64_decode($info->question_content))) {
         $info->question_content = unserialize(base64_decode($info->question_content));
     }
     if (json_decode($info->question_pics)) {
         $info->question_pics = json_decode($info->question_pics);
     }
     $answerColumns = ['ub.user_nickname', 'ub.user_cover', 'Apps\\Common\\Models\\QuestionAnswer.answer_content', 'Apps\\Common\\Models\\QuestionAnswer.answer_addtime', 'Apps\\Common\\Models\\QuestionAnswer.answer_id', 'Apps\\Common\\Models\\QuestionAnswer.original_content', 'Apps\\Common\\Models\\QuestionAnswer.answer_pics', 'Apps\\Common\\Models\\QuestionAnswer.type', 'Apps\\Common\\Models\\QuestionAnswer.user_id'];
     $answerList = QuestionAnswer::query()->columns($answerColumns)->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\QuestionAnswer.user_id', 'ub')->where("Apps\\Common\\Models\\QuestionAnswer.question_id = {$questionId} and Apps\\Common\\Models\\QuestionAnswer.answer_state = 1")->orderBy("Apps\\Common\\Models\\QuestionAnswer.answer_floor asc")->execute()->toArray();
     foreach ($answerList as $k => $val) {
         if (unserialize(base64_decode($answerList[$k]['answer_content']))) {
             $answerList[$k]['answer_content'] = unserialize(base64_decode($answerList[$k]['answer_content']));
         }
         if (unserialize(base64_decode($answerList[$k]['original_content']))) {
             $answerList[$k]['original_content'] = unserialize(base64_decode($answerList[$k]['original_content']));
         }
         if (json_decode($answerList[$k]['answer_pics'])) {
             $answerList[$k]['answer_pics'] = json_decode($answerList[$k]['answer_pics']);
         }
         if ($answerList[$k]['type'] == 1) {
             $answerList[$k]['reply'] = QuestionAnswerComments::query()->columns(['ub.user_nickname', 'ub.user_cover', 'ub.user_id', 'content', 'add_time', 'id'])->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\QuestionAnswerComments.user_id', 'ub')->where("question_id = {$questionId} and answer_id = " . $answerList[$k]['answer_id'] . " and to_user_id = " . $answerList[$k]['user_id'])->orderBy("id desc")->execute()->toArray();
         }
         $answerList[$k]['user_cover'] = PicUrl::UserCover($answerList[$k]['user_cover'], $this->di);
     }
     $userList = UserBase::find("is_manage = 1");
     $seeList = QuestionViewsUser::query()->columns(['distinct ub.user_id', 'ub.user_cover'])->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\QuestionViewsUser.user_id', 'ub')->where("question_id = {$questionId}")->orderBy("id desc")->limit(7)->execute();
     $this->view->setVar('seelist', $seeList);
     $this->view->setVar('comment_count', QuestionAnswer::count('answer_state = 1 and question_id = ' . $questionId));
     $this->view->setVar('question_id', $questionId);
     $this->view->setVar('userlist', $userList);
     $this->view->setVar('questioninfo', $info);
     $this->view->setVar('answerlist', $answerList);
     $this->view->pick('question/info');
 }
示例#13
0
 public function run()
 {
     // 验证用户权限
     if (!$this->verifyUserAuth()) {
         return false;
     }
     $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_id', 'user_expert'];
     $info = UserBase::query()->columns($field)->where('user_id=' . $this->getUserAuth()->userId)->execute()->getFirst()->toArray();
     // 获取城市信息
     $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
     $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
     $info['user_district'] = $city['FULL_NAME'] ?: '';
     $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
     $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
     // 加入关注数和粉丝数
     $UserFollow = new UserFollow();
     $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1);
     $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1);
     $this->setResult($info);
 }
示例#14
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return;
     }
     $area = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'persional_sign'];
     $field = $this->getDataItem('field');
     //字段
     $value = Keyword::Filter($this->getDataItem('value', ''));
     //值
     if ($field == "persional_sign") {
         if ($this->count_string_len($value) > 40) {
             return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '个性签名字数超过了40个字符');
         } else {
             $value = base64_encode(serialize($value));
         }
     }
     if (!in_array($field, $area)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '字段名不存在.');
     }
     $fieldsArr = ['user_cover' => 'user_cover', 'user_nickname' => 'user_nickname', 'user_gender' => 'user_gender', 'user_birthday' => 'user_birthday', 'user_realname' => 'user_realname', 'persional_sign' => 'persional_sign', 'user_district' => 'user_district', 'user_money' => 'user_money', 'user_money_virtual' => 'user_money_virtual', 'user_mobile' => 'user_account'];
     $user = UserBase::findFirst('user_id=' . $this->getUserAuth()->userId);
     $f = $fieldsArr[$field];
     if ($field == 'user_cover') {
         $up = new UploadPic();
         $value = $up->userCover();
         if ($value == false) {
             return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '文件流不能为空.');
         }
     }
     $user->{$f} = $value;
     if ($user->save()) {
         $this->success = 1;
         $this->message = $field . ' 更新成功';
     }
     $this->setResult(['success' => $this->success, 'message' => $this->message]);
 }
示例#15
0
 public function run()
 {
     $mobile = $this->getDataItem('mobile');
     $password = $this->getDataItem('password');
     $smsCode = $this->getDataItem('sms_code');
     if (empty($mobile) || empty($password) || empty($smsCode)) {
         if (!$this->userInfoByAccount($mobile)) {
             $this->setResult(['success' => 0, 'message' => '手机号码不存在.']);
             return;
         }
     }
     if (!MobileSMS::Check('update_password', $smsCode, $mobile, $this->apiAccessToken->id)) {
         $this->setResult(['success' => 0, 'message' => '短信验证码错误.']);
         return;
     }
     $newPassword = $this->hashPassword($password);
     if (UserBase::SetPassword($mobile, $newPassword)) {
         $this->setResult(['success' => 1, 'message' => '']);
     } else {
         $this->setResult(['success' => 0, 'message' => '保存数据异常.']);
     }
 }
示例#16
0
 public function run()
 {
     $user_id = intval($this->getDataItem('user_id', 0));
     $expert_id = intval($this->getDataItem('expert_id', 0));
     //		$expert_id = 289;
     if ($expert_id < 1) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '缺少必传参数!');
     }
     $columns = ['user_id', 'user_nickname', 'user_cover', 'expert_follow_count', 'persional_sign'];
     if ($UserBase = UserBase::query()->columns($columns)->where('user_expert = 1 and user_id = ' . $expert_id)->execute()->getFirst()) {
         $info = $UserBase->toArray();
         $info['user_cover'] = PicUrl::ActivityCover($info['user_cover'], $this->getDi());
         if ($userAttribute = UserAttribute::findFirst('attr_type = 103 and attr_state = 1 and user_id = ' . $expert_id)) {
             $attr_value_json = $userAttribute->attr_value_json;
         } else {
             $attr_value_json = [];
         }
         $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
         $attr_value_json = $attr_value_json ? json_decode($attr_value_json) : [];
         $info['experience'] = $attr_value_json->experience ?: '';
         // 从业经验
         $info['experttitle'] = $attr_value_json->experttitle ?: '';
         // 擅长领域
         $info['field'] = $attr_value_json->field ?: [];
         // 专家头衔(array)
         if ($user_id > 0) {
             $info['is_follow'] = (new UserFollow())->is_follow($user_id, $expert_id, 2) ? '1' : '0';
         } else {
             $info['is_follow'] = '0';
         }
         // 回答问题数
         $result = (new UserBase())->getReadConnection()->query("SELECT count(*) c FROM\r\n(SELECT count(*) FROM question_answer WHERE answer_state = 1 AND user_id = {$expert_id} GROUP BY question_id) a;");
         $count = $result->fetch();
         $info['question_count'] = $count['c'];
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '用户不存在或不是专家');
     }
     $this->setResult($info);
 }
示例#17
0
 public function run()
 {
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     //		$user_id = 12;
     $where = 'user_expert = 1 and user_state = 1';
     if ($user_id > 0) {
         // 用户关注的专家列表
         $followExpert = UserFollow::query()->where("user_id = {$user_id} and type = 2")->execute()->toArray();
         $expert = '';
         foreach ($followExpert as $val) {
             $expert .= $val['to_user_id'] . ',';
         }
         if ($expert && ($expert = trim($expert, ','))) {
             $where = "user_expert = 1 and user_state = 1 and user_id not in({$expert})";
         }
     }
     $list = UserBase::query()->columns(['user_id', 'user_nickname', 'user_cover', 'expert_follow_count'])->where($where)->orderBy('expert_follow_count DESC')->limit($limit, $offset)->execute()->toArray();
     foreach ($list as $k => $val) {
         $list[$k]['user_cover'] = PicUrl::ActivityCover($val['user_cover'], $this->getDi());
         // 获取专家的扩展信息
         if ($userAttribute = UserAttribute::findFirst('attr_type = 103 and attr_state = 1 and user_id = ' . $val['user_id'])) {
             $attr_value_json = $userAttribute->attr_value_json;
         } else {
             $attr_value_json = [];
         }
         $info = $attr_value_json ? json_decode($attr_value_json) : [];
         $list[$k]['experience'] = $info->experience ?: '0';
         // 从业经验
         $list[$k]['experttitle'] = $info->experttitle ?: '';
         // 擅长领域
         $list[$k]['field'] = $info->field ?: '';
         // 专家头衔(array)
     }
     $this->setResult($list);
 }
示例#18
0
 public function run()
 {
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $mobile = $this->getDataItem('mobile', '');
     //帐号
     $smsCode = $this->getDataItem('sms_code', '');
     //短信验证
     if ($this->userInfoByAccount($mobile)) {
         $this->setResult(['success' => $this->success, 'message' => '手机号码已经使用过了.']);
         return false;
     }
     if (!MobileSMS::Check('update_mobile', $smsCode, $mobile, $this->apiAccessToken->id)) {
         $this->setResult(['success' => $this->success, 'message' => '短信验证码错误']);
         return false;
     }
     // 修改用户手机号码
     if (UserBase::SetMobile($this->getUserAuth()->userId, $mobile)) {
         $this->setResult(['success' => 1, 'message' => '绑定手机号码成功.']);
     } else {
         $this->setResult(['success' => 0, 'message' => '保存数据异常.']);
     }
 }
示例#19
0
 public function push()
 {
     if ($this->param['type'] === null || $this->param['ispushservice'] === null || $this->param['phone'] === null || $this->param['content'] === null || $this->param['shop_id'] === null) {
         return $this->returnResult($this->DATAERROR, '数据错误!');
     }
     if (strlen($this->param['phone']) != 11) {
         return $this->returnResult($this->DATAERROR, '数据错误!');
     }
     if ($this->param['phone'] == '') {
         return $this->returnResult($this->DATAERROR, '数据错误!');
     }
     $userinfo = UserBase::findFirst("user_account = " . $this->param['phone']);
     if (!$userinfo) {
         return $this->returnResult($this->DATAERROR, '数据错误!');
     }
     $user_id = $userinfo->user_id;
     $usermessage = new UserMessage();
     $usermessage->user_id = $user_id;
     if ($this->param['ispushservice'] == 1) {
         $usermessage->is_read_b = 0;
     } else {
         $usermessage->is_read_b = 1;
     }
     $usermessage->message_content = $this->param['content'];
     $usermessage->push_type = $this->param['type'];
     $usermessage->message_state = 1;
     $usermessage->shop_id = $this->param['shop_id'];
     $usermessage->from_user_name = 1;
     $usermessage->from_user_cover = 1;
     $this->db->begin();
     $message_status = $usermessage->save();
     //添加数据到user_message
     if (!$message_status) {
         $this->db->rollback();
         return $this->returnResult($this->MYSQLERROR, "数据库错误");
     }
     /*推送至APP代码*/
     $config = $this->di->get('appConfig')->jpush;
     $app_key = $config->app_key;
     $master_secret = $config->master_secret;
     JPushLog::setLogHandlers([new StreamHandler('jpush.log', Logger::DEBUG)]);
     $client = new JPushClient($app_key, $master_secret);
     //easy push
     try {
         $result = $client->push()->setPlatform(M\all)->setAudience(M\alias([$user_id]))->setNotification(M\notification($this->param['content']))->setOptions(M\options(null, null, null, true, null))->send();
         if ($result->isOk === true) {
             $this->db->commit();
             return $this->returnResult($this->SUCCESS, "推送成功!");
         } else {
             $this->db->rollback();
             return $this->returnResult($this->PUSHFAIL, "推送失败!");
         }
     } catch (APIRequestException $e) {
         /* echo 'Push Fail.' . '<br>';
          		 echo 'Http Code : ' . $e->httpCode . '<br>';
          		echo 'code : ' . $e->code . '<br>';
          		echo 'message : ' . $e->message . '<br>';
          		echo 'Response JSON : ' . $e->json . '<br>';
          		echo 'rateLimitLimit : ' . $e->rateLimitLimit . '<br>';
          		echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . '<br>';
          		echo 'rateLimitReset : ' . $e->rateLimitReset . '<br>';
          		exit; */
         $this->db->rollback();
         return $this->returnResult($this->PUSHFAIL, "推送失败!");
     } catch (APIConnectionException $e) {
         $this->db->rollback();
         return $this->returnResult($this->PUSHFAIL, "推送失败!");
     }
     /*the end*/
 }
示例#20
0
 public function run()
 {
     $account = $this->getDataItem('account', 1);
     //帐号
     $password = $this->getDataItem('password', 1);
     //密码
     $nickname = Keyword::Filter($this->getDataItem('nickname', 1));
     //昵称
     $smsCode = $this->getDataItem('sms_code', '');
     //短信验证
     if ($this->userInfoByAccount($account)) {
         $this->setResult(['success' => 101, 'user_token' => $this->userToken, 'message' => '账户名已存在']);
         return;
     }
     if (empty($password) || empty($nickname)) {
         $this->setResult(['success' => 103, 'user_token' => $this->userToken, 'message' => '密码和昵称不能为空']);
         return;
     }
     if (empty($smsCode)) {
         $this->setResult(['success' => 102, 'user_token' => $this->userToken, 'message' => '短信验证码必填']);
         return;
     }
     if (!MobileSMS::Check('register', $smsCode, $account, $this->apiAccessToken->id)) {
         $this->setResult(['success' => 102, 'user_token' => $this->userToken, 'message' => '短信验证码错误']);
         return;
     }
     $this->userInfo = new UserBase();
     $this->userInfo->user_account = $account;
     $this->userInfo->user_password = $this->hashPassword($password);
     $this->userInfo->user_nickname = $nickname;
     $this->userInfo->user_cover = $this->getConfig()->defaultCover;
     //'default.jpg';
     $this->userInfo->bind_phone = $account;
     if ($this->userInfo->save()) {
         $this->success = 1;
         $this->message = '注册成功';
         $this->saveUserAuth($this->apiAccessToken->id, $this->userInfo->user_id);
         $this->userToken = $this->getUserAuth()->userToken;
     } else {
         $this->message = '注册失败';
         $this->databaseErrorLog($this->userInfo);
     }
     if ($this->success == 1) {
         if ($model = UserBase::findFirst('user_id = ' . $this->userInfo->user_id)) {
             $info = $model->toArray();
         } else {
             $info = [];
         }
         $info['user_mobile'] = $info['bind_phone'];
         $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
         // 获取城市信息
         $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
         $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
         $info['user_district'] = $city['FULL_NAME'] ?: '';
         // 删除不要的字段
         unset($info['user_account'], $info['user_password'], $info['user_state'], $info['user_addtime'], $info['is_manage']);
         $this->setResult(array_merge($info, ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message]));
     } else {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userInfo->user_id]);
     }
 }
示例#21
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;
     }
 }
示例#22
0
 public function run()
 {
     $questionId = intval($this->getDataItem('question_id', 0));
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     //        $questionId = 194;
     if ($questionId < 1) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '参数不完整或者参数错误!');
     }
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $QuestionAnswer = new QuestionAnswer();
     $expertReplyList = $QuestionAnswer->query()->columns(['u.user_id', 'u.user_cover', 'u.user_nickname', 'answer_id', 'answer_content', 'support_count', 'answer_addtime', 'answer_pics', 'a.attr_value_json'])->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\QuestionAnswer.user_id', 'u')->leftJoin('\\Apps\\Common\\Models\\UserAttribute', 'a.user_id = \\Apps\\Common\\Models\\QuestionAnswer.user_id', 'a')->where("a.attr_type = 103 and a.attr_state = 1 and answer_state = 1 and type = 2 and question_id = {$questionId}")->orderBy('answer_addtime DESC')->limit($limit, $offset)->execute()->toArray();
     $QuestionAnswerComments = new QuestionAnswerComments();
     $UserBase = new UserBase();
     $QuestionAnswerFollow = new QuestionAnswerFollow();
     foreach ($expertReplyList as $k => $val) {
         if ($val['attr_value_json']) {
             $objAttrValueJoin = json_decode($val['attr_value_json']);
             $expertReplyList[$k]['experttitle'] = $objAttrValueJoin->experttitle;
             $expertReplyList[$k]['field'] = $objAttrValueJoin->field ?: [];
         } else {
             $expertReplyList[$k]['experttitle'] = [];
             $expertReplyList[$k]['field'] = [];
         }
         $expertReplyList[$k]['user_cover'] = PicUrl::UserCover($val['user_cover'], $this->getDi());
         $expertReplyList[$k]['answer_content'] = unserialize(base64_decode($val['answer_content'])) ?: $val['answer_content'];
         if ($user_id > 0) {
             $expertReplyList[$k]['is_support'] = $QuestionAnswerFollow->is_support($user_id, $val['answer_id']) ? '1' : '0';
         } else {
             $expertReplyList[$k]['is_support'] = '0';
         }
         $answer_pics = [];
         if ($answer_pics_list = json_decode($val['answer_pics'], true)) {
             foreach ($answer_pics_list as $value) {
                 $answer_pics[] = PicUrl::Question($value, $this->getDi());
             }
         }
         $expertReplyList[$k]['answer_pics'] = $answer_pics;
         unset($expertReplyList[$k]['attr_value_json']);
         if ($item = $QuestionAnswerComments->query()->where('answer_id = ' . $val['answer_id'])->limit(10, 0)->execute()->toArray()) {
             foreach ($item as $key => $v) {
                 $user_info = $UserBase->getOne($v['user_id']);
                 $to_user_info = $UserBase->getOne($v['to_user_id']);
                 $item[$key]['user_info'] = ['user_id' => $v['user_id'], 'user_nickname' => $user_info['user_nickname']];
                 $item[$key]['to_user_info'] = ['user_id' => $v['to_user_id'], 'user_nickname' => $to_user_info['user_nickname']];
                 $pics = [];
                 if ($pics_list = json_decode($v['pics'], true)) {
                     foreach ($pics_list as $values) {
                         $pics[] = PicUrl::Question($values, $this->getDi());
                     }
                 }
                 $item[$key]['pics'] = $pics;
                 unset($item[$key]['user_id'], $item[$key]['to_user_id']);
             }
             $expertReplyList[$k]['item'] = $item;
         } else {
             $expertReplyList[$k]['item'] = [];
         }
     }
     $this->setResult($expertReplyList);
 }
示例#23
0
 /**
  * 验证用户账号和密码
  * @param string $account
  * @param string $password
  * @return bool
  */
 private function verifyAccount($account, $password)
 {
     //根据账号查询用户是否存在
     if ($model = UserBase::query()->where("user_account='{$account}'")->execute()->getFirst()) {
         $this->userInfo = $model->toArray();
     }
     if ($this->userInfo) {
         //账户存在
         if ($this->userInfo['user_state'] != 1) {
             //账户已被停用
             $this->success = 3;
             $this->userInfo = [];
             $this->message = '账户已被停用,请联系管理员!';
             return false;
         } elseif ($this->userInfo['user_password'] != $this->hashPassword($password)) {
             //密码错误
             $this->success = 4;
             $this->userInfo = [];
             $this->message = '密码不正确!';
             return false;
         }
     } else {
         //未注册
         $this->success = 2;
         $this->message = '账户未注册!';
         return false;
     }
     return true;
 }
示例#24
0
 /**
  * 添加关联1.0
  */
 public function questionUserAddAction()
 {
     $req = $this->request;
     if (!$req->isPost()) {
         $this->view->setVar('opList', BackendOperator::find('operator_group = 2'));
         return;
     }
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $opId = intval($req->getPost('op_id', null, 0));
     $userId = intval($req->getPost('user_id', null, 0));
     if ($opId < 1 || $userId < 1) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!');
         return $response;
     }
     // 操作员是否存在
     if (BackendOperator::count('operator_id = ' . $opId) == 0) {
         $response->sendError(ResponseResultStatus::BUSINESS, '操作员不存在!');
         return $response;
     }
     // 用户是否存在
     if (UserBase::count('user_id = ' . $userId) == 0) {
         $response->sendError(ResponseResultStatus::BUSINESS, '用户不存在!');
         return $response;
     }
     $info = new OmQuestionAnswerUser();
     $info->op_id = $opId;
     $info->user_id = $userId;
     if ($info->save() == false) {
         $this->databaseErrorLog($info);
         $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常!');
     } else {
         $response->sendResult($info->qau_id);
     }
     return $response;
 }
示例#25
0
 /**
  * 修改密码
  * @return $this|ResponseResult
  */
 public function setPasswdAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $pwd = $req->getPost('pwd');
         if (empty($pwd)) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = UserBase::findFirst('user_id=' . $id);
         if ($info) {
             $info->update(['user_password' => UserCommon::hashPassword($pwd, $this->di)]);
         }
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
示例#26
0
 /**
  * 查看活动回复列表
  * @date: 2016年1月5日 
  * @author: chenxiaolin
  */
 public function commentListAction()
 {
     $this->setLeftNav('commentList');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $activity_id = $req->getQuery('id');
     $user_name = $req->getQuery('user_name');
     $comment_content = $req->getQuery('comment_content');
     $addtime = $req->getQuery('addtime');
     $timeSlotarr = explode("至", $addtime);
     $columns = ['comment_id', 'comment_content', 'addtime', 'user.user_nickname as user_name'];
     $where = [];
     $bind = [];
     $medal = [];
     //通过用户名筛选数据
     if ($user_name != '') {
         $user = UserBase::query()->columns(['user_id'])->where("user_nickname like '%" . $user_name . "%'")->execute();
         foreach ($user as $k => $v) {
             $user_id .= $v['user_id'] . ',';
         }
         $user_id = rtrim($user_id, ",");
         if (!empty($user_id)) {
             $where[] = "comment_user_id in ( {$user_id} )";
         } else {
             $where[] = "comment_user_id in ( 0 )";
         }
         $this->view->setVar("user_name", $user_name);
     }
     //通过评论内容筛选数据
     if ($comment_content != '') {
         $where[] = "comment_content like '%" . $comment_content . "%'";
         $this->view->setVar("comment_content", $comment_content);
     }
     //通过评论时间筛选数据
     if ($addtime) {
         $where[] = "addtime > '" . $timeSlotarr[0] . "'";
         $where[] = "addtime < '" . $timeSlotarr[1] . "'";
         $this->view->setVar("addtime", $addtime);
     }
     $where[] = "activity_id = {$activity_id} and state = 1";
     $whereStr = implode(' AND ', $where);
     $query = ActivityComment::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\UserBase', 'user.user_id=Apps\\Common\\Models\\ActivityComment.comment_user_id', 'user');
     if (!empty($whereStr)) {
         $query = $query->where($whereStr);
     }
     if (count($bind) > 0) {
         $query = $query->bind($bind);
     }
     $data = $query->orderBy('addtime DESC')->limit($limit, $offset)->execute();
     /* var_dump($data);
        exit;
         */
     // 总数
     $total = ActivityComment::count(['conditions' => $whereStr, 'bind' => $bind]);
     $this->view->setVar('total', $total);
     $this->view->setVar('page', $page);
     $this->view->setVar('limit', $limit);
     $this->view->setVar('data', $data);
     $this->view->setVar('activity_id', $activity_id);
 }
示例#27
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $area = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'persional_sign'];
     $field = $this->getDataItem('field');
     //字段
     $value = trim($this->getDataItem('value', ''));
     //值
     if (!in_array($field, $area)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '字段名不存在.');
     }
     if ($user = UserBase::findFirst('user_id=' . $this->getUserAuth()->userId)) {
         if ($field == 'user_cover') {
             $up = new UploadPic();
             $user->user_cover = $up->userCover();
             if (!$user->user_cover) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '文件流不能为空.');
             }
             $value = PicUrl::UserCover($user->user_cover, $this->getDi());
         } elseif ($field == 'user_district') {
             if (!is_numeric($value)) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '城市格式错误.');
             }
             if (!\Apps\Common\Models\SysAreaZipDistrictPhonecode::count('K_ID = ' . $value)) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '城市不存在.');
             }
             $user->user_district = $value;
             // 获取城市信息
             $city = (new SysAreaZipDistrictPhonecode())->getOne($value);
             $value = $city['FULL_NAME'] ?: '';
         } elseif ($field == 'persional_sign') {
             if ($value && $this->utf8_strlen($value) > 30) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '个性签名字数超过了30个字符');
             } else {
                 $user->persional_sign = $value ? base64_encode(serialize($value)) : '';
             }
         } elseif ($field == 'user_nickname') {
             $nicknameLength = $this->utf8_strlen($value);
             if ($nicknameLength < 1 || $nicknameLength > 10) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '昵称长度需在1~10字节之间');
             }
             $user->user_nickname = $value;
         } elseif ($field == 'user_realname') {
             if (empty($value)) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '姓名不能为空');
             }
             if ($this->utf8_strlen($value) > 10) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '姓名不能超过10个字符');
             }
             $user->user_realname = $value;
         } elseif ($field == 'user_gender') {
             if (!in_array($value, ['0', '1', '2'])) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '请输入正确的性别');
             }
             $user->user_gender = $value;
         } elseif ($field == 'user_birthday') {
             if (!$this->validateDate($value)) {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '日期格式错误');
             }
             $user->user_birthday = $value;
         }
         if ($user->save()) {
             $this->setResult(['success' => 1, 'message' => $field . ' 更新成功', 'value' => $value]);
             return true;
         }
     }
     $this->setResult(['success' => 0, 'message' => '更新失败', 'value' => '']);
 }
示例#28
0
 /**
  * 通过用户账号获取用户信息
  * @param $account
  * @return UserBase
  */
 public function userInfoByAccount($account)
 {
     //return UserBase::findFirst("user_account='".$account."'");
     return UserBase::findFirst(['conditions' => 'user_account = :account:', 'bind' => ['account' => $account]]);
 }
示例#29
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;
 }