示例#1
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' => '']);
     }
 }
示例#2
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;
 }
示例#3
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);
 }
示例#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);
 }
 /**
  * 美容院评论列表
  * @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);
 }
示例#6
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);
 }
示例#7
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);
 }
示例#8
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);
 }
示例#9
0
 /**
  * 用户列表
  */
 public function listAction()
 {
     $this->setLeftNav('list');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $columns = ['user_id', 'user_account', 'user_nickname', 'user_cover', 'user_gender', 'user_expert', 'user_birthday', 'user_realname', 'user_district', 'FULL_NAME district', 'user_state', 'user_addtime', 'persional_sign'];
     $filterName = $req->getQuery('filterName', null, '');
     $filterMobile = $req->getQuery('filterMobile', null, '');
     $filterState = intval($req->getQuery('filterState', null, -10000));
     $filterGender = intval($req->getQuery('filterGender', null, -10000));
     $filterExpert = intval($req->getQuery('filterExpert', null, -10000));
     $filterProvince = $req->getQuery('filterProvince', null, '');
     $filterCity = $req->getQuery('filterCity', null, '');
     $filterDistrict = intval($req->getQuery('filterDistrict', null, -10000));
     $where = [];
     $bind = [];
     if (!!$filterName) {
         $where[] = 'user_nickname LIKE :fname:';
         $bind['fname'] = '%' . $filterName . '%';
     }
     if (!!$filterMobile) {
         $where[] = 'user_account = :mobile:';
         $bind['mobile'] = $filterMobile;
     }
     if ($filterState > -10000) {
         $where[] = 'user_state = :state:';
         $bind['state'] = $filterState;
     }
     if ($filterGender > -10000) {
         $where[] = 'user_gender = :gender:';
         $bind['gender'] = $filterGender;
     }
     if ($filterExpert > -10000) {
         $where[] = 'user_expert = :expert:';
         $bind['expert'] = $filterExpert;
     }
     // 地区
     $districts = [];
     if ($filterDistrict > -10000) {
         $where[] = 'user_district = :district:';
         $bind['district'] = $filterDistrict;
     } elseif (!empty($filterCity)) {
         // 获取所有城市的下级区县值
         $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :province: AND C_NM = :city:', ['province' => $filterProvince, 'city' => $filterCity])->execute();
         foreach ($dids as $d) {
             $districts[] = $d->id;
         }
     } elseif (!empty($filterProvince)) {
         // 获取所有城市的下级区县值
         $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :p:', ['p' => $filterProvince])->execute();
         foreach ($dids as $d) {
             $districts[] = $d->id;
         }
     }
     if (count($districts) > 0) {
         $where[] = 'user_district IN(' . implode(', ', $districts) . ')';
     }
     $whereStr = count($where) > 0 ? implode(' AND ', $where) : '';
     $query = UserBase::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'K_ID=user_district', 'area');
     if (count($where) > 0) {
         $query = $query->where($whereStr);
     }
     if (count($bind) > 0) {
         $query = $query->bind($bind);
     }
     $data = $query->orderBy('user_id DESC')->limit($limit, $offset)->execute();
     $total = UserBase::count(['conditions' => $whereStr, 'bind' => $bind]);
     $this->view->setVars(['filterName' => $filterName, 'filterMobile' => $filterMobile, 'filterState' => $filterState, 'filterGender' => $filterGender, 'filterExpert' => $filterExpert, 'filterProvince' => $filterProvince, 'filterCity' => $filterCity, 'filterDistrict' => $filterDistrict]);
     $this->view->setVars(['page' => $page, 'limit' => $limit, 'total' => $total]);
     $this->view->setVar('data', $data);
 }
示例#10
0
 public function run()
 {
     $type = $this->getDataItem('type');
     $openId = $this->getDataItem('openid');
     $nickname = $this->getDataItem('nickname');
     $cover = $this->getDataItem('cover');
     $otherData = $this->getDataItem('other_data');
     $pushId = $this->getDataItem('push_id');
     // push id
     $osType = $this->getDataItem('os_type');
     // 验证数据完整性
     if (empty($type) || empty($openId) || empty($nickname)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "业务参数不全.");
     }
     if (!in_array($type, ['weixin', 'weibo'])) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "类型不支持.");
     }
     $attrType = 101;
     if ($type == 'weibo') {
         $attrType = 102;
     }
     // 判断用户是否已经注册了
     $userId = $this->isRegister($attrType, $openId);
     if ($userId === false) {
         // 注册新账号
         $userId = $this->register($type, $attrType, $openId, $nickname, $cover, $otherData);
         if ($userId === false) {
             return;
         }
     }
     $info = [];
     // 获取 user token
     if ($this->saveUserAuth($this->apiAccessToken->id, $userId)) {
         $this->success = 1;
         $this->userid = $userId;
         $this->message = '登录成功!';
         $this->userToken = $this->getUserAuth()->userToken;
         $this->saveUserPushId($userId, $pushId, $osType);
         if ($model = UserBase::query()->where("user_id = {$userId}")->execute()->getFirst()) {
             $info = $model->toArray();
             $info['user_mobile'] = $info['bind_phone'] ?: $info['user_account'];
             if ($info['user_cover'] == 'default.png' && $attrType == 101) {
                 $info['user_cover'] = json_decode($otherData)->headimgurl;
             } else {
                 $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'])) : '';
             // 获取城市信息
             $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
             $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
             $info['user_district'] = $city['FULL_NAME'] ?: '';
             // 加入关注数和粉丝数
             $UserFollow = new UserFollow();
             $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1);
             $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1);
             // 删除不要的字段
             unset($info['user_account'], $info['user_password'], $info['user_state'], $info['user_addtime'], $info['is_manage']);
         }
     } else {
         $this->message = '获取User Token异常!';
     }
     if (!$info) {
         $info = ["user_id" => "", "user_nickname" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0];
     }
     $info = array_merge($info, ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userid]);
     $this->setResult($info);
 }
示例#11
0
 /**
  * 编辑用户信息
  * @date: 2016-1-5 
  * @author: futao
  */
 public function editAction()
 {
     $this->setLeftNav("update");
     $req = $this->request;
     $id = $req->getQuery("id", null, 0);
     $action = $req->getQuery("action", null, '');
     $info = UserBase::query()->columns(['user_account', 'user_password', 'user_district', 'user_nickname', 'user_realname', 'bind_phone', 'persional_sign', 'user_birthday', 'user_cover', 'user_gender', 'user_expert'])->where("user_id = :id:")->bind(['id' => $id])->execute()->getFirst();
     if (!$info) {
         $this->view->disable();
         echo '用户不存在!';
         return;
     }
     if ($info->user_expert == 1) {
         $userAttr = UserAttribute::findFirst('user_id =' . $id . ' and attr_type = 103 and attr_state = 1');
         $this->view->setVar('user_attr', json_decode($userAttr->attr_value_json));
     }
     //个性签名解码
     if (unserialize(base64_decode($info->persional_sign))) {
         $info->persional_sign = unserialize(base64_decode($info->persional_sign));
     }
     $info->user_cover = PicUrl::UserCover($info->user_cover, $this->di);
     $userArea = SysAreaZipDistrictPhonecode::findFirst("K_ID = " . $info->user_district);
     $this->view->setVar('userArea', $userArea);
     $this->view->setVar('userInfo', $info);
     $this->view->setVar('userId', $id);
     $this->view->setVar('action', $action);
 }
示例#12
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);
 }
示例#13
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;
 }