Commit 3f164814 authored by clone's avatar clone Committed by hujun

聊天关系建立

parent d17ba1bc
...@@ -157,8 +157,10 @@ class AppChat extends Basic ...@@ -157,8 +157,10 @@ class AppChat extends Basic
} }
$result = $this->_chat->sendMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from, $this->accessToken); $result = $this->_chat->sendMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from, $this->accessToken);
if (count($result) > 0) { if ($result) {
return $this->response("200", "", [ "msg" => "消息发送成功" ]); return $this->response("200", "", [ "msg" => "消息发送成功" ]);
}else{
return $this->response("101", "", [ "msg" => "消息内容错误" ]);
} }
...@@ -231,47 +233,47 @@ class AppChat extends Basic ...@@ -231,47 +233,47 @@ class AppChat extends Basic
$params = $this->params; $params = $this->params;
//$params['id']=312; //$params['id']=312;
if (!isset($params['id'])) { if (!isset($params['id'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']); return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
} }
$id = $params['id']; $id = $params['id'];
$HouseInfos=new HouseInfos(); $HouseInfos = new HouseInfos();
$HouseInfosre = $HouseInfos->getHousepusmessage($id); $HouseInfosre = $HouseInfos->getHousepusmessage($id);
//dump($HouseInfosre); //dump($HouseInfosre);
if($HouseInfosre){ if ($HouseInfosre) {
$data['title']=$HouseInfosre[0]['title']; $data['title'] = $HouseInfosre[0]['title'];
//dump($HouseInfosre[0]['room_area']); //dump($HouseInfosre[0]['room_area']);
//dump($HouseInfosre[0]['room_area2']); //dump($HouseInfosre[0]['room_area2']);
$room_area =$HouseInfosre[0]['room_area']? $HouseInfosre[0]['room_area']:''; $room_area = $HouseInfosre[0]['room_area'] ? $HouseInfosre[0]['room_area'] : '';
$room_area2 = $HouseInfosre[0]['room_area2']?'-'.$HouseInfosre[0]['room_area2']:''; $room_area2 = $HouseInfosre[0]['room_area2'] ? '-' . $HouseInfosre[0]['room_area2'] : '';
$data['room_area_all']='暂无!'; $data['room_area_all'] = '暂无!';
if ($room_area || $room_area2) { if ($room_area || $room_area2) {
$data['room_area_all']=$room_area.$room_area2.'m²'; $data['room_area_all'] = $room_area . $room_area2 . 'm²';
} }
$data['price']='暂无!'; $data['price'] = '暂无!';
if($HouseInfosre[0]['rent_type']){ if ($HouseInfosre[0]['rent_type']) {
//rent_type COMMENT '1.月租金 2.营业额扣点 3.每平方米租金', //rent_type COMMENT '1.月租金 2.营业额扣点 3.每平方米租金',
$message[1]='月租金:'.$HouseInfosre[0]['price'].'元/月'; $message[1] = '月租金:' . $HouseInfosre[0]['price'] . '元/月';
$message[2]='营业额扣点:'.$HouseInfosre[0]['price'].'%'; $message[2] = '营业额扣点:' . $HouseInfosre[0]['price'] . '%';
$message[3]='每平方米租金:'.$HouseInfosre[0]['price'].'元/天/㎡'; $message[3] = '每平方米租金:' . $HouseInfosre[0]['price'] . '元/天/㎡';
$data['price']=$message[$HouseInfosre[0]['rent_type']]; $data['price'] = $message[$HouseInfosre[0]['rent_type']];
} }
//同联默认图片,如果用户没上传的话/img/houseinfobackgroundimg.png //同联默认图片,如果用户没上传的话/img/houseinfobackgroundimg.png
$data['imagename'] = $homeurl. '/img/houseinfobackgroundimg_new.png'; $data['imagename'] = $homeurl . '/img/houseinfobackgroundimg_new.png';
$HouseImgs=new HouseImgs(); $HouseImgs = new HouseImgs();
$HouseImgsre = $HouseImgs->getHouseImgs($id,1); $HouseImgsre = $HouseImgs->getHouseImgs($id, 1);
//用户上传了就用上传的 //用户上传了就用上传的
if($HouseImgsre){ if ($HouseImgsre) {
$data['imagename']=$homeurl. '/houseImg/small_' . $HouseImgsre[0]['imagename']; $data['imagename'] = $homeurl . '/houseImg/small_' . $HouseImgsre[0]['imagename'];
} }
// dump($HouseInfosre); // dump($HouseInfosre);
// dump($data); // dump($data);
// exit; // exit;
return $this->response("200", "success!",$data); return $this->response("200", "success!", $data);
}else{ } else {
return $this->response("400", "暂无数据!"); return $this->response("400", "暂无数据!");
} }
......
...@@ -96,7 +96,7 @@ class ChatService ...@@ -96,7 +96,7 @@ class ChatService
$where_["inuse"] = 1; $where_["inuse"] = 1;
$where_["id"] = $userId; $where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_); $agentsResult = $this->agentsModel->getAgentsById("id", $where_);
if ( count($agentsResult) > 0 && $agentsResult[0]['id'] > 0) if (count($agentsResult) > 0 && $agentsResult[0]['id'] > 0)
$onlyId = self::SOURCE_TYPE_AGENT . $userId; $onlyId = self::SOURCE_TYPE_AGENT . $userId;
break; break;
case 2: case 2:
...@@ -293,10 +293,17 @@ class ChatService ...@@ -293,10 +293,17 @@ class ChatService
* @param $target * @param $target
* @param $from * @param $from
*/ */
private function verifyRelation($target, $from){ private function verifyRelation($target, $from)
{
$chatRelationModel = new ChatRelation(); $chatRelationModel = new ChatRelation();
$param["to_id"] = $params["target"] = $target;
$chatRelationModel->getChatRelation(); $params["from"] = $from;
$relationResult = $chatRelationModel->getChatRelation($params);
if (count($relationResult) > 0) {
//表示关系已经建立
}
//getChatRelation //getChatRelation
} }
......
<?php <?php
namespace app\model; namespace app\model;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User : zw * User : zw
...@@ -22,11 +24,33 @@ class ChatRelation extends Model ...@@ -22,11 +24,33 @@ class ChatRelation extends Model
$this->db_ = Db($this->table); $this->db_ = Db($this->table);
} }
/**
* 获取关系是否存在
* @param $params
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
*/
public function getChatRelation($params, $field = "id,to_id,from_id") public function getChatRelation($params, $field = "id,to_id,from_id")
{ {
return $this->db->field($field) $where_ = $whereOr_ = [];
->where($params)
->find(); if (isset($params["target"])) {
$where_["to_id"] = $params["target"];
$whereOr_["from_id"] = $params["target"];
}
if (isset($params["from"])) {
$where_["to_id"] = $params["from"];
$whereOr_["from_id"] = $params["from"];
}
$where_["disable"] = 0;
$whereOr_["disable"] = 0;
return $this->field($field)
->where($where_)
->whereOr(function ($query) use ($whereOr_) {
$query->where($whereOr_);
})
->select();
} }
public function addChatRelation($params) public function addChatRelation($params)
......
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