Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
e469ea76
Commit
e469ea76
authored
Feb 07, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
聊天关系建立
parent
49e57002
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
32 deletions
+80
-32
AppChat.php
application/chat/controller/AppChat.php
+26
-24
ChatService.php
application/chat/service/ChatService.php
+27
-5
ChatRelation.php
application/model/ChatRelation.php
+27
-3
No files found.
application/chat/controller/AppChat.php
View file @
e469ea76
...
...
@@ -154,8 +154,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"
=>
"消息内容错误"
]);
}
}
...
...
@@ -223,50 +225,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"
,
"暂无数据!"
);
}
...
...
application/chat/service/ChatService.php
View file @
e469ea76
...
...
@@ -18,7 +18,9 @@ use app\model\ChatMsgExt;
use
app\model\ChatMsgStatus
;
use
app\model\ChatRelation
;
use
app\model\ChatUser
;
use
app\model\HouseInfos
;
use
app\model\Users
;
use
http\Exception
;
class
ChatService
{
...
...
@@ -96,7 +98,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
:
...
...
@@ -142,8 +144,21 @@ class ChatService
public
function
sendMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$accessToken
)
{
if
(
$type
==
3
)
{
try
{
$house_id
=
(
integer
)
trim
(
$msg_content
);
$HouseInfoModel
=
new
HouseInfos
();
$houseResult
=
$HouseInfoModel
->
getHousepusmessage
(
$house_id
);
if
(
count
(
$houseResult
)
==
0
)
return
false
;
}
catch
(
Exception
$e
)
{
return
false
;
}
}
//todo 判断是否创建关系没有则保存
$this
->
verifyRelation
(
$target
,
$from
);
$this
->
verifyRelation
(
$target
,
$from
);
$this
->
insertMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
);
$rPush
=
new
RPush
();
...
...
@@ -283,10 +298,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
}
...
...
application/model/ChatRelation.php
View file @
e469ea76
<?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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment