| | |
| | | //添加信息 |
| | | public function add($postdata,$user) |
| | | { |
| | | // 验证:不能给自己发消息 |
| | | if (!isset($postdata['you_user_id']) || $postdata['you_user_id'] == $user['user_id']) { |
| | | $this->error = '不能给自己发消息'; |
| | | return false; |
| | | } |
| | | |
| | | // 开启事务 |
| | | $this->startTrans(); |
| | | try { |
| | | |
| | | |
| | | $ChatRelation = new ChatRelation(); |
| | | |
| | | |
| | | $info = $ChatRelation->where('user_id', '=', $user['user_id'])->where('other_user_id', '=', $postdata['you_user_id'])->find(); |
| | | if(empty($info)){ |
| | | $info = $ChatRelation->where('user_id', '=', $postdata['you_user_id'])->where('other_user_id', '=', $user['user_id'])->find(); |