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

聊天关系建立

parent d17ba1bc
......@@ -157,8 +157,10 @@ class AppChat extends Basic
}
$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" => "消息发送成功" ]);
}else{
return $this->response("101", "", [ "msg" => "消息内容错误" ]);
}
......@@ -228,50 +230,50 @@ class AppChat extends Basic
public function pushMsg_gethouseinfo()
{
$homeurl = $this->request->domain();
$params = $this->params;
$params = $this->params;
//$params['id']=312;
if (!isset($params['id'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
$id = $params['id'];
$HouseInfos=new HouseInfos();
$id = $params['id'];
$HouseInfos = new HouseInfos();
$HouseInfosre = $HouseInfos->getHousepusmessage($id);
//dump($HouseInfosre);
if($HouseInfosre){
$data['title']=$HouseInfosre[0]['title'];
if ($HouseInfosre) {
$data['title'] = $HouseInfosre[0]['title'];
//dump($HouseInfosre[0]['room_area']);
//dump($HouseInfosre[0]['room_area2']);
$room_area =$HouseInfosre[0]['room_area']? $HouseInfosre[0]['room_area']:'';
$room_area2 = $HouseInfosre[0]['room_area2']?'-'.$HouseInfosre[0]['room_area2']:'';
$data['room_area_all']='暂无!';
$room_area = $HouseInfosre[0]['room_area'] ? $HouseInfosre[0]['room_area'] : '';
$room_area2 = $HouseInfosre[0]['room_area2'] ? '-' . $HouseInfosre[0]['room_area2'] : '';
$data['room_area_all'] = '暂无!';
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']='暂无!';
if($HouseInfosre[0]['rent_type']){
$data['price'] = '暂无!';
if ($HouseInfosre[0]['rent_type']) {
//rent_type COMMENT '1.月租金 2.营业额扣点 3.每平方米租金',
$message[1]='月租金:'.$HouseInfosre[0]['price'].'元/月';
$message[2]='营业额扣点:'.$HouseInfosre[0]['price'].'%';
$message[3]='每平方米租金:'.$HouseInfosre[0]['price'].'元/天/㎡';
$data['price']=$message[$HouseInfosre[0]['rent_type']];
$message[1] = '月租金:' . $HouseInfosre[0]['price'] . '元/月';
$message[2] = '营业额扣点:' . $HouseInfosre[0]['price'] . '%';
$message[3] = '每平方米租金:' . $HouseInfosre[0]['price'] . '元/天/㎡';
$data['price'] = $message[$HouseInfosre[0]['rent_type']];
}
//同联默认图片,如果用户没上传的话/img/houseinfobackgroundimg.png
$data['imagename'] = $homeurl. '/img/houseinfobackgroundimg_new.png';
$data['imagename'] = $homeurl . '/img/houseinfobackgroundimg_new.png';
$HouseImgs=new HouseImgs();
$HouseImgsre = $HouseImgs->getHouseImgs($id,1);
$HouseImgs = new HouseImgs();
$HouseImgsre = $HouseImgs->getHouseImgs($id, 1);
//用户上传了就用上传的
if($HouseImgsre){
$data['imagename']=$homeurl. '/houseImg/small_' . $HouseImgsre[0]['imagename'];
if ($HouseImgsre) {
$data['imagename'] = $homeurl . '/houseImg/small_' . $HouseImgsre[0]['imagename'];
}
// dump($HouseInfosre);
// dump($data);
// exit;
return $this->response("200", "success!",$data);
}else{
return $this->response("200", "success!", $data);
} else {
return $this->response("400", "暂无数据!");
}
......
......@@ -96,7 +96,7 @@ class ChatService
$where_["inuse"] = 1;
$where_["id"] = $userId;
$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;
break;
case 2:
......@@ -293,10 +293,17 @@ class ChatService
* @param $target
* @param $from
*/
private function verifyRelation($target, $from){
private function verifyRelation($target, $from)
{
$chatRelationModel = new ChatRelation();
$param["to_id"] =
$chatRelationModel->getChatRelation();
$params["target"] = $target;
$params["from"] = $from;
$relationResult = $chatRelationModel->getChatRelation($params);
if (count($relationResult) > 0) {
//表示关系已经建立
}
//getChatRelation
}
......
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User : zw
......@@ -22,11 +24,33 @@ class ChatRelation extends Model
$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")
{
return $this->db->field($field)
->where($params)
->find();
$where_ = $whereOr_ = [];
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)
......
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