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
57e817f3
Commit
57e817f3
authored
May 07, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开盘redis
parent
5515a564
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
143 additions
and
2 deletions
+143
-2
SquareSortService.php
application/api_broker/service/SquareSortService.php
+26
-2
BSquareSort.php
application/model/BSquareSort.php
+49
-0
route.php
application/route.php
+1
-0
SquareTask.php
application/task/controller/SquareTask.php
+67
-0
No files found.
application/api_broker/service/SquareSortService.php
View file @
57e817f3
...
...
@@ -35,10 +35,9 @@ class SquareSortService
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
,
$time_
,
$s_id
);
$this
->
redis
->
zAdd
(
self
::
SORT_KEY
,
time
()
,
$s_id
);
return
true
;
}
...
...
@@ -82,4 +81,28 @@ class SquareSortService
return
true
;
}
}
/**
* 每个开盘浏览统计(UV)
*
* @return array
* User HuJun
* Date 19-5-7 下午4:37
*/
public
function
getLookData
()
{
$look_num
=
$this
->
redis
->
zRange
(
self
::
LOOK_NUM_KEY
,
0
,
-
1
,
true
);
return
$look_num
;
}
/**
* 每个开盘最后评论时间
*
* @return array
* User HuJun
* Date 19-5-7 下午4:38
*/
public
function
getCommentData
()
{
$comment_time
=
$this
->
redis
->
zRange
(
self
::
SORT_KEY
,
0
,
-
1
,
true
);
return
$comment_time
;
}
}
\ No newline at end of file
application/model/BSquareSort.php
0 → 100644
View file @
57e817f3
<?php
namespace
app\model
;
use
think\Db
;
class
BSquareSort
extends
BaseModel
{
protected
$table
=
"b_square_sort"
;
private
$db_
;
public
function
__construct
()
{
$this
->
db_
=
Db
::
name
(
$this
->
table
);
}
/**
* 更新数据
*
* @param $data
* @param $id
* @param array $where
* @return mixed
* User HuJun
* Date 19-5-7 下午5:54
*/
public
function
updateData
(
$data
,
$id
,
$where
=
[])
{
if
(
$id
>
0
)
{
$where
[
'id'
]
=
$id
;
}
return
$this
->
db_
->
where
(
$where
)
->
upate
(
$data
);
}
/**
* 插入数据
*
* @param $data
* @return int|string
* User HuJun
* Date 19-5-7 下午5:54
*/
public
function
insertData
(
$data
)
{
return
$this
->
db_
->
insert
(
$data
);
}
}
\ No newline at end of file
application/route.php
View file @
57e817f3
...
...
@@ -633,6 +633,7 @@ Route::group('task', [
'moveFollowUpList'
=>
[
'task/FollowUpTask/moveFollowUpList'
,
[
'method'
=>
'get'
]],
'frostAgent'
=>
[
'task/FrostAgentTask/frostAgent'
,
[
'method'
=>
'get'
]],
'squareBackUp'
=>
[
'task/squareBackUp/readRedis'
,
[
'method'
=>
'get'
]],
'updateActivityStatus'
=>
[
'task/UpdateActivityTask/updateActivityStatus'
,
[
'method'
=>
'get'
]],
...
...
application/task/controller/SquareTask.php
0 → 100644
View file @
57e817f3
<?php
namespace
app\task\controller
;
use
app\api_broker\service\SquareSortService
;
use
app\model\BSquare
;
use
app\model\BSquareSort
;
class
SquareTask
{
private
$m_sort
;
private
$m_square
;
public
function
__construct
()
{
$this
->
m_sort
=
new
BSquareSort
();
$this
->
m_square
=
new
BSquare
();
}
public
function
squareBackUp
()
{
$save_data
=
$square_id
=
[];
$sort_service
=
new
SquareSortService
();
$look_num
=
$sort_service
->
getLookData
();
//看盘数量
foreach
(
$look_num
as
$k
=>
$v
)
{
$square_id
[]
=
$k
;
}
$comment
=
$sort_service
->
getCommentData
();
//最后评论时间
foreach
(
$comment
as
$k
=>
$v
)
{
$square_id
[]
=
$k
;
}
if
(
empty
(
$square_id
))
{
return
;
}
$square_id
=
array_unique
(
$square_id
);
sort
(
$square_id
);
foreach
(
$square_id
as
$k
=>
$v
)
{
if
(
isset
(
$look_num
[
$v
]))
{
$save_data
[
'browse_number'
]
=
$look_num
[
$v
];
if
(
$look_num
[
$v
]
>=
500
)
{
$square_data
=
$this
->
m_square
->
getSquare
(
'id,is_cream'
,[
'id'
=>
$v
]);
//是否是精华帖 0普通 1精华
if
(
$square_data
[
0
][
'is_cream'
]
==
0
)
{
$this
->
m_square
->
updateStatus
([
'id'
=>
$v
],
[
'is_cream'
=>
1
]);
}
}
}
if
(
isset
(
$comment
[
$v
]))
{
$save_data
[
'last_reply_time'
]
=
date
(
'Y-m-d H:i:s'
,
$comment
[
$v
]);
}
$num
=
$this
->
m_sort
->
getList
(
1
,
1
,
''
,
'id'
,[
'square_id'
=>
$v
,
'is_del'
=>
0
]);
if
(
$num
)
{
$this
->
m_sort
->
updateData
(
$save_data
,
$num
[
0
][
'id'
]);
}
else
{
$save_data
[
'square_id'
]
=
$v
;
$this
->
m_sort
->
insertData
(
$save_data
);
}
}
}
}
\ 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