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

批量查询经纪人或者会员的信息

parent b96e20de
...@@ -105,12 +105,12 @@ class AppChat extends Basic ...@@ -105,12 +105,12 @@ class AppChat extends Basic
{ {
$params = $this->params; $params = $this->params;
if (!isset($params['only_id']) && !isset($params['phone']) || !isset($params['type'])) { if (!isset($params['only_id']) || !isset($params['phone']) || !isset($params['source'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误"); return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
} }
/* $params = array( /* $params = array(
"only_id" => "user_66", "only_id" => "user_72,agent_10",
"phone" => "13817616471", "phone" => "13112341234",
"source" => 2,// 1经纪人 or 2用户 "source" => 2,// 1经纪人 or 2用户
);*/ );*/
$only_id = isset($params['only_id']) ? $params['only_id'] : 0; $only_id = isset($params['only_id']) ? $params['only_id'] : 0;
...@@ -213,7 +213,7 @@ class AppChat extends Basic ...@@ -213,7 +213,7 @@ class AppChat extends Basic
$image = \think\Image::open($static_path); $image = \think\Image::open($static_path);
$image->thumb(500, 500)->save($static_path); //生成缩略图 $image->thumb(500, 500)->save($static_path); //生成缩略图
$data = [ 'file_name' => CHAT_IMG_URL . $img_path, 'name' => $img_path ]; $data = [ 'name' => $img_path ];
} else { } else {
// 上传失败获取错误信息 // 上传失败获取错误信息
return $this->response("101", $file->getError()); return $this->response("101", $file->getError());
......
...@@ -95,7 +95,7 @@ class ChatService ...@@ -95,7 +95,7 @@ class ChatService
$where_["id"] = $userId; $where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_); $agentsResult = $this->agentsModel->getAgentsById("id", $where_);
if ($agentsResult->id > 0) if ($agentsResult[0]['id'] > 0)
$onlyId = self::SOURCE_TYPE_AGENT . $userId; $onlyId = self::SOURCE_TYPE_AGENT . $userId;
break; break;
case 2: case 2:
...@@ -187,45 +187,66 @@ class ChatService ...@@ -187,45 +187,66 @@ class ChatService
*/ */
public function getUserInfo($only_id, $phone, $type) public function getUserInfo($only_id, $phone, $type)
{ {
$user_phone = $phone;
$user_phone = $agent_phone = [];
if ($only_id) { if ($only_id) {
$where_["only_id"] = $only_id; $only_id_arr = explode(",", $only_id);
$where_["only_id"] = array( "in", $only_id_arr );
$where_["status"] = 0; $where_["status"] = 0;
$field = "type,user_id,phone,only_id"; $field = "type,user_id,phone,only_id";
$chat_user = $this->chatUserModel->getChatUser($where_, $field); $chat_user = $this->chatUserModel->getChatUser($where_, $field);
if ($chat_user[0]["phone"]) { foreach ($chat_user as $v) {
$user_phone = $chat_user[0]["phone"]; if ($v["type"] == 1) {
array_push($agent_phone, $v["phone"]);
} else {
array_push($user_phone, $v["phone"]);
}
}
} else {
if ($type == 1) {
$agent_phone = [ $phone ];
} else if ($type == 2) {
$user_phone = [ $phone ];
} }
} }
$info = [];
switch ($type) {
case 1:
$field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic";
$where_agent["phone"] = $user_phone; $info_arr = [];
$where_agent["inuse"] = 1; if (count($agent_phone) > 0) {
$field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic";
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent); $where_agent["phone"] = array( "in", $agent_phone );
$where_agent["inuse"] = 1;
if ($agentsResult["user_pic"]) { $agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);
$agentsResult["user_pic"] = IMG_PATH . $agentsResult["user_pic"];
foreach ($agentsResult as $v) {
if ($v["user_pic"]) {
$v["user_pic"] = IMG_PATH . $v["user_pic"];
} }
$info = $agentsResult; array_push($info_arr, $v);
break; }
case 2:
$fields = "id,user_nick,user_phone,user_pic";
$param["status"] = 0; }
$param["user_phone"] = $user_phone;
$userResult = $this->userModel->getUserByWhere($param, $fields); if (count($user_phone) > 0) {
if ($userResult ["user_pic"]) { $fields = "id,user_nick,user_phone,user_pic";
$agentsResult["user_pic"] = HEADERIMGURL . $userResult["user_pic"];
$param["status"] = 0;
$param["user_phone"] = array( "in", $user_phone );
$userResult = $this->userModel->getUserByWhere($param, $fields);
foreach ($userResult as $v) {
if ($v["user_pic"]) {
$v["user_pic"] = HEADERIMGURL . $v["user_pic"];
} }
$info = $userResult; array_push($info_arr, $v);
break; }
} }
return $info; return $info_arr;
} }
......
...@@ -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 1516869338 rememberMe deleteMe a1.easemob.com FALSE / FALSE 1516874980 rememberMe deleteMe
...@@ -9,6 +9,12 @@ class Users extends Model ...@@ -9,6 +9,12 @@ class Users extends Model
{ {
// 设置当前模型对应的完整数据表名称 // 设置当前模型对应的完整数据表名称
protected $table = 'u_users'; protected $table = 'u_users';
protected $usersModel;
function __construct()
{
$this->usersModel = Db($this->table);
}
/** /**
* 查询用户 * 查询用户
...@@ -34,9 +40,10 @@ class Users extends Model ...@@ -34,9 +40,10 @@ class Users extends Model
} }
public function getUserByWhere($param, $fields = 'id,user_phone') public function getUserByWhere($param, $fields = 'id,user_phone')
{ {
$data = $this->field($fields) $data = $this->usersModel
->field($fields)
->where($param) ->where($param)
->find(); ->select();
return $data; return $data;
} /** } /**
* 查询用户和经纪人 * 查询用户和经纪人
......
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