Commit c45db7df authored by clone's avatar clone

bug

parent 0f89df04
...@@ -205,27 +205,29 @@ class ChatService ...@@ -205,27 +205,29 @@ class ChatService
$msg_id = $this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from); $msg_id = $this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from);
$rPush = new RPush(); $rPush = new RPush();
// 消息接收人必须是数组
$userExt = new ChatUserExt(); $userExt = new ChatUserExt();
$where['only_id'] = $target; $where['only_id'] = $target;
$m_user = new ChatUser();
$user_where['only_id'] = $from;
$user_where['only_id_or'] = $target;
$user_where['status'] = 0;
$user_arr = $m_user->getChatUserOne('user_id', $user_where);
//0用户 1经纪人 if (count($user_arr) < 2) {
if (strstr($target,'user')) {
$where['type'] = 2; //对用户发
} elseif (strstr($target,'agent')) {
$where['type'] = 1; //对经纪人发
} else {
return false; return false;
} }
$user_id = 0;
$m_user = new ChatUser(); $where['type'] = 1;
$user_where['only_id'] = $from; foreach ($user_arr as $item) {
$user_where['status'] = 0; if ($item["only_id"] == $from) {
$user_arr = $m_user->getChatUserOne('user_id', $user_where); $user_id = empty($user_arr['user_id']) ? 0 : $user_arr['user_id'];
$user_id = empty($user_arr['user_id']) ? 0:$user_arr['user_id'] ; } else {
$where['type'] = $item["type"];
}
}
$info = $userExt->getChatUserExtByUserId($where, 'a.id,a.ext_id,a.device_id,a.push_id,b.user_id'); $info = $userExt->getChatUserExtByUserId($where, 'a.id,a.ext_id,a.device_id,a.push_id,b.user_id');
if (count($info) <= 0) { if (count($info) <= 0) {
...@@ -248,13 +250,13 @@ class ChatService ...@@ -248,13 +250,13 @@ class ChatService
*/ */
public function saveSendStatus($response, $target, $from, $msg_content) public function saveSendStatus($response, $target, $from, $msg_content)
{ {
try{ try {
//目前没有针对多人聊天 //目前没有针对多人聊天
$status = $response["code"]; $status = $response["code"];
$this->insertPushLog($from, $target, $msg_content, $status, $response["msg"]); $this->insertPushLog($from, $target, $msg_content, $status, $response["msg"]);
}catch (Exception $exception){ } catch (Exception $exception) {
//todo 暂不处理 //todo 暂不处理
} }
} }
...@@ -350,8 +352,7 @@ class ChatService ...@@ -350,8 +352,7 @@ class ChatService
*/ */
private function insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from) private function insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from)
{ {
//todo $params["msg_type"] = 1;
$params["msg_type"] = 1; //目前只用到了环信的文本消息
$params["to_id"] = $target; $params["to_id"] = $target;
$params["from_id"] = $from; $params["from_id"] = $from;
$params["is_group"] = $target_type == "users" ? 0 : 1; $params["is_group"] = $target_type == "users" ? 0 : 1;
......
...@@ -62,9 +62,17 @@ class ChatUser extends Model ...@@ -62,9 +62,17 @@ class ChatUser extends Model
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getChatUserOne($field, $params) { public function getChatUserOne($field, $params) {
$where_ = $whereOr_ = [];
if(isset($params["only_id"])){
$where_["only_id"] = $params["only_id"];
}
if(isset($params["only_id_or"])){
$whereOr_["only_id"] = $params["only_id_or"];
}
$data = $this->db->field($field) $data = $this->db->field($field)
->where($params) ->where($params)
->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