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
43a59923
Commit
43a59923
authored
May 07, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
140845a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
1 deletion
+60
-1
SquareSort.php
application/api_broker/service/SquareSort.php
+60
-1
No files found.
application/api_broker/service/SquareSort.php
View file @
43a59923
...
...
@@ -14,6 +14,9 @@ class SquareSort
{
private
$redis
;
private
$nowTime
;
const
SORT_KEY
=
"sort_by_time_square"
;
const
LOOK_NUM_KEY
=
"look_num_square"
;
const
LOOK_AGENT_KEY
=
"_look_agent_square_"
;
public
function
__construct
()
{
...
...
@@ -21,7 +24,62 @@ class SquareSort
$this
->
nowTime
=
date
(
"Y-m-d"
,
time
());
}
public
function
setSortSquareSort
(){
/**
* 评论的时候调用 根据评论时间排序
* @param $s_id
* @return bool
*/
public
function
setSortSquareSort
(
$s_id
)
{
if
(
!
$s_id
||
$s_id
<=
0
)
{
return
false
;
}
//todo 设置排序按评论时间,每次薪的评论进来,先删除掉存在的,插入新的
$time_
=
date
(
"Y-m-d H:i:s"
,
time
());
$this
->
redis
->
zRem
(
self
::
SORT_KEY
,
$s_id
);
//删除不管key存不存在
//todo 新增key
$this
->
redis
->
zAdd
(
self
::
SORT_KEY
,
$s_id
,
$time_
);
return
true
;
}
/**
* 开盘广场浏览人数统计
* @param $s_id
* @param $agent_id
* @return bool
*/
public
function
setCream
(
$s_id
,
$agent_id
)
{
if
(
!
$this
->
verifyAgentLookSquare
(
$s_id
,
$agent_id
))
{
return
false
;
}
if
(
$this
->
redis
->
zScore
(
self
::
LOOK_NUM_KEY
,
$s_id
))
{
$this
->
redis
->
zIncrBy
(
self
::
LOOK_NUM_KEY
,
1
,
$s_id
);
}
else
{
//todo 新增key
$this
->
redis
->
zAdd
(
self
::
LOOK_NUM_KEY
,
$s_id
,
1
);
}
return
true
;
}
/**
* 验证经纪人是否看过此开盘广场
* @param $s_id
* @param $agent_id
* @return bool
*/
private
function
verifyAgentLookSquare
(
$s_id
,
$agent_id
)
{
if
(
!
$s_id
||
$s_id
<=
0
||
!
$agent_id
||
$agent_id
<=
0
)
{
return
false
;
}
if
(
$this
->
redis
->
get
(
$s_id
.
self
::
LOOK_AGENT_KEY
.
$agent_id
))
{
return
false
;
}
else
{
$this
->
redis
->
set
(
$s_id
.
self
::
LOOK_AGENT_KEY
.
$agent_id
,
1
);
return
true
;
}
}
}
\ 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