Commit 35999362 authored by clone's avatar clone Committed by hujun

获取用户信息

parent 2ee0bb29
......@@ -107,18 +107,30 @@ class AppChat extends Basic
return $this->response("200", "success", "");
}
/**
* 获取经纪人或用户的信息
* @return \think\Response
*/
public function getUserOrAgentInfo()
{
$params = $this->params;
if (!isset($params['id']) || !isset($params['type'])) {
if (!isset($params['only_id']) && !isset($params['phone']) || !isset($params['type'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
$params = array(
"id" => 1,
"type" => 1,//1用户 or 2经纪人
);
$this->_chat->getUserInfo();
/* $params = array(
"only_id" => "user_66",
"phone" => "13817616471",
"source" => 2,// 1经纪人 or 2用户
);*/
$only_id = isset($params['only_id']) ? $params['only_id'] : 0;
$phone = isset($params['phone']) ? $params['phone'] : 0;
$result = $this->_chat->getUserInfo($only_id, $phone, $params["source"]);
if ($result) {
return $this->response("200", "request success", $result);
}
return $this->response("101", "request error ,not fund list", []);
}
......
......@@ -91,7 +91,9 @@ class ChatService
$onlyId = "";
switch ($source) {
case 1:
$agentsResult = $this->agentsModel->getAgentsById("id", $userId);
$where_["inuse"] = 1;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);
if (count($agentsResult) > 1)
$onlyId = self::SOURCE_TYPE_AGENT . $userId;
break;
......@@ -175,21 +177,54 @@ class ChatService
$this->insertPushLog($sender, $target, $msg_content, $status, $response['statusMsg']);*/
}
public function getUserInfo($id, $type)
/**
* 根据手机号或者onlyId获取用户信息
* @param $only_id
* @param $phone
* @param $type
* @return array|false|\PDOStatement|string|\think\Model
*/
public function getUserInfo($only_id, $phone, $type)
{
$user_phone = $phone;
if ($only_id) {
$where_["only_id"] = $only_id;
$where_["status"] = 0;
$field = "type,user_id,phone,only_id";
$chat_user = $this->chatUserModel->getChatUser($where_, $field);
if ($chat_user[0]["phone"]) {
$user_phone = $chat_user[0]["phone"];
}
}
$info = [];
switch ($type) {
case 1:
$field = "id,";
$field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic";
$where_agent["phone"] = $user_phone;
$where_agent["inuse"] = 1;
$agentsResult = $this->agentsModel->getAgentsById($field, $id);
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);
if ($agentsResult["user_pic"]) {
$agentsResult["user_pic"] = IMG_PATH . $agentsResult["user_pic"];
}
$info = $agentsResult;
break;
case 2:
$userResult = $this->userModel->selectUser($id);
$fields = "id,user_nick,user_phone,user_pic";
$param["status"] = 0;
$param["user_phone"] = $user_phone;
$userResult = $this->userModel->getUserByWhere($param, $fields);
if ($userResult ["user_pic"]) {
$agentsResult["user_pic"] = HEADERIMGURL . $userResult["user_pic"];
}
$info = $userResult;
break;
}
return $info;
}
/**
......
......@@ -2,4 +2,4 @@
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 1516762819 rememberMe deleteMe
a1.easemob.com FALSE / FALSE 1516852769 rememberMe deleteMe
......@@ -115,8 +115,10 @@ class Agents extends Model
->field($field)
->where('inuse = 1 and id = ' . $id)
->find();
return $data;
}
/**
* 查询经纪人列表
*
......
......@@ -32,8 +32,13 @@ class Users extends Model
}
return $data;
}
/**
public function getUserByWhere($param, $fields = 'id,user_phone')
{
$data = $this->field($fields)
->where($param)
->find();
return $data;
} /**
* 查询用户和经纪人
*
* @param int $pageNo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment