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
9b1e12e0
Commit
9b1e12e0
authored
May 09, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis ext
parent
a7090130
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
25 deletions
+56
-25
LookShopService.php
application/api_broker/service/LookShopService.php
+44
-20
RedisExt.php
application/extra/RedisExt.php
+12
-5
No files found.
application/api_broker/service/LookShopService.php
View file @
9b1e12e0
...
...
@@ -6,6 +6,8 @@ use app\extra\RedisExt;
use
app\model\AAgents
;
use
app\model\GHousesToAgents
;
use
app\model\SystemConfig
;
use
RedisException
;
use
think\Exception
;
use
think\Log
;
/**
...
...
@@ -27,12 +29,16 @@ class LookShopService
public
function
__construct
()
{
try
{
$this
->
redis
=
RedisExt
::
getRedis
();
}
catch
(
RedisException
$exception
)
{
$this
->
redis
=
false
;
}
$this
->
redis
=
RedisExt
::
getRedis
();
$this
->
nowTime
=
date
(
"Y-m-d"
,
time
());
$this
->
nowTime
=
date
(
"Y-m-d"
,
time
());
$this
->
gHousesToAgentsModel
=
new
GHousesToAgents
();
$this
->
agentsModel
=
new
AAgents
();
$this
->
systemConfigModel
=
new
SystemConfig
();
$this
->
agentsModel
=
new
AAgents
();
$this
->
systemConfigModel
=
new
SystemConfig
();
}
...
...
@@ -49,12 +55,16 @@ class LookShopService
{
//todo 1.取读控制里面的看铺数量,2.取出此经济人已看数量和商铺 3.判断时间,每天刷新看铺数量
// todo 4.判断是否到达上限,if 上限 return false else return true
//todo 过滤掉店长以上的经纪人
$agentInfo
=
$this
->
agentsModel
->
getAgentById
(
"id,level"
,[
"agent_id"
=>
$agent_id
]);
//redis服务挂掉,都可以看
if
(
!
$this
->
redis
){
return
[];
}
//todo 过滤掉店长以上的经纪人
$agentInfo
=
$this
->
agentsModel
->
getAgentById
(
"id,level"
,
[
"agent_id"
=>
$agent_id
]);
Log
::
record
(
'info ----countLookShopNum-------'
.
json_encode
(
$agentInfo
),
"info"
);
if
(
$agentInfo
&&
$agentInfo
[
0
][
"level"
]
>
10
)
{
Log
::
record
(
'info ----countLookShopNum------123-'
,
"info"
);
if
(
$agentInfo
&&
$agentInfo
[
0
][
"level"
]
>
10
)
{
Log
::
record
(
'info ----countLookShopNum------123-'
,
"info"
);
return
[];
}
//过滤掉盘方为自己的
...
...
@@ -62,10 +72,10 @@ class LookShopService
$params
[
"agents_id"
]
=
$agent_id
;
$params
[
"type"
]
=
2
;
$params
[
"is_del"
]
=
1
;
$housesToAgents
=
$this
->
gHousesToAgentsModel
->
getHouseToAgents
(
"id"
,
$params
);
$isPanParty
=
count
(
$housesToAgents
)
>
0
?
true
:
false
;
$housesToAgents
=
$this
->
gHousesToAgentsModel
->
getHouseToAgents
(
"id"
,
$params
);
$isPanParty
=
count
(
$housesToAgents
)
>
0
?
true
:
false
;
//判断楼盘是否看过,看过了则不判断数量
$isExist
=
$this
->
isLooked
(
$agent_id
,
$house_id
);
$isExist
=
$this
->
isLooked
(
$agent_id
,
$house_id
);
$lookShopNum
=
$this
->
isLookShop
(
$agent_id
);
if
(
$lookShopNum
>
0
&&
!
$isExist
&&
!
$isPanParty
)
{
...
...
@@ -73,7 +83,7 @@ class LookShopService
$this
->
incrementLookNum
(
$agent_id
);
}
$totalNum
=
$this
->
redis
->
hGet
(
self
::
LOOK_TOTAL
.
$this
->
nowTime
,
$agent_id
);
return
[
"total_num"
=>
$totalNum
,
"residue_num"
=>
$lookShopNum
,
"isExist"
=>
$isExist
,
"isPanParty"
=>
$isPanParty
];
return
[
"total_num"
=>
$totalNum
,
"residue_num"
=>
$lookShopNum
,
"isExist"
=>
$isExist
,
"isPanParty"
=>
$isPanParty
];
}
...
...
@@ -83,11 +93,16 @@ class LookShopService
* @param int $house_id
* @return bool
*/
public
function
isLooked
(
int
$agent_id
,
int
$house_id
)
:
bool
{
public
function
isLooked
(
int
$agent_id
,
int
$house_id
)
:
bool
{
//redis服务挂掉,都可以看
if
(
!
$this
->
redis
){
return
false
;
}
$isExist
=
$this
->
redis
->
sIsMember
(
self
::
LOOK_SHOP
.
$this
->
nowTime
.
$agent_id
,
$house_id
);
if
(
$isExist
)
{
if
(
$isExist
)
{
return
true
;
}
else
{
}
else
{
return
false
;
}
}
...
...
@@ -100,7 +115,7 @@ class LookShopService
private
function
incrementLookNum
(
int
$agent_id
)
:
bool
{
$residueNum
=
(
int
)
$this
->
redis
->
hGet
(
$this
->
nowTime
,
$agent_id
);
$residueNum
+=
1
;
$residueNum
+=
1
;
Log
::
record
(
'info ----look residueNum-------'
.
$residueNum
,
"info"
);
$this
->
redis
->
hSet
(
$this
->
nowTime
,
$agent_id
,
$residueNum
);
return
true
;
...
...
@@ -116,16 +131,19 @@ class LookShopService
*/
public
function
isLookShop
(
int
$agent_id
)
:
int
{
//redis服务挂掉,不显示升级按钮 数量不能为0
if
(
!
$this
->
redis
){
return
1
;
}
$lookNum
=
50
;
//默认50看铺数量
if
(
!
$this
->
redis
->
get
(
"lookNum"
))
{
//数据库查询
$data
=
$this
->
systemConfigModel
->
getSetting
([
"config_type"
=>
40
],
"rule"
);
//数据库查询
$data
=
$this
->
systemConfigModel
->
getSetting
([
"config_type"
=>
40
],
"rule"
);
if
(
$data
&&
$data
[
"agent_shop_num"
]
>
0
)
{
$lookNum
=
$data
[
"agent_shop_num"
];
}
$this
->
redis
->
set
(
"lookNum"
,
$lookNum
);
}
else
{
}
else
{
$lookNum
=
$this
->
redis
->
get
(
"lookNum"
);
}
...
...
@@ -150,6 +168,9 @@ class LookShopService
*/
public
function
setLookNum
(
int
$num
)
:
bool
{
if
(
!
$this
->
redis
){
return
false
;
}
$this
->
redis
->
set
(
"lookNum"
,
$num
);
return
true
;
}
...
...
@@ -161,6 +182,9 @@ class LookShopService
*/
public
function
setAgentLookNum
(
int
$agent_id
)
:
bool
{
if
(
!
$this
->
redis
){
return
false
;
}
$agentNum
=
$this
->
redis
->
hGet
(
self
::
LOOK_TOTAL
.
$this
->
nowTime
,
$agent_id
);
$lookNum
=
$this
->
redis
->
get
(
"lookNum"
);
$upLookNum
=
(
int
)
$lookNum
+
(
int
)
$agentNum
;
...
...
application/extra/RedisExt.php
View file @
9b1e12e0
...
...
@@ -2,6 +2,8 @@
namespace
app\extra
;
use
RedisException
;
/**
* Created by PhpStorm.
* User : zw
...
...
@@ -28,11 +30,16 @@ class RedisExt
];
self
::
$_instance
=
new
\Redis
();
self
::
$_instance
->
connect
(
$config
[
"host"
],
$config
[
"port"
],
$config
[
"timeout"
]
);
try
{
self
::
$_instance
->
connect
(
$config
[
"host"
],
$config
[
"port"
],
$config
[
"timeout"
]
);
}
catch
(
RedisException
$exception
){
throw
new
RedisException
(
$exception
);
}
}
public
static
function
getRedis
()
...
...
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