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
10bbc3d0
Commit
10bbc3d0
authored
May 09, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步修改开盘缓存
parent
72fb6e35
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
16 deletions
+89
-16
RedisCacheService.php
application/api_broker/service/RedisCacheService.php
+23
-1
SquareSortService.php
application/api_broker/service/SquareSortService.php
+7
-6
ASite.php
application/model/ASite.php
+20
-0
SquareTask.php
application/task/controller/SquareTask.php
+39
-9
No files found.
application/api_broker/service/RedisCacheService.php
View file @
10bbc3d0
...
...
@@ -29,6 +29,7 @@ class RedisCacheService
private
$group_key
=
'cache_group_'
;
private
$rule_key
=
'cache_rule_'
;
private
$site_city_key
=
'cache_site_city_'
;
private
$site_city_all_key
=
'cache_site_city_all'
;
private
$label_call_key
=
'cache_label_call'
;
private
$group_site_key
=
'cache_group_site_'
;
private
$time
;
...
...
@@ -246,7 +247,7 @@ class RedisCacheService
}
/**
* 缓存城市
*
根据id
缓存城市
*
* @param $id
* @return false|\PDOStatement|string|\think\Collection
...
...
@@ -261,6 +262,27 @@ class RedisCacheService
return
$name
;
}
/**
* 缓存所有城市站点
*
* @return bool|false|mixed|\PDOStatement|string|\think\Collection
* User HuJun
* Date 19-5-9 上午10:00
*/
public
function
siteAllCityCache
()
{
$result
=
$this
->
redis_ext
->
get
(
$this
->
site_city_all_key
);
if
(
empty
(
$result
))
{
$m_auth_rule
=
new
ASite
();
$result
=
$m_auth_rule
->
getSiteList
();
$this
->
setRedisCache
(
$this
->
site_city_all_key
,
$result
);
}
else
{
$result
=
json_decode
(
$result
,
true
);
}
return
$result
;
}
/**
* 缓存电话标签
*
...
...
application/api_broker/service/SquareSortService.php
View file @
10bbc3d0
...
...
@@ -15,8 +15,8 @@ class SquareSortService
{
private
$redis
;
private
$nowTime
;
const
SORT_KEY
=
"sort_by_time_square"
;
const
SORT_KEY_CREAM
=
"sort_by_time_square_cream"
;
const
SORT_KEY
=
"sort_by_time_square
_
"
;
const
SORT_KEY_CREAM
=
"sort_by_time_square_cream
_
"
;
const
LOOK_NUM_KEY
=
"look_num_square"
;
const
LOOK_AGENT_KEY
=
"_look_agent_square_"
;
...
...
@@ -40,7 +40,7 @@ class SquareSortService
//todo 设置排序按评论时间,每次薪的评论进来,先删除掉存在的,插入新的
//删除不管key存不存在
$look_num
=
$this
->
redis
->
zScore
(
self
::
LOOK_NUM_KEY
.
$site_id
,
$s_id
);
$look_num
=
$this
->
redis
->
zScore
(
self
::
LOOK_NUM_KEY
,
$s_id
);
$this
->
redis
->
zRem
(
self
::
SORT_KEY
.
$site_id
,
$s_id
);
$this
->
redis
->
zRem
(
self
::
SORT_KEY_CREAM
.
$site_id
,
$s_id
);
if
(
$look_num
>
3
)
{
...
...
@@ -110,13 +110,14 @@ class SquareSortService
/**
* 每个开盘最后评论时间
*
* @param $site_id
* @return array
* User HuJun
* Date 19-5-
7 下午4:38
* Date 19-5-
9 上午9:37
*/
public
function
getCommentData
()
public
function
getCommentData
(
$site_id
)
{
$comment_time
=
$this
->
redis
->
zRange
(
self
::
SORT_KEY
,
0
,
-
1
,
true
);
$comment_time
=
$this
->
redis
->
zRange
(
self
::
SORT_KEY
.
$site_id
,
0
,
-
1
,
true
);
return
$comment_time
;
}
...
...
application/model/ASite.php
View file @
10bbc3d0
...
...
@@ -94,4 +94,24 @@ class ASite extends BaseModel
return
$return
;
}
/**
* @param string $fields
* @param array $where
* @return bool|false|\PDOStatement|string|\think\Collection
* User HuJun
* Date 19-5-9 上午10:00
*/
public
function
getSiteList
(
$fields
=
'id,name,city'
,
$where
=
[])
{
if
(
!
isset
(
$where
[
'is_del'
]))
{
$where
[
'is_del'
]
=
0
;
}
try
{
$result
=
$this
->
field
(
$fields
)
->
where
(
$where
)
->
select
();
}
catch
(
\Exception
$e
)
{
$result
=
false
;
}
return
$result
;
}
}
application/task/controller/SquareTask.php
View file @
10bbc3d0
...
...
@@ -4,6 +4,7 @@
namespace
app\task\controller
;
use
app\api_broker\service\RedisCacheService
;
use
app\api_broker\service\SquareSortService
;
use
app\model\BSquare
;
use
app\model\BSquareSort
;
...
...
@@ -26,9 +27,17 @@ class SquareTask
* Date 19-5-8 上午10:09
*/
public
function
squareBackUp
()
{
$s
ave_data
=
$square_id
=
[];
$s
quare_id
=
$comment_array
=
[];
$sort_service
=
new
SquareSortService
();
$redis_service
=
new
RedisCacheService
();
$site_data
=
$redis_service
->
siteAllCityCache
();
if
(
empty
(
$site_data
))
{
Log
::
write
(
'获取城市站点失败'
,
'redis_backUp_square_task'
);
//记录日志
return
;
}
$look_num
=
$sort_service
->
getLookData
();
//看盘数量
if
(
$look_num
)
{
foreach
(
$look_num
as
$k
=>
$v
)
{
...
...
@@ -36,13 +45,29 @@ class SquareTask
}
}
$comment
=
$sort_service
->
getCommentData
();
//最后评论时间
if
(
$comment
)
{
foreach
(
$comment
as
$k
=>
$v
)
{
$square_id
[]
=
$k
;
foreach
(
$site_data
as
$k
=>
$v
)
{
$comment
=
$sort_service
->
getCommentData
(
$v
[
'id'
]);
//最后评论时间
foreach
(
$comment
as
$kk
=>
$vv
)
{
$comment_array
[
$kk
][
'time'
]
=
$vv
;
$comment_array
[
$kk
][
'site_id'
]
=
$v
[
'id'
];
$square_id
[]
=
$kk
;
}
}
$this
->
saveData
(
$square_id
,
$look_num
,
$comment_array
);
}
/**
* 保存数据
*
* @param $square_id
* @param array $look_num
* @param array $comment_array
* User HuJun
* Date 19-5-9 上午10:39
*/
private
function
saveData
(
$square_id
,
$look_num
=
[],
$comment_array
=
[])
{
if
(
empty
(
$square_id
))
{
return
;
}
...
...
@@ -51,10 +76,12 @@ class SquareTask
sort
(
$square_id
);
try
{
foreach
(
$square_id
as
$k
=>
$v
)
{
$save_data
=
[];
if
(
isset
(
$look_num
[
$v
]))
{
$save_data
[
'browse_number'
]
=
$look_num
[
$v
];
if
(
$look_num
[
$v
]
>=
500
)
{
// if ($look_num[$v] >= 500) {
if
(
$look_num
[
$v
]
>=
3
)
{
$square_data
=
$this
->
m_square
->
getSquare
(
'id,is_cream'
,[
'id'
=>
$v
]);
//是否是精华帖 0普通 1精华
if
(
$square_data
[
0
][
'is_cream'
]
==
0
)
{
...
...
@@ -62,11 +89,14 @@ class SquareTask
}
}
}
if
(
isset
(
$comment
[
$v
]))
{
$save_data
[
'last_reply_time'
]
=
date
(
'Y-m-d H:i:s'
,
$comment
[
$v
]);
if
(
isset
(
$comment_array
[
$v
]))
{
$save_data
[
'last_reply_time'
]
=
date
(
'Y-m-d H:i:s'
,
$comment_array
[
$v
][
'time'
]);
$save_data
[
'site_id'
]
=
$comment_array
[
$v
][
'site_id'
];
}
$num
=
$this
->
m_sort
->
getList
(
1
,
1
,
''
,
'id'
,[
'square_id'
=>
$v
,
'is_del'
=>
0
]);
$where
[
'square_id'
]
=
$v
;
$where
[
'is_del'
]
=
0
;
$num
=
$this
->
m_sort
->
getList
(
1
,
1
,
''
,
'id'
,
$where
);
if
(
$num
)
{
$this
->
m_sort
->
updateData
(
$save_data
,
$num
[
0
][
'id'
]);
}
else
{
...
...
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