Commit c45db7df authored by clone's avatar clone

bug

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