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
99f8d964
Commit
99f8d964
authored
Sep 18, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取每月新增客户数
parent
0da62cea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
4 deletions
+48
-4
ClinchMap.php
application/index/controller/ClinchMap.php
+48
-4
No files found.
application/index/controller/ClinchMap.php
View file @
99f8d964
...
...
@@ -8,6 +8,7 @@ namespace app\index\controller;
* Date: 2019/9/17
* Time: 15:40:20
*/
use
app\extra\RedisExt
;
use
app\index\extend\Basic
;
use
app\model\GHouses
;
use
app\model\OBargainModel
;
...
...
@@ -23,6 +24,7 @@ class ClinchMap extends Basic
private
$marchInModel
;
private
$bargainModel
;
private
$partialCommission
;
private
$redis_user_prefix
;
public
function
__construct
(
$request
=
null
)
...
...
@@ -34,6 +36,7 @@ class ClinchMap extends Basic
$this
->
bargainModel
=
new
OBargainModel
();
$this
->
partialCommission
=
new
OPartialCommission
();
$this
->
redis_user_prefix
=
'clinch_map_user_add_num_'
;
//每月新增客户数 redis 前缀
}
...
...
@@ -59,6 +62,7 @@ class ClinchMap extends Basic
$result
[
"performance_info"
]
=
$this
->
getPerformanceInfo
();
$result
[
"user_month_info"
]
=
$this
->
getUserInfo
();
return
$this
->
response
(
200
,
'success'
,
$result
);
}
...
...
@@ -77,13 +81,16 @@ class ClinchMap extends Basic
/**
* 客户总数
* @param $params
* @return int
*/
public
function
getUserNum
()
public
function
getUserNum
(
$params
=
[]
)
{
$conditions
=
[];
$conditions
[
'status'
]
=
0
;
$addUserNum
=
$this
->
userModel
->
getAddUserNumForOperation
(
$conditions
);
$conditions
=
[
'status'
=>
0
];
if
(
isset
(
$params
[
'start_time'
])
&&
isset
(
$params
[
'end_time'
])){
$conditions
[
'create_time'
]
=
array
(
'between'
,
array
(
$params
[
'start_time'
]
.
" 00:00:00"
,
$params
[
'end_time'
]
.
" 23:59:59"
)
);
}
$addUserNum
=
$this
->
userModel
->
getAddUserNumForOperation
(
$conditions
);
$user_num
=
isset
(
$addUserNum
[
0
][
"num"
])
?
$addUserNum
[
0
][
"num"
]
:
0
;
return
$user_num
;
}
...
...
@@ -169,5 +176,41 @@ class ClinchMap extends Basic
return
$time_arr
;
}
/**
* 获取每月新增客户数
* @return array
*/
public
function
getUserInfo
()
{
$time_arr
=
[
date
(
'Y-m'
,
strtotime
(
'-1 month'
))
=>
[
'type'
=>
'1'
],
date
(
'Y-m'
,
strtotime
(
'-2 month'
))
=>
[
'type'
=>
'2'
],
date
(
'Y-m'
,
strtotime
(
'-3 month'
))
=>
[
'type'
=>
'3'
],
date
(
'Y-m'
,
strtotime
(
'-4 month'
))
=>
[
'type'
=>
'4'
],
date
(
'Y-m'
,
strtotime
(
'-5 month'
))
=>
[
'type'
=>
'5'
],
date
(
'Y-m'
,
strtotime
(
'-6 month'
))
=>
[
'type'
=>
'6'
],
date
(
'Y-m'
,
strtotime
(
'-7 month'
))
=>
[
'type'
=>
'7'
],
date
(
'Y-m'
,
strtotime
(
'-8 month'
))
=>
[
'type'
=>
'8'
],
date
(
'Y-m'
,
strtotime
(
'-9 month'
))
=>
[
'type'
=>
'9'
],
date
(
'Y-m'
,
strtotime
(
'-10 month'
))
=>
[
'type'
=>
'10'
]];
$redis
=
RedisExt
::
getRedis
();
foreach
(
$time_arr
as
$key
=>
$v
)
{
if
(
!
$redis
->
get
(
$this
->
redis_user_prefix
.
$key
))
{
//数据库查询
$last_num
=
$v
[
'type'
]
-
1
;
$params
=
[];
$params
[
'start_time'
]
=
date
(
'Y-m-d'
,
strtotime
(
date
(
'Y-m-01'
)
.
"-
{
$v
[
'type'
]
}
month"
));
// 计算出本月第一天再减一个月
$last_time
=
date
(
'Y-m-d'
,
strtotime
(
date
(
'Y-m-01'
)
.
"-
{
$last_num
}
month"
));
//计算出本月
$params
[
'end_time'
]
=
date
(
'Y-m-d'
,
strtotime
(
$last_time
.
' -1 day'
));
//本月第一天再减一天
$month_user_num
=
$this
->
getUserNum
(
$params
);
$redis
->
set
(
$this
->
redis_user_prefix
.
$key
,
$month_user_num
);
//商铺自动下架天数
}
else
{
$month_user_num
=
$redis
->
get
(
$this
->
redis_user_prefix
.
$key
);
}
$time_arr
[
$key
][
"user_num"
]
=
$month_user_num
;
}
return
$time_arr
;
}
}
\ 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