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
98f71a94
Commit
98f71a94
authored
Jan 26, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息发送成功失败存储 接口修改
parent
ec82c0e0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
32 deletions
+74
-32
AppChat.php
application/chat/controller/AppChat.php
+7
-10
ChatService.php
application/chat/service/ChatService.php
+26
-21
curl_cookie.txt
application/chat/utils/curl_cookie.txt
+1
-1
ChatMsgStatus.php
application/model/ChatMsgStatus.php
+40
-0
No files found.
application/chat/controller/AppChat.php
View file @
98f71a94
...
@@ -102,18 +102,15 @@ class AppChat extends Basic
...
@@ -102,18 +102,15 @@ class AppChat extends Basic
{
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'only_id'
])
||
!
isset
(
$params
[
'
phone'
])
||
!
isset
(
$params
[
'
source'
]))
{
if
(
!
isset
(
$params
[
'only_id'
])
||
!
isset
(
$params
[
'source'
]))
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
}
/* $params = array(
/* $params = array(
"only_id" => "user_72,agent_10",
"only_id" => "user_72,agent_10",
"phone" => "13112341234",
"source" => 2,// 1经纪人 or 2用户
"source" => 2,// 1经纪人 or 2用户
);*/
);*/
$only_id
=
isset
(
$params
[
'only_id'
])
?
$params
[
'only_id'
]
:
0
;
$phone
=
isset
(
$params
[
'phone'
])
?
$params
[
'phone'
]
:
0
;
$result
=
$this
->
_chat
->
getUserInfo
(
$
only_id
,
$phone
,
$params
[
"source"
]);
$result
=
$this
->
_chat
->
getUserInfo
(
$
params
[
'only_id'
]
,
$params
[
"source"
]);
if
(
$result
)
{
if
(
$result
)
{
return
$this
->
response
(
"200"
,
"request success"
,
$result
);
return
$this
->
response
(
"200"
,
"request success"
,
$result
);
}
}
...
@@ -128,21 +125,21 @@ class AppChat extends Basic
...
@@ -128,21 +125,21 @@ class AppChat extends Basic
public
function
pushMsg
()
public
function
pushMsg
()
{
{
$params
=
$this
->
params
;
/*
$params = $this->params;
if (!isset($params['target_type']) || !isset($params['target']) || !isset($params['type']) || !isset($params['msg_content'])
if (!isset($params['target_type']) || !isset($params['target']) || !isset($params['type']) || !isset($params['msg_content'])
|| !isset($params['source']) || !isset($params['is_user']) || !isset($params['from'])) {
|| !isset($params['source']) || !isset($params['is_user']) || !isset($params['from'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
}*/
/*
$params = array(
$params
=
array
(
'msg_content'
=>
'ceshi666'
,
'msg_content'
=>
'ceshi666'
,
'target_type'
=>
'users'
,
'target_type'
=>
'users'
,
'source'
=>
'1'
,
'source'
=>
'1'
,
'from' => 'admin
',
'from'
=>
'adminqwqw
'
,
'type'
=>
'1'
,
'type'
=>
'1'
,
'is_user'
=>
'0'
,
'is_user'
=>
'0'
,
'target'
=>
'18112347151'
,
'target'
=>
'18112347151'
,
);*/
);
$target_type
=
$params
[
'target_type'
];
// 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target_type
=
$params
[
'target_type'
];
// 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target
=
$params
[
'target'
];
//接受人 if target_type 群 者表示群id
$target
=
$params
[
'target'
];
//接受人 if target_type 群 者表示群id
$source
=
$params
[
'source'
];
//消息来源 1c端app 2b端app 3其他
$source
=
$params
[
'source'
];
//消息来源 1c端app 2b端app 3其他
...
...
application/chat/service/ChatService.php
View file @
98f71a94
...
@@ -15,6 +15,7 @@ use app\chat\utils\RPush;
...
@@ -15,6 +15,7 @@ use app\chat\utils\RPush;
use
app\model\Agents
;
use
app\model\Agents
;
use
app\model\ChatMsg
;
use
app\model\ChatMsg
;
use
app\model\ChatMsgExt
;
use
app\model\ChatMsgExt
;
use
app\model\ChatMsgStatus
;
use
app\model\ChatUser
;
use
app\model\ChatUser
;
use
app\model\Users
;
use
app\model\Users
;
...
@@ -161,28 +162,27 @@ class ChatService
...
@@ -161,28 +162,27 @@ class ChatService
public
function
saveSendStatus
(
$response
,
$target
,
$from
,
$msg_content
)
public
function
saveSendStatus
(
$response
,
$target
,
$from
,
$msg_content
)
{
{
$response
=
json_decode
(
$response
,
true
);
$response
=
json_decode
(
$response
,
true
);
$status
=
$response
[
"data"
][
$target
[
0
]];
//目前没有针对多人聊天
if
(
$status
===
"success"
)
{
$status
=
isset
(
$response
[
"data"
][
$target
[
0
]])
?
$response
[
"data"
][
$target
[
0
]]
:
"faild"
;
//todo 保存成功
$error_reason
=
""
;
if
(
$status
!=
"success"
)
{
$error_reason
=
"环信发送异常"
;
}
}
$this
->
insertPushLog
(
$from
,
$target
[
0
],
$msg_content
,
$status
,
$error_reason
);
// $status = $response['statusCode'] == RPush::PUSH_STATUS_SUCCESS ? MsgStatus::STATUS_SUCCESS : MsgStatus::STATUS_FAILURE;
//$this->insertPushLog($sender, $target, $msg_content, $status, $response['statusMsg']);
}
}
/**
/**
* 根据手机号或者onlyId获取用户信息
* 根据手机号或者onlyId获取用户信息
* @param $only_id
* @param $only_id
* @param $phone
* @param $type 之后扩展
* @param $type
* @return array|false|\PDOStatement|string|\think\Model
* @return array|false|\PDOStatement|string|\think\Model
*
*/
*/
public
function
getUserInfo
(
$only_id
,
$
phone
,
$
type
)
public
function
getUserInfo
(
$only_id
,
$type
)
{
{
$user_phone
=
$agent_phone
=
[];
$user_phone
=
$agent_phone
=
[];
$chat_user_arr
=
[];
if
(
$only_id
)
{
if
(
$only_id
)
{
$only_id_arr
=
explode
(
","
,
$only_id
);
$only_id_arr
=
explode
(
","
,
$only_id
);
$where_
[
"only_id"
]
=
array
(
"in"
,
$only_id_arr
);
$where_
[
"only_id"
]
=
array
(
"in"
,
$only_id_arr
);
...
@@ -195,15 +195,10 @@ class ChatService
...
@@ -195,15 +195,10 @@ class ChatService
}
else
{
}
else
{
array_push
(
$user_phone
,
$v
[
"phone"
]);
array_push
(
$user_phone
,
$v
[
"phone"
]);
}
}
$chat_user_arr
[
$v
[
"phone"
]]
=
$v
[
"only_id"
];
}
}
}
else
{
if
(
$type
==
1
)
{
$agent_phone
=
[
$phone
];
}
else
if
(
$type
==
2
)
{
$user_phone
=
[
$phone
];
}
}
}
$info_arr
=
[];
$info_arr
=
[];
...
@@ -219,6 +214,8 @@ class ChatService
...
@@ -219,6 +214,8 @@ class ChatService
if
(
$v
[
"user_pic"
])
{
if
(
$v
[
"user_pic"
])
{
$v
[
"user_pic"
]
=
IMG_PATH
.
$v
[
"user_pic"
];
$v
[
"user_pic"
]
=
IMG_PATH
.
$v
[
"user_pic"
];
}
}
$v
[
"only_id"
]
=
$chat_user_arr
[
$v
[
"user_phone"
]];
array_push
(
$info_arr
,
$v
);
array_push
(
$info_arr
,
$v
);
}
}
...
@@ -235,6 +232,7 @@ class ChatService
...
@@ -235,6 +232,7 @@ class ChatService
if
(
$v
[
"user_pic"
])
{
if
(
$v
[
"user_pic"
])
{
$v
[
"user_pic"
]
=
HEADERIMGURL
.
$v
[
"user_pic"
];
$v
[
"user_pic"
]
=
HEADERIMGURL
.
$v
[
"user_pic"
];
}
}
$v
[
"only_id"
]
=
$chat_user_arr
[
$v
[
"user_phone"
]];
array_push
(
$info_arr
,
$v
);
array_push
(
$info_arr
,
$v
);
}
}
}
}
...
@@ -314,17 +312,24 @@ class ChatService
...
@@ -314,17 +312,24 @@ class ChatService
/**
/**
* 往chat_msg_status中插入数据,记录推送的状态
* 往chat_msg_status中插入数据,记录推送的状态
* @param $
sender
* @param $
from
* @param $target
* @param $target
* @param $content
* @param $content
* @param $status
* @param $status
* @param $error_reason
* @param $error_reason
* @return bool
* @return bool
*/
*/
public
function
insertPushLog
(
$
sender
,
$target
,
$content
,
$status
,
$error_reason
)
public
function
insertPushLog
(
$
from
,
$target
,
$content
,
$status
,
$error_reason
)
{
{
$param
[
"from"
]
=
$from
;
//todo
$param
[
"target"
]
=
$target
;
$param
[
"content"
]
=
$content
;
$param
[
"status"
]
=
$status
;
$param
[
"error_reason"
]
=
$error_reason
;
$param
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$model_
=
new
ChatMsgStatus
();
$model_
->
addChatMsgStatus
(
$param
);
return
true
;
return
true
;
}
}
...
...
application/chat/utils/curl_cookie.txt
View file @
98f71a94
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
# http://curl.haxx.se/docs/http-cookies.html
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 1516
87498
0 rememberMe deleteMe
a1.easemob.com FALSE / FALSE 1516
95455
0 rememberMe deleteMe
application/model/ChatMsgStatus.php
0 → 100644
View file @
98f71a94
<?php
namespace
app\model
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/26
* Time : 16:08
* Intro:
*/
use
think\Model
;
use
think\Db
;
class
ChatMsgStatus
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'chat_msg_status'
;
protected
$db
;
public
function
__construct
()
{
$this
->
db
=
Db
::
name
(
$this
->
table
);
}
public
function
addChatMsgStatus
(
$params
)
{
Db
::
startTrans
();
try
{
$this
->
db
->
insert
(
$params
);
Db
::
commit
();
}
catch
(
\Exception
$e
)
{
dump
(
$e
);
Db
::
rollback
();
}
return
0
;
}
}
\ No newline at end of file
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