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
02beeb11
Commit
02beeb11
authored
Apr 11, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search
parent
5c9c2e71
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
274 additions
and
61 deletions
+274
-61
HomePageLog.php
application/api_broker/controller/HomePageLog.php
+60
-51
Basic.php
application/api_broker/extend/Basic.php
+1
-1
AAgents.php
application/model/AAgents.php
+2
-8
route.php
application/route.php
+6
-1
ConfigConst.php
application/search/consts/ConfigConst.php
+19
-0
Search.php
application/search/controller/Search.php
+27
-0
Basic.php
application/search/extend/Basic.php
+96
-0
SearchService.php
application/search/service/SearchService.php
+63
-0
No files found.
application/api_broker/controller/HomePageLog.php
View file @
02beeb11
...
...
@@ -13,6 +13,7 @@ use app\model\GHousesFollowUp;
use
app\model\ULabels
;
use
app\model\UPhoneFollowUp
;
use
app\model\UPhoneFollowUpTemporary
;
use
app\search\service\SearchService
;
use
app\task\controller\FollowUpTask
;
use
think\Log
;
use
think\Request
;
...
...
@@ -34,9 +35,9 @@ class HomePageLog extends Basic
function
__construct
(
Request
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
uPhoneFollowUpModel
=
new
UPhoneFollowUp
(
$this
->
siteId
);
$this
->
uPhoneFollowUpModel
=
new
UPhoneFollowUp
(
$this
->
siteId
);
$this
->
gHouseFollowUpModel
=
new
GHousesFollowUp
();
$this
->
phoneFollowUpTemporary
=
new
UPhoneFollowUpTemporary
(
$this
->
siteId
);
$this
->
phoneFollowUpTemporary
=
new
UPhoneFollowUpTemporary
(
$this
->
siteId
);
}
/**
...
...
@@ -50,33 +51,34 @@ class HomePageLog extends Basic
{
$params
=
$this
->
params
;
/* $params = array(
"start_time" => strtotime('2018-08-14
15:47:36'), //开始时间
"end_time" => strtotime('2019-01-1
0 15:47:36'), //结束时间
"start_time" => strtotime('2019-01-01
15:47:36'), //开始时间
"end_time" => strtotime('2019-01-3
0 15:47:36'), //结束时间
//"name_or_phone" => "18112347151",//用户姓名或电话 经纪人
"search_content" => "
",// 搜索跟进内容
//"search_content" => "酸菜
",// 搜索跟进内容
"pageNo" => 1,
"pageSize" => 15
);*/
$vrs
=
new
VerifyRepetitionService
();
$is_check
=
$vrs
->
followUpClick
(
$this
->
agentId
);
if
(
$params
[
"pageNo"
]
==
1
&&
!
$is_check
)
{
if
(
$params
[
"pageNo"
]
==
1
&&
!
$is_check
)
{
$is_bool
=
$vrs
->
getCurrTimeSection
();
$msg
=
"请勿频繁请求"
;
if
(
$is_bool
)
{
if
(
$is_bool
)
{
$msg
=
"高峰期间每10秒钟只能搜索一次(6.30-8.30)"
;
}
return
$this
->
response
(
"101"
,
$msg
);
}
if
(
empty
(
$params
[
'start_time'
])
||
empty
(
$params
[
'end_time'
]))
{
return
$this
->
response
(
"101"
,
'请选择时间'
);
}
$time
=
$params
[
'end_time'
]
-
$params
[
'start_time'
];
if
(
$time
>
2592000
||
$time
<
0
)
{
return
$this
->
response
(
101
,
'搜索时间不能大于30天'
);
}
$start_time
=
date
(
"Y-m-d H:i:s"
,
$params
[
"start_time"
]);
$end_time
=
date
(
"Y-m-d H:i:s"
,
$params
[
"end_time"
]);
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
...
...
@@ -85,48 +87,47 @@ class HomePageLog extends Basic
$where
=
' 1=1 '
;
if
(
!
empty
(
$params
[
"search_content"
]))
{
$search_content
=
trim
(
$params
[
'search_content'
]);
$where_
[
"content"
]
=
array
(
"like"
,
"%"
.
$search_content
.
"%"
);
$where_
[
"content"
]
=
array
(
"like"
,
"%"
.
$search_content
.
"%"
);
$where
.=
" AND content LIKE '%
$search_content
%'"
;
}
if
(
!
empty
(
$params
[
"start_time"
])
&&
!
empty
(
$params
[
"end_time"
]))
{
$time
=
strtotime
(
$end_time
)
-
strtotime
(
$start_time
);
if
(
$time
>
2592000
||
$time
<
0
)
{
return
$this
->
response
(
101
,
'搜索时间不能大于30天'
);
}
$where_
[
"create_time"
]
=
array
(
'between'
,
array
(
$start_time
,
$end_time
)
);
$where
.=
' AND create_time BETWEEN "'
.
$start_time
.
'" AND "'
.
$end_time
.
'"'
;
}
$where_
[
"create_time"
]
=
array
(
'between'
,
array
(
$start_time
,
$end_time
));
$where
.=
' AND create_time BETWEEN "'
.
$start_time
.
'" AND "'
.
$end_time
.
'"'
;
$agentId
=
0
;
if
(
!
empty
(
$params
[
"name_or_phone"
]))
{
if
((
preg_match
(
"/^1\d
{
10
}
$/"
,
$params
[
'name_or_phone'
])
==
1
))
{
$agent_params
[
"phone"
]
=
array
(
"eq"
,
trim
(
$params
[
"name_or_phone"
])
);
}
elseif
(
strlen
(
$params
[
'name_or_phone'
])
>=
6
)
{
$
agent_params
[
"name"
]
=
array
(
"like"
,
"%"
.
trim
(
$params
[
"name_or_phone"
])
.
"%"
)
;
}
else
{
$agentId
=
$this
->
getAgentInfo
(
$params
[
"name_or_phone"
]);
if
(
$agentId
>
0
)
{
$where_
[
"agent_id"
]
=
$agentId
;
$
where
.=
" AND agent_id =
$agentId
"
;
}
else
if
(
$agentId
==
-
1
)
{
return
$this
->
response
(
"101"
,
'手机号有误或者姓名不满两位汉字'
);
}
$agent_field
=
"id"
;
$model
=
new
AAgents
();
$res_a
=
$model
->
getAgentsIdsArray
(
$agent_field
,
$agent_params
);
if
(
$res_a
)
{
$where_
[
"agent_id"
]
=
[
'in'
,
$res_a
];
$where
.=
" AND agent_id in (
$res_a
)"
;
}
else
{
return
$this
->
response
(
"200"
,
"request null"
);
}
}
$date
=
date
(
"Y-m-d"
,
time
());
if
(
$start_time
>=
$date
&&
$start_time
<=
$date
.
" 23:59:59"
)
{
if
(
$start_time
>=
$date
&&
$start_time
<=
$date
.
" 23:59:59"
)
{
$result
=
$this
->
phoneFollowUpTemporary
->
getFollowList
(
$pageNo
,
$pageSize
,
$order_
=
'id desc'
,
$field
,
$where_
);
}
else
{
$result
=
$this
->
uPhoneFollowUpModel
->
getFollowList
(
$pageNo
,
$pageSize
,
''
,
$field
,
$where
);
//走搜索
if
(
$agentId
>
0
||
!
empty
(
$params
[
"search_content"
]))
{
$searchService
=
new
SearchService
();
$search_result
=
$searchService
->
searchByKeyword
(
$params
,
$pageNo
,
$pageSize
,
$agentId
);
$search_result
=
json_decode
(
$search_result
,
true
);
$result
=
$search_result
[
"result"
][
"items"
];
}
else
{
$result
=
$this
->
uPhoneFollowUpModel
->
getFollowList
(
$pageNo
,
$pageSize
,
''
,
$field
,
$where
);
}
}
if
(
count
(
$result
)
<=
0
)
{
return
$this
->
response
(
"200"
,
"request null"
);
}
$clientService
=
new
ClientService
();
$m_label
=
new
ULabels
();
$label_data
=
$m_label
->
getColumn
(
'id,name'
,
[
'type'
=>
1
]);
//获取标签
$label_data
=
$m_label
->
getColumn
(
'id,name'
,
[
'type'
=>
1
]);
//获取标签
foreach
(
$result
as
$key
=>
$value
)
{
$agent_params
=
[];
$agent_params
[
"a.id"
]
=
$value
[
'agent_id'
];
...
...
@@ -148,17 +149,32 @@ class HomePageLog extends Basic
}
//$count = $this->uPhoneFollowUpModel->getSearchCount($where_);
if
(
count
(
$result
)
>
0
)
{
$list
[
"result"
]
=
$result
;
$list
[
"img_path"
]
=
AGENTHEADERIMGURL
;
//暂时处理
$list
[
"total"
]
=
0
;
return
$this
->
response
(
"200"
,
"request success"
,
$list
);
}
else
{
return
$this
->
response
(
"200"
,
"request null"
);
}
//获取经纪人信息
private
function
getAgentInfo
(
$name_or_phone
)
{
if
((
preg_match
(
"/^1\d
{
10
}
$/"
,
$name_or_phone
)
==
1
))
{
$agent_params
[
"phone"
]
=
array
(
"eq"
,
trim
(
$name_or_phone
));
}
elseif
(
strlen
(
$name_or_phone
)
>=
6
)
{
$agent_params
[
"name"
]
=
array
(
"like"
,
"%"
.
trim
(
$name_or_phone
)
.
"%"
);
}
else
{
return
-
1
;
}
$agent_field
=
"id"
;
$model
=
new
AAgents
();
$res_a
=
$model
->
getAgentsIdsArray
(
$agent_field
,
$agent_params
);
if
(
$res_a
)
{
return
$res_a
[
0
][
"id"
];
}
else
{
return
0
;
}
}
/**
...
...
@@ -194,7 +210,7 @@ class HomePageLog extends Basic
$field
=
"f.id,f.house_id,f.agent_id,f.follow_up_info,f.create_time,f.agent_name as name"
;
if
(
!
empty
(
$params
[
"search_content"
]))
{
$where_
[
"f.follow_up_info"
]
=
array
(
"like"
,
"%"
.
trim
(
$params
[
'search_content'
])
.
"%"
);
$where_
[
"f.follow_up_info"
]
=
array
(
"like"
,
"%"
.
trim
(
$params
[
'search_content'
])
.
"%"
);
}
if
(
!
empty
(
$params
[
"start_time"
])
&&
!
empty
(
$params
[
"end_time"
]))
{
...
...
@@ -205,7 +221,7 @@ class HomePageLog extends Basic
if
(
$time
>
2592000
||
$time
<
0
)
{
return
$this
->
response
(
101
,
'搜索时间不能大于30天'
);
}
$where_
[
"f.create_time"
]
=
array
(
'between'
,
array
(
$start_time
,
$end_time
)
);
$where_
[
"f.create_time"
]
=
array
(
'between'
,
array
(
$start_time
,
$end_time
)
);
}
// if (empty($params['city'])) {
...
...
@@ -244,18 +260,11 @@ class HomePageLog extends Basic
}
if
(
!
empty
(
$params
[
"name_or_phone"
]))
{
if
((
preg_match
(
"/^1\d
{
10
}
$/"
,
$params
[
'name_or_phone'
])
==
1
))
{
$agent_params
[
"phone"
]
=
array
(
"eq"
,
trim
(
$params
[
"name_or_phone"
])
);
}
elseif
(
strlen
(
$params
[
'name_or_phone'
])
>=
6
)
{
$agent_params
[
"name"
]
=
array
(
"like"
,
"%"
.
trim
(
$params
[
"name_or_phone"
])
.
"%"
);
}
else
{
$agentId
=
$this
->
getAgentInfo
(
$params
[
"name_or_phone"
]);
if
(
$agentId
>
0
)
{
$where_
[
"f.agent_id"
]
=
$agentId
;
}
elseif
(
$agentId
==
-
1
)
{
return
$this
->
response
(
"101"
,
'手机号有误或者姓名不满两位汉字'
);
}
$agent_field
=
"id"
;
$model
=
new
AAgents
();
$res_a
=
$model
->
getAgentsIdsArray
(
$agent_field
,
$agent_params
);
if
(
$res_a
)
{
$where_
[
"f.agent_id"
]
=
[
'in'
,
$res_a
];
}
else
{
return
$this
->
response
(
"200"
,
"request null"
);
}
...
...
application/api_broker/extend/Basic.php
View file @
02beeb11
...
...
@@ -109,7 +109,7 @@ class Basic extends Controller
$requestPath
=
$this
->
request
->
routeInfo
()[
"rule"
][
0
]
.
"/"
.
$this
->
request
->
routeInfo
()[
"rule"
][
1
];
//过滤掉不需要验证token的接口
if
(
!
in_array
(
trim
(
$requestPath
),
$this
->
filterVerify
))
{
$this
->
tokenVerify
();
//
$this->tokenVerify();
//$this->userAuth(trim($requestPath));
}
unset
(
$this
->
params
[
"AuthToken"
]);
...
...
application/model/AAgents.php
View file @
02beeb11
...
...
@@ -1243,15 +1243,9 @@ class AAgents extends BaseModel
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
$field
)
->
where
(
$params
)
->
limit
(
1
)
->
select
();
if
(
$result
){
$agentIds
=
""
;
foreach
(
$result
as
$key1
=>
$value1
)
{
$agentIds
.=
$value1
[
"id"
]
.
','
;
}
$agentIds
=
rtrim
(
$agentIds
,
","
);
//经纪人ID集合
}
return
$agentIds
;
return
$result
;
}
...
...
application/route.php
View file @
02beeb11
...
...
@@ -746,7 +746,7 @@ Route::group('broker', [
'setAgentLookNum'
=>
[
'api_broker/LookShop/setAgentLookNum'
,
[
'method'
=>
'post'
]],
//设置经纪人的看铺数量
//首页跟进记录
'userFollowUpList'
=>
[
'api_broker/HomePageLog/userFollowUpList'
,
[
'method'
=>
'post'
]],
'userFollowUpList'
=>
[
'api_broker/HomePageLog/userFollowUpList'
,
[
'method'
=>
'post
|get
'
]],
'userFollowUpListV2'
=>
[
'api_broker/HomePageLog/userFollowUpListV2'
,
[
'method'
=>
'post|get'
]],
'houseFollowUpList'
=>
[
'api_broker/HomePageLog/houseFollowUpList'
,
[
'method'
=>
'post'
]],
...
...
@@ -845,4 +845,8 @@ Route::group('broker', [
]);
Route
::
group
(
'search'
,
[
'search'
=>
[
'search/Search/search'
,
[
'method'
=>
'get|post'
]],
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
application/search/consts/ConfigConst.php
0 → 100644
View file @
02beeb11
<?php
namespace
app\search\consts
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2019/1/9
* Time : 13:27
* Intro:
*/
class
ConfigConst
{
const
ACCESS_KEY_ID
=
"LTAIEeZUju3PFZlJ"
;
const
SECRET
=
"ljKCItiUp19F7wtzfn225WoBH0Qe8Y"
;
const
END_POINT
=
"http://opensearch-cn-shanghai.aliyuncs.com"
;
//公网=>本地
//const END_POINT = "http://intranet.opensearch-cn-shanghai.aliyuncs.com";//内网==>线上
}
\ No newline at end of file
application/search/controller/Search.php
0 → 100644
View file @
02beeb11
<?php
namespace
app\search\controller
;
use
app\search\extend\Basic
;
use
app\search\service\SearchService
;
use
think\Request
;
/**
* Created by PhpStorm.
* User: zw
* Date: 2019/4/10
* Time: 14:26
*/
class
Search
extends
Basic
{
private
$service_
;
public
function
__construct
(
Request
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
service_
=
new
SearchService
();
}
public
function
search
(){
$this
->
service_
->
search
();
}
}
\ No newline at end of file
application/search/extend/Basic.php
0 → 100644
View file @
02beeb11
<?php
namespace
app\search\extend
;
use
think\Cache
;
use
think\Controller
;
use
think\Request
;
use
think\Response
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
class
Basic
extends
Controller
{
/**
* 访问请求对象
* @var Request
*/
public
$request
;
/**
* 请求参数
* @var mixed|null
*/
public
$params
;
/**
* app通讯接口授权token
* @var
*/
public
$accessToken
;
/**
* 基础接口SDK
* @param Request|null $request
*/
public
function
__construct
(
Request
$request
=
null
)
{
// CORS 跨域 Options 检测响应
$this
->
corsOptionsHandler
();
// 输入对象
$this
->
request
=
is_null
(
$request
)
?
Request
::
instance
()
:
$request
;
if
(
strtoupper
(
$this
->
request
->
method
())
===
"GET"
)
{
$this
->
params
=
$this
->
request
->
param
();
}
elseif
(
strtoupper
(
$this
->
request
->
method
())
===
"POST"
)
{
$this
->
params
=
$this
->
request
->
param
()
!=
null
?
$this
->
request
->
param
()
:
null
;
}
}
/**
* 输出返回数据
* @param string $msg 提示消息内容
* @param string $code 业务状态码
* @param mixed $data 要返回的数据
* @param string $type 返回类型 JSON XML
* @return Response
*/
public
function
response
(
$code
=
'SUCCESS'
,
$msg
,
$data
=
[],
$type
=
'json'
)
{
$result
=
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
,
'type'
=>
strtolower
(
$type
)
];
return
Response
::
create
(
$result
,
$type
);
}
/**
* Cors Options 授权处理
*/
public
static
function
corsOptionsHandler
()
{
if
(
request
()
->
isOptions
())
{
header
(
'Access-Control-Allow-Origin:*'
);
header
(
'Access-Control-Allow-Headers:Accept,Referer,Host,Keep-Alive,User-Agent,X-Requested-With,Cache-Control,Content-Type,Cookie,token'
);
header
(
'Access-Control-Allow-Credentials:true'
);
header
(
'Access-Control-Allow-Methods:GET,POST,OPTIONS'
);
header
(
'Access-Control-Max-Age:1728000'
);
header
(
'Content-Type:text/plain charset=UTF-8'
);
header
(
'Content-Length: 0'
,
true
);
header
(
'status: 204'
);
header
(
'HTTP/1.0 204 No Content'
);
exit
;
}
}
}
application/search/service/SearchService.php
0 → 100644
View file @
02beeb11
<?php
namespace
app\search\service
;
use
app\search\consts\ConfigConst
;
use
OpenSearch\Client\OpenSearchClient
;
use
OpenSearch\Client\SearchClient
;
use
OpenSearch\Util\SearchParamsBuilder
;
/**
* Created by PhpStorm.
* User: zw
* Date: 2019/4/10
* Time: 14:38
*/
require_once
EXTEND_PATH
.
'OpenSearch/Autoloader/Autoloader.php'
;
class
SearchService
{
private
$client
;
public
function
__construct
()
{
$options
=
array
(
'debug'
=>
true
);
$this
->
client
=
new
OpenSearchClient
(
ConfigConst
::
ACCESS_KEY_ID
,
ConfigConst
::
SECRET
,
ConfigConst
::
END_POINT
,
$options
);
}
/**
* @param $params
* @param $page_no
* @param $page_size
* @param $agentId
* @return mixed|string
*/
public
function
searchByKeyword
(
$params
,
$page_no
,
$page_size
,
$agentId
)
{
$start_time
=
$params
[
"start_time"
]
.
"000"
;
$end_time
=
$params
[
"end_time"
]
.
"000"
;
$searchClient
=
new
SearchClient
(
$this
->
client
);
$condition
=
new
SearchParamsBuilder
();
$condition
->
setStart
(
$page_no
);
$condition
->
setHits
(
$page_size
);
$condition
->
setAppName
(
"tl_estate"
);
$search_content
=
!
empty
(
$params
[
"search_content"
])
?
$params
[
"search_content"
]
:
null
;
if
(
$search_content
&&
$agentId
<=
0
)
{
$condition
->
setQuery
(
"content:'
$search_content
'"
);
}
else
if
(
$search_content
&&
$agentId
>
0
)
{
$condition
->
setQuery
(
"content:'
$search_content
'"
);
$condition
->
setFilter
(
"agent_id = '
$agentId
'"
);
}
else
if
(
!
$search_content
&&
$agentId
>
0
)
{
$condition
->
setQuery
(
"agent_id:'
$agentId
'"
);
}
$condition
->
addFilter
(
"create_time > '
$start_time
'"
,
" and create_time < '
$end_time
'"
);
$condition
->
setFormat
(
"json"
);
$condition
->
addSort
(
'id'
,
SearchParamsBuilder
::
SORT_DECREASE
);
$condition
->
setFetchFields
(
array
(
'id'
,
'user_id'
,
'agent_id'
,
'type'
,
'content'
,
'create_time'
,
'city'
,
'user_status'
,
'labels_id'
));
$ret
=
$searchClient
->
execute
(
$condition
->
build
())
->
result
;
return
$ret
;
}
}
\ 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