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

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

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