Commit 0e0b0b6f authored by clone's avatar clone

获取用户信息

parent 8e62fd6d
...@@ -104,18 +104,30 @@ class AppChat extends Basic ...@@ -104,18 +104,30 @@ class AppChat extends Basic
return $this->response("200", "success", ""); return $this->response("200", "success", "");
} }
/**
* 获取经纪人或用户的信息
* @return \think\Response
*/
public function getUserOrAgentInfo() public function getUserOrAgentInfo()
{ {
$params = $this->params; $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, "请求参数错误"); return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
} }
$params = array( /* $params = array(
"id" => 1, "only_id" => "user_66",
"type" => 1,//1用户 or 2经纪人 "phone" => "13817616471",
); "source" => 2,// 1经纪人 or 2用户
$this->_chat->getUserInfo(); );*/
$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 ...@@ -91,7 +91,9 @@ class ChatService
$onlyId = ""; $onlyId = "";
switch ($source) { switch ($source) {
case 1: case 1:
$agentsResult = $this->agentsModel->getAgentsById("id", $userId); $where_["inuse"] = 1;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);
if (count($agentsResult) > 1) if (count($agentsResult) > 1)
$onlyId = self::SOURCE_TYPE_AGENT . $userId; $onlyId = self::SOURCE_TYPE_AGENT . $userId;
break; break;
...@@ -167,21 +169,54 @@ class ChatService ...@@ -167,21 +169,54 @@ class ChatService
//$this->insertPushLog($sender, $target, $msg_content, $status, $response['statusMsg']); //$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) { switch ($type) {
case 1: 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; break;
case 2: 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; break;
} }
return $info;
} }
/** /**
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
# http://curl.haxx.se/docs/http-cookies.html # http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk. # 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
...@@ -55,11 +55,11 @@ class Agents extends Model ...@@ -55,11 +55,11 @@ class Agents extends Model
public function agentsDetail($id) public function agentsDetail($id)
{ {
if ($id) { if ($id) {
$result = $this->field('id,realname,created,sub_shopname,head_portrait') $result = $this->field('id,realname,created,sub_shopname,head_portrait')
->where('level=2 or level=5') ->where('level=2 or level=5')
->where('id', $id)->find(); ->where('id', $id)->find();
$result['head_portrait'] = 'user_header/' . $result['head_portrait']; //头像 $result['head_portrait'] = 'user_header/' . $result['head_portrait']; //头像
$evaluate_grade = Db::table('u_evaluate') $evaluate_grade = Db::table('u_evaluate')
->field('sum(evaluate_grade) as evaluate_grade, count(*) as evaluate_num') ->field('sum(evaluate_grade) as evaluate_grade, count(*) as evaluate_num')
->where('agents_id', $id)->where('is_show', 0)->find(); ->where('agents_id', $id)->where('is_show', 0)->find();
...@@ -70,18 +70,18 @@ class Agents extends Model ...@@ -70,18 +70,18 @@ class Agents extends Model
} }
$result['evaluate_grade'] = $grade; //评分等级 $result['evaluate_grade'] = $grade; //评分等级
$result['evaluate_num'] = $evaluate_grade['evaluate_num']; //评论数量 $result['evaluate_num'] = $evaluate_grade['evaluate_num']; //评论数量
$result['watch_shop'] = Db::table('u_appoint_watch_shop') $result['watch_shop'] = Db::table('u_appoint_watch_shop')
->where('agents_id', $id)->count(); //看铺 ->where('agents_id', $id)->count(); //看铺
$result['head_portrait'] = ADMIN_URL_TL . $result['head_portrait']; $result['head_portrait'] = ADMIN_URL_TL . $result['head_portrait'];
$journal = new JournalAccounts(); $journal = new JournalAccounts();
$fields = 'count(j.id) as num'; $fields = 'count(j.id) as num';
$result['JournalAccounts'] = $journal->getJournalHouseInfoId($fields, $id)['num']; //成交记录 $result['JournalAccounts'] = $journal->getJournalHouseInfoId($fields, $id)['num']; //成交记录
$current_time = time(); $current_time = time();
$user_time = strtotime($result['created']); $user_time = strtotime($result['created']);
$year = date('Y', $current_time) - date('Y', $user_time); $year = date('Y', $current_time) - date('Y', $user_time);
//入职年限 //入职年限
if ($year == 0) { if ($year == 0) {
...@@ -91,7 +91,7 @@ class Agents extends Model ...@@ -91,7 +91,7 @@ class Agents extends Model
} }
$result['label'] = array( 0 => '待定标签数据', 1 => '待定标签数据' ); $result['label'] = array( 0 => '待定标签数据', 1 => '待定标签数据' );
$data = $result; $data = $result;
} else { } else {
$data = false; $data = false;
} }
...@@ -102,17 +102,19 @@ class Agents extends Model ...@@ -102,17 +102,19 @@ class Agents extends Model
/** /**
* 获取经纪人 by zw * 获取经纪人 by zw
* @param $field * @param $field
* @param $id * @param $where_
* @return array|false|\PDOStatement|string|Model * @return array|false|\PDOStatement|string|Model
*/ */
public function getAgentsById($field , $id) public function getAgentsById($field, $where_)
{ {
return $this $data = $this
->field($field) ->field($field)
->where('inuse = 1 and id = ' . $id) ->where($where_)
->find(); ->find();
return $data;
} }
/** /**
* 查询经纪人列表 * 查询经纪人列表
* *
......
...@@ -32,8 +32,13 @@ class Users extends Model ...@@ -32,8 +32,13 @@ class Users extends Model
} }
return $data; return $data;
} }
public function getUserByWhere($param, $fields = 'id,user_phone')
/** {
$data = $this->field($fields)
->where($param)
->find();
return $data;
} /**
* 查询用户和经纪人 * 查询用户和经纪人
* *
* @param int $pageNo * @param int $pageNo
......
...@@ -143,6 +143,7 @@ Route::group('chat', [ ...@@ -143,6 +143,7 @@ Route::group('chat', [
'userChat' => [ 'chat/AppChat/userChat', [ 'method' => 'post|get' ] ], 'userChat' => [ 'chat/AppChat/userChat', [ 'method' => 'post|get' ] ],
'pushMsg' => [ 'chat/AppChat/pushMsg', [ 'method' => 'post|get' ] ], 'pushMsg' => [ 'chat/AppChat/pushMsg', [ 'method' => 'post|get' ] ],
'getChatHistory' => [ 'chat/AppChat/getChatHistory', [ 'method' => 'post|get' ] ], 'getChatHistory' => [ 'chat/AppChat/getChatHistory', [ 'method' => 'post|get' ] ],
'getUserOrAgentInfo' => [ 'chat/AppChat/getUserOrAgentInfo', [ 'method' => 'post|get' ] ],
]); ]);
Route::group('task',[ Route::group('task',[
......
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