Exemplo n.º 1
0
 /**
  * 获取智囊图列表
  * @param int $mem_id 用户id
  * @param string $mem_mark 单点标识
  * @param int $page_id 分页页码
  * @param int $limit 每页条数
  * @return int|array
  */
 public function getSageList($mem_id, $mem_mark, $page_id = 1, $limit = 20)
 {
     //单点查询
     $member_exists = $this->singleMember($mem_id, $mem_mark);
     if ($member_exists != OK) {
         return $member_exists;
     }
     //查询智囊
     $sql = 'select mem_id,mem_head,mem_nickname,mem_answers,mem_fine
             from member
             where mem_is_sage=1 and mem_status=1
             order by mem_fine desc,mem_answers desc';
     $list = $this->pagination($sql, [], 'mem_id', $page_id, $limit);
     //处理数据
     $mem_ides = '';
     $data = [];
     if ($list['list']) {
         foreach ($list['list'] as $key => $val) {
             //智囊头像
             $val['mem_head'] = Func::setImg($val['mem_head']);
             //反转义数据
             $val['mem_nickname'] = Func::unescape($val['mem_nickname']);
             //用智囊id当数据键
             $val['tags'] = [];
             $data[$val['mem_id']] = $val;
             //提取提问id
             $tmp = $key == 0 ? '' : ',';
             $mem_ides .= "{$tmp}{$val['mem_id']}";
         }
         //查询智囊标签
         $sql = "select p1.mem_id,p2.tag_name from tag_adept p1 inner join tag p2 on p1.tag_id=p2.tag_id where p1.mem_id in ({$mem_ides})";
         $tags = $this->fetchAll($sql);
         if ($tags) {
             foreach ($tags as $val) {
                 if (isset($data[$val['mem_id']])) {
                     $data[$val['mem_id']]['tags'][] = $val['tag_name'];
                 }
             }
         }
     }
     $list['list'] = $data;
     return $list;
 }
Exemplo n.º 2
0
 /**
  * 手机验证码登陆
  * @param string $pho_phone 手机号
  * @param int $pho_code 验证码
  * @param int $login_system 操作系统
  * @param string $login_number 手机序列号
  * @param string $mem_client_id 推送key
  * @return int|array
  */
 public function codeLogin($pho_phone, $pho_code, $login_system, $login_number, $mem_client_id)
 {
     //手机验证码验证
     $phone_status = $this->verifyPhoneCode($pho_phone, $pho_code);
     if ($phone_status != OK) {
         return $phone_status;
     }
     //查询用户信息
     $sql = 'select mem_id,mem_status,mem_online,mem_mark,mem_password,mem_nickname,mem_head,mem_sex,
                    mem_is_sage,mem_questions,mem_answers,mem_fine,mem_gold,mem_on_system,mem_on_user
             from member where mem_phone=?';
     $member = $this->fetchOne($sql, [$pho_phone]);
     //判断手机是否注册
     if (!$member) {
         return NOT_FOUND_USER;
     }
     //账号状态
     if ($member['mem_status'] != 1) {
         return USER_AUTHORITY_ERROR;
     }
     //添加登陆信息
     $login_status = $this->addLoginLog($member, $login_system, $login_number, $mem_client_id);
     if ($login_status != OK) {
         return $login_status;
     }
     return ['mem_id' => $member['mem_id'], 'mem_mark' => $member['mem_mark'], 'mem_nickname' => $member['mem_account'], 'mem_head' => Func::setImg($member['mem_head']), 'mem_is_sage' => $member['mem_is_sage'], 'mem_sex' => $member['mem_is_sage'], 'mem_questions' => $member['mem_questions'], 'mem_answers' => $member['mem_answers'], 'mem_fine' => $member['mem_fine'], 'mem_gold' => $member['mem_gold'], 'mem_on_system' => $member['mem_on_system'], 'mem_on_user' => $member['mem_on_user']];
 }
Exemplo n.º 3
0
 /**
  * 设置头像
  */
 public function setHeadAction()
 {
     $vars = ['mem_id', 'mem_head', 'mem_mark', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //生成图片
     $this->data['mem_head'] = \Func::touchImg($this->data['mem_head'], 'head');
     if (!$this->data['mem_head']) {
         $this->throwMessage(ILLEGAL_IMAGE);
     }
     //修改头像
     $field = ['mem_id', 'mem_mark', 'mem_head'];
     $upd_status = $this->callModelFunc('Member', 'updMemHead', $field);
     if ($upd_status != OK) {
         $this->throwMessage($upd_status);
     }
     $this->throwMessage(OK, ['mem_head' => \Func::setImg($this->data['mem_head'])]);
 }
Exemplo n.º 4
0
 /**
  * 获取提问列表
  * @param int $que_id 提问id
  * @return mixed 失败返回int,成功返回array
  */
 public function getQuestionInfo($que_id)
 {
     //查询数据
     $sql = "select p1.que_id,p1.mem_id,p1.que_content,p1.que_img,p1.que_reward,p1.que_answers,p1.que_addtime,\n                       p2.mem_head,p2.mem_nickname,p2.mem_rong_id\n                from question p1\n                inner join member p2 on p1.mem_id=p2.mem_id\n                where p1.que_is_hidden=1 and p1.que_status=2 and p2.mem_status=1 and p1.que_id=?";
     $question = $this->fetchOne($sql, [$que_id]);
     if (!$question) {
         return NOT_FOUND_DATA;
     }
     //查询标签
     $question['tags'] = [];
     $sql = 'select p2.tag_name from question_tag p1 inner join tag p2 on p1.tag_id=p2.tag_id where p1.que_id=?';
     $tags = $this->fetchAll($sql, [$que_id]);
     if ($tags) {
         foreach ($tags as $val) {
             $question['tags'][] = $val['tag_name'];
         }
     }
     //处理数据
     $question['mem_head'] = Func::setImg($question['mem_head']);
     $question['mem_nickname'] = Func::unescape($question['mem_nickname']);
     $question['que_content'] = Func::unescape($question['que_content']);
     $question['que_img'] = json_decode($question['que_img'], true);
     if ($question['que_img']) {
         foreach ($question['que_img'] as $key => $val) {
             $question['que_img'][$key] = Func::setImg($val);
         }
     }
     return $question;
 }
Exemplo n.º 5
0
 /**
  * 修改昵称
  * @param int $mem_id 用户id
  * @param string $mem_mark 单点标识
  * @param string $mem_nickname 性别
  * @return int
  */
 public function updMemNickname($mem_id, $mem_mark, $mem_nickname)
 {
     //获取用户融云id,头像
     $member = $this->getMemRongYunRelate($mem_id);
     $status = Chat::getInstance()->userRefresh($member['mem_rong_id'], $mem_nickname, Func::setImg($member['mem_head']));
     if ($status != OK) {
         return $status;
     }
     return $this->updMemOneFieldBasic($mem_id, $mem_mark, 'mem_nickname', $mem_nickname);
 }