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
6edaa036
Commit
6edaa036
authored
Jul 07, 2018
by
zw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
liaotian
parent
c64ea1e7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
42 deletions
+30
-42
AppChat.php
application/chat/controller/AppChat.php
+6
-3
ChatService.php
application/chat/service/ChatService.php
+21
-38
UWxInfo.php
application/model/UWxInfo.php
+3
-1
No files found.
application/chat/controller/AppChat.php
View file @
6edaa036
...
@@ -81,22 +81,25 @@ class AppChat extends Basic
...
@@ -81,22 +81,25 @@ class AppChat extends Basic
"user_id" => 118,
"user_id" => 118,
"mobile" => "15821506182",
"mobile" => "15821506182",
"source" => 1 //1经纪人 2用户
"source" => 1 //1经纪人 2用户
"push_id" => "ssss1231231123123"
);*/
);*/
$params
=
$this
->
params
;
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'user_id'
])
||
!
isset
(
$params
[
'mobile'
])
||
!
isset
(
$params
[
'source'
]))
{
if
(
!
isset
(
$params
[
'user_id'
])
||
!
isset
(
$params
[
'mobile'
])
||
!
isset
(
$params
[
'source'
])
||
!
isset
(
$params
[
'push_id'
])
)
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
}
$user_id
=
$params
[
'user_id'
];
$user_id
=
$params
[
'user_id'
];
$mobile
=
$params
[
'mobile'
];
$mobile
=
$params
[
'mobile'
];
$source
=
$params
[
'source'
];
$source
=
$params
[
'source'
];
$push_id
=
$params
[
'push_id'
];
if
(
!
$user_id
||
!
$mobile
||
!
$source
)
{
if
(
!
$user_id
||
!
$mobile
||
!
$source
||
!
$push_id
)
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
}
$only_arr
=
$this
->
_chat
->
register
(
$user_id
,
$mobile
,
$source
);
$only_arr
=
$this
->
_chat
->
register
(
$user_id
,
$mobile
,
$source
,
$push_id
);
if
(
$only_arr
[
"code"
]
==
200
)
{
if
(
$only_arr
[
"code"
]
==
200
)
{
return
$this
->
response
(
"200"
,
"success"
,
[
"only_id"
=>
$only_arr
[
"only_id"
]
]);
return
$this
->
response
(
"200"
,
"success"
,
[
"only_id"
=>
$only_arr
[
"only_id"
]
]);
...
...
application/chat/service/ChatService.php
View file @
6edaa036
...
@@ -58,12 +58,13 @@ class ChatService
...
@@ -58,12 +58,13 @@ class ChatService
* @param $user_id
* @param $user_id
* @param $mobile
* @param $mobile
* @param $source
* @param $source
* @param $push_id
* @return array
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
register
(
$user_id
,
$mobile
,
$source
)
public
function
register
(
$user_id
,
$mobile
,
$source
,
$push_id
)
{
{
$params
[
"type"
]
=
$source
;
$params
[
"type"
]
=
$source
;
$params
[
"user_id"
]
=
$user_id
;
$params
[
"user_id"
]
=
$user_id
;
...
@@ -74,20 +75,21 @@ class ChatService
...
@@ -74,20 +75,21 @@ class ChatService
if
(
count
(
$chatUser
)
>
0
)
{
if
(
count
(
$chatUser
)
>
0
)
{
return
[
"code"
=>
"200"
,
"only_id"
=>
$chatUser
[
0
][
"only_id"
]
];
return
[
"code"
=>
"200"
,
"only_id"
=>
$chatUser
[
0
][
"only_id"
]
];
}
else
{
}
else
{
$reg
=
new
RegisterUtil
();
$only_id
=
$this
->
createOnlyId
(
$user_id
,
$source
);
$only_id
=
$this
->
createOnlyId
(
$user_id
,
$source
);
if
(
!
$only_id
)
{
if
(
!
$only_id
)
{
return
[
"code"
=>
"101"
,
"msg"
=>
"user msg not found"
];
return
[
"code"
=>
"101"
,
"msg"
=>
"没有找到用户信息"
];
}
}
else
{
$response
=
$reg
->
registerByCurl
(
$only_id
,
$mobile
);
if
(
$response
)
{
//todo insert
$this
->
insertChatUser
(
$source
,
$user_id
,
$mobile
,
$only_id
);
$this
->
insertChatUser
(
$source
,
$user_id
,
$mobile
,
$only_id
);
}
}
//todo 保存或更新push_id
return
[
"code"
=>
200
,
"only_id"
=>
$only_id
];
return
[
"code"
=>
200
,
"only_id"
=>
$only_id
];
}
}
}
}
private
function
savePushId
(){
//todo
}
/**
/**
* 生成唯一id
* 生成唯一id
...
@@ -103,12 +105,9 @@ class ChatService
...
@@ -103,12 +105,9 @@ class ChatService
$onlyId
=
""
;
$onlyId
=
""
;
switch
(
$source
)
{
switch
(
$source
)
{
case
1
:
case
1
:
/*$where_["inuse"] = 1;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);*/
$where_
[
"status"
]
=
0
;
$where_
[
"status"
]
=
0
;
$where_
[
"id"
]
=
$userId
;
$where_
[
"id"
]
=
$userId
;
$agentsResult
=
$this
->
agentsV2Model
->
getAgentsByStoreId
(
$where_
);
$agentsResult
=
$this
->
agentsV2Model
->
getAgentsByStoreId
(
$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
;
...
@@ -153,32 +152,16 @@ class ChatService
...
@@ -153,32 +152,16 @@ class ChatService
* @param $accessToken
* @param $accessToken
* @return bool
* @return bool
*/
*/
public
function
sendMsg
(
$user_name
,
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$accessToken
)
public
function
sendMsg
(
$user_name
,
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$accessToken
)
{
{
//todo 判断是否创建关系没有则保存
$this
->
verifyRelation
(
$target
,
$from
);
//fixme 之后扩展 此处有bug
/* 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
->
insertMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
);
$this
->
insertMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
);
$rPush
=
new
RPush
();
$rPush
=
new
RPush
();
//todo 消息接收人必须是数据
//todo 消息接收人必须是数据
$rPush
->
send
(
$user_name
,
$target_type
,
[
$target
],
$msg_content
,
$from
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
$rPush
->
send
(
$user_name
,
$target_type
,
[
$target
],
$msg_content
,
$from
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
return
true
;
return
true
;
}
}
...
@@ -236,18 +219,18 @@ class ChatService
...
@@ -236,18 +219,18 @@ class ChatService
$info_arr
=
[];
$info_arr
=
[];
if
(
count
(
$agent_phone
)
>
0
)
{
if
(
count
(
$agent_phone
)
>
0
)
{
/* $field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic,CONCAT(agentshopname,'-',sub_shopname) as shop_name";
/* $field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic,CONCAT(agentshopname,'-',sub_shopname) as shop_name";
$where_agent["phone"] = array( "in", $agent_phone );
$where_agent["phone"] = array( "in", $agent_phone );
$where_agent["inuse"] = 1;
$where_agent["inuse"] = 1;
$where_agent["level"] = array( "in", [ 2, 5 ] );
$where_agent["level"] = array( "in", [ 2, 5 ] );
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);*/
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);*/
$field
=
"a.id,a.name as user_nick,a.phone as user_phone,a.img as user_pic,CONCAT(c.district_name,'-',b.store_name) as shop_name"
;
$field
=
"a.id,a.name as user_nick,a.phone as user_phone,a.img as user_pic,CONCAT(c.district_name,'-',b.store_name) as shop_name"
;
$where_agent
[
"phone"
]
=
array
(
"in"
,
$agent_phone
);
$where_agent
[
"phone"
]
=
array
(
"in"
,
$agent_phone
);
$agentsResult
=
$this
->
agentsV2Model
->
getAgentsInfoByAgentId
(
$field
,
$where_agent
);
$agentsResult
=
$this
->
agentsV2Model
->
getAgentsInfoByAgentId
(
$field
,
$where_agent
);
foreach
(
$agentsResult
as
$v
)
{
foreach
(
$agentsResult
as
$v
)
{
if
(
$v
[
"user_pic"
])
{
if
(
$v
[
"user_pic"
])
{
...
...
application/model/UWxInfo.php
View file @
6edaa036
...
@@ -60,12 +60,14 @@ class UWxInfo extends Model
...
@@ -60,12 +60,14 @@ class UWxInfo extends Model
}
}
}
}
/**
/**
* 根据微信open_id获取id
* 根据微信open_id获取id
* @param string $open_id
* @param string $open_id
* @param string $field
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
*/
public
function
getWxInfoByOpenId
(
string
$open_id
,
string
$field
=
"id"
)
public
function
getWxInfoByOpenId
(
string
$open_id
,
string
$field
=
"id"
)
{
{
...
...
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