Commit 12addacd authored by clone's avatar clone

return id

parent 31906b5a
...@@ -202,7 +202,7 @@ class ChatService ...@@ -202,7 +202,7 @@ class ChatService
// 判断是否创建关系没有则保存 // 判断是否创建关系没有则保存
$this->verifyRelation($target, $from); $this->verifyRelation($target, $from);
$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();
// 消息接收人必须是数组 // 消息接收人必须是数组
...@@ -336,6 +336,7 @@ class ChatService ...@@ -336,6 +336,7 @@ class ChatService
* @param $type * @param $type
* @param $msg_content * @param $msg_content
* @param $from * @param $from
* @return int|string
*/ */
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)
{ {
...@@ -359,7 +360,7 @@ class ChatService ...@@ -359,7 +360,7 @@ class ChatService
if ($target_type != "users") { if ($target_type != "users") {
$group_id = $from; $group_id = $from;
} }
$this->insetMsgExt($id, $type, $msg_content, $params["is_group"], $group_id); return $this->insetMsgExt($id, $type, $msg_content, $params["is_group"], $group_id);
} }
} }
...@@ -477,6 +478,7 @@ class ChatService ...@@ -477,6 +478,7 @@ class ChatService
return $result; return $result;
} }
/** /**
* 记录消息body * 记录消息body
* @param $id * @param $id
...@@ -484,6 +486,7 @@ class ChatService ...@@ -484,6 +486,7 @@ class ChatService
* @param $msg_content * @param $msg_content
* @param $is_group * @param $is_group
* @param $group_id * @param $group_id
* @return int|string
*/ */
private function insetMsgExt($id, $type, $msg_content, $is_group, $group_id) private function insetMsgExt($id, $type, $msg_content, $is_group, $group_id)
{ {
...@@ -496,7 +499,7 @@ class ChatService ...@@ -496,7 +499,7 @@ class ChatService
$param["updated_at"] = date("Y-m-d H:i:s", time()); $param["updated_at"] = date("Y-m-d H:i:s", time());
$msgExtModel = new ChatMsgExt(); $msgExtModel = new ChatMsgExt();
$msgExtModel->addChatMsgExt($param); return $msgExtModel->addChatMsgExt($param);
} }
......
...@@ -27,10 +27,10 @@ class ChatMsgExt extends Model ...@@ -27,10 +27,10 @@ class ChatMsgExt extends Model
{ {
Db::startTrans(); Db::startTrans();
try { try {
$this->db->insert($params); $id = $this->db->insertGetId($params);
Db::commit(); Db::commit();
return $id;
} catch (\Exception $e) { } catch (\Exception $e) {
dump($e);
Db::rollback(); Db::rollback();
} }
......
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