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

创建聊天关系

parent 3f164814
...@@ -300,11 +300,10 @@ class ChatService ...@@ -300,11 +300,10 @@ class ChatService
$params["from"] = $from; $params["from"] = $from;
$relationResult = $chatRelationModel->getChatRelation($params); $relationResult = $chatRelationModel->getChatRelation($params);
if (count($relationResult) > 0) { if (count($relationResult) == 0) {
//表示关系已经建立 //如果没有记录则记录聊天关系
$chatRelationModel->addChatRelation($params);
} }
//getChatRelation
} }
/** /**
......
...@@ -55,13 +55,23 @@ class ChatRelation extends Model ...@@ -55,13 +55,23 @@ class ChatRelation extends Model
public function addChatRelation($params) public function addChatRelation($params)
{ {
$where_ = [];
if (isset($params["target"])) {
$where_["to_id"] = $params["target"];
}
if (isset($params["from"])) {
$where_["from_id"] = $params["from"];
}
$where_["create_time"] = date("Y-m-d H:i:s",time());
$where_["update_time"] = date("Y-m-d H:i:s",time());
Db::startTrans(); Db::startTrans();
try { try {
$this->insert($params); $this->insert($where_);
Db::commit(); Db::commit();
} catch (\Exception $e) { } catch (\Exception $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