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
45eae845
Commit
45eae845
authored
Mar 20, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
全部客户3
parent
cbcbe3f7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
105 deletions
+97
-105
Client.php
application/api_broker/controller/Client.php
+60
-52
common.php
application/common.php
+33
-0
Users.php
application/model/Users.php
+4
-53
No files found.
application/api_broker/controller/Client.php
View file @
45eae845
...
...
@@ -215,6 +215,10 @@ class Client extends Basic
}
/**
* 全部客户
*/
public
function
all_user
()
{
header
(
'Access-Control-Allow-Origin:*'
);
$Two_days_ago
=
date
(
"Y-m-d h:i:s"
,
strtotime
(
"-2 day"
));
...
...
@@ -222,11 +226,11 @@ class Client extends Basic
$params
=
$this
->
params
;
#测试数据
$params
[
'phone_or_name'
]
=
'666'
;
$params
[
'pagenum'
]
=
'1'
;
$params
[
'user_id'
]
=
'10'
;
$params
[
'type'
]
=
0
;
$params
[
'search_type'
]
=
'2'
;
$params
[
'phone_or_name'
]
=
'666'
;
$params
[
'pagenum'
]
=
'1'
;
$params
[
'user_id'
]
=
'10'
;
$params
[
'type'
]
=
0
;
$params
[
'search_type'
]
=
'2'
;
#测试数据 end
if
(
!
isset
(
$params
[
'phone_or_name'
])
||
!
isset
(
$params
[
'user_id'
]))
{
...
...
@@ -234,7 +238,6 @@ class Client extends Basic
}
$phone_or_name
=
trim
(
$params
[
'phone_or_name'
]);
$pagenum
=
isset
(
$params
[
'pagenum'
])
?
$params
[
'pagenum'
]
:
1
;
$pagesize
=
15
;
...
...
@@ -242,74 +245,79 @@ class Client extends Basic
$type
=
$params
[
'type'
];
$search_type
=
$params
[
'search_type'
];
#无:'';客户电话:0;客户姓名:1;跟进:2;
if
(
$search_type
==
'0'
){
//客户电话
$user
=
new
Users
();
// 查询数据集
$user_res
=
$user
->
all_user_search_phone
(
$phone_or_name
,
$pagesize
,
$pagenum
);
//$user_res =$user->user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum);
$total
=
$user
->
all_user_search_count_phone
(
$phone_or_name
);
}
elseif
(
$search_type
==
'1'
){
//客户电话
$user
=
new
Users
();
// 查询数据集
$user_res
=
$user
->
all_user_search_name
(
$phone_or_name
,
$pagesize
,
$pagenum
);
//$user_res =$user->user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum);
$total
=
$user
->
all_user_search_count_name
(
$phone_or_name
);
}
elseif
(
$search_type
==
'2'
){
//跟进
if
(
$search_type
==
'0'
)
{
//客户电话
$params
[
'user_phone'
]
=
[
'LIKE'
,
"%
$phone_or_name
%"
];
}
elseif
(
$search_type
==
'1'
){
//客户电话
$params
[
'user_nick'
]
=
[
'LIKE'
,
"%
$phone_or_name
%"
];
}
if
(
$search_type
!=
'2'
)
{
//全部客户
// if($type == '0')
// {//求租:0 ;已租:1
// $params[''] = ['in', [1,2,3]];
// }else{//
// $params[''] = ['in', [1]];
// }
$user
=
new
Users
();
$user_res
=
$user
->
all_user
(
$params
,
$pagesize
,
$pagenum
);
$total
=
$user
->
all_user_count
(
$params
);
}
else
{
//跟进
$UPhoneFollowPp
=
new
UPhoneFollowPp
();
// 查询电话跟进数据
$user_res
=
$UPhoneFollowPp
->
all_user_search
(
$phone_or_name
,
$pagesize
,
$pagenum
);
$total
=
$UPhoneFollowPp
->
all_user_search_count
(
$phone_or_name
);
$user_res
=
$UPhoneFollowPp
->
all_user_search
(
$phone_or_name
,
$pagesize
,
$pagenum
);
$total
=
$UPhoneFollowPp
->
all_user_search_count
(
$phone_or_name
);
//dump($total);exit;
}
else
{
//全部客户
$user
=
new
Users
();
// 查询数据集
$user_res
=
$user
->
all_user
(
$pagesize
,
$pagenum
);
//$user_res =$user->user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum);
$total
=
$user
->
all_user_count
();
}
$total
=
intval
(
$total
/
$pagesize
)
+
((
$total
%
$pagesize
==
0
)
?
0
:
1
);
if
(
$search_type
!=
'2'
){
foreach
(
$user_res
as
$k
=>
$v
){
if
(
$search_type
!=
'2'
)
{
//全部客户数据处理
foreach
(
$user_res
as
$k
=>
$v
)
{
$label
=
array
();
//dump($v);exit;
$user_res
[
$k
][
'user_nick'
]
=
$v
[
'user_nick'
]
?
$v
[
'user_nick'
]
:
'未知'
;
if
(
$user_id
==
$v
[
'agent_id'
]){
$label
[]
=
'我的'
;
$user_res
[
$k
][
'user_nick'
]
=
$v
[
'user_nick'
]
?
$v
[
'user_nick'
]
:
'未知'
;
if
(
$user_id
==
$v
[
'agent_id'
])
{
$label
[]
=
'我的'
;
}
// dump($v['create_time']);
// $time=strtotime(date("Y-m-d h:i:s"))-strtotime($v['create_time']);
// dump(strtotime(date("Y-m-d h:i:s"))-strtotime($v['create_time']));//48时(h)=172800秒(s)
// exit;
if
((
strtotime
(
date
(
"Y-m-d h:i:s"
))
-
strtotime
(
$v
[
'create_time'
]))
<
172800
){
$label
[]
=
'保护期内'
;
/*dump($v['create_time']);
$time=strtotime(date("Y-m-d h:i:s"))-strtotime($v['create_time']);
dump(strtotime(date("Y-m-d h:i:s"))-strtotime($v['create_time']));//48时(h)=172800秒(s)
exit;*/
if
((
strtotime
(
date
(
"Y-m-d h:i:s"
))
-
strtotime
(
$v
[
'create_time'
]))
<
172800
)
{
$label
[]
=
'保护期内'
;
}
$user_res
[
$k
][
'label'
]
=
implode
(
','
,
$label
);
$user_res
[
$k
][
'label'
]
=
implode
(
','
,
$label
);
}
}
else
{
foreach
(
$user_res
as
$k
=>
$v
){
}
else
{
//跟进数据处理
foreach
(
$user_res
as
$k
=>
$v
)
{
$user_res
[
$k
][
'time'
]
=
tranTime
(
$v
[
'create_time'
]);
$table
=
new
Agents
();
$Agents_res
=
$table
->
Agents_res
(
$v
[
'agent_id'
]);
$Agents_res
=
$table
->
Agents_res
(
$v
[
'agent_id'
]);
//dump($Agents_res);
$user_res
[
$k
][
'agentinfo'
]
=
$Agents_res
?
$Agents_res
[
'agentshopname'
]
.
'-'
.
$Agents_res
[
'realname'
]
:
'未知'
;
$user_res
[
$k
][
'user_pic'
]
=
ADMIN_URL_TL
.
'user_header/'
.
$Agents_res
[
'head_portrait'
];
$user_res
[
$k
][
'agentinfo'
]
=
$Agents_res
?
$Agents_res
[
'agentshopname'
]
.
'-'
.
$Agents_res
[
'realname'
]
:
'未知'
;
$user_res
[
$k
][
'agentshopname'
]
=
$Agents_res
[
'agentshopname'
]
?
$Agents_res
[
'agentshopname'
]
:
''
;
$user_res
[
$k
][
'realname'
]
=
$Agents_res
[
'realname'
]
?
$Agents_res
[
'realname'
]
:
''
;
$user_res
[
$k
][
'user_pic'
]
=
ADMIN_URL_TL
.
'user_header/'
.
$Agents_res
[
'head_portrait'
];
}
}
/*dump($total);
var_dump($user_res);
exit;*/
$total
=
intval
(
$total
/
$pagesize
)
+
((
$total
%
$pagesize
==
0
)
?
0
:
1
);
if
(
$user_res
)
{
if
(
$user_res
)
{
return
$this
->
response
(
"200"
,
"success!"
,
[
'user_date'
=>
$user_res
,
'pagenum'
=>
$pagenum
,
'total'
=>
$total
,
'search_type'
=>
$search_type
]);
}
else
{
return
$this
->
response
(
"101"
,
"失败!"
);
}
return
$this
->
response
(
200
,
'all_user'
,
[
'all_user'
]);
}
...
...
application/common.php
View file @
45eae845
...
...
@@ -142,3 +142,36 @@ function checkMobileValidity($phone)
return
false
;
}
}
/**
* 时间轴 '刚刚' '昨天' '前天'
* 朱伟 2017-10-23 09:56:05
*/
function
tranTime
(
$time_inpute
)
{
$time2
=
strtotime
(
$time_inpute
);
$time
=
time
()
-
$time2
;
$rtime
=
date
(
"H点i分s秒"
,
$time2
);
if
(
$time
<
60
)
{
$str
=
'刚刚'
;
}
elseif
(
$time
<
60
*
60
)
{
$min
=
floor
(
$time
/
60
);
$str
=
$min
.
'分钟前'
;
}
// elseif ($time < 60 * 60 * 24) {
// $h = floor($time/(60*60));
// $str = $h.'小时前 ';
// }
// elseif ($time < 60 * 60 * 24 * 3) {
// $d = floor($time/(60*60*24));
// if($d==1)
// $str = '昨天 '.$rtime;
// else
// $str = '前天 '.$rtime;
// }
else
{
$str
=
date
(
"Y-m-d"
,
$time2
);
}
return
$str
;
}
application/model/Users.php
View file @
45eae845
...
...
@@ -272,74 +272,25 @@ class Users extends Model
->
find
();
}
/*public function user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum) {
$data =$this ->where('user_nick|user_phone','like',"%$phone_or_name%")
->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
->whereOr('agent_id',$user_id)
->limit($pagesize)
->page($pagenum)
->field('id as user_id,sex,user_nick,user_phone')
->select();
return $data;
}*/
public
function
all_user
(
$pagesize
,
$pagenum
)
{
return
db
(
'u_users'
)
//->where('user_nick|user_phone','like',"%$phone_or_name%")
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
->
limit
(
$pagesize
)
->
page
(
$pagenum
)
->
field
(
'id as user_id,sex,user_nick,user_phone,agent_id,create_time'
)
->
select
();
}
public
function
all_user
_count
(
)
public
function
all_user
(
$params
=
''
,
$pagesize
,
$pagenum
)
{
return
db
(
'u_users'
)
->
where
(
$params
)
//->where('user_nick|user_phone','like',"%$phone_or_name%")
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
//->field('id as user_id,sex,user_nick,user_phone,create_time')
->
count
();
}
public
function
all_user_search_phone
(
$phone
,
$pagesize
,
$pagenum
)
{
return
db
(
'u_users'
)
->
where
(
'user_phone'
,
'like'
,
"%
$phone
%"
)
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
->
limit
(
$pagesize
)
->
page
(
$pagenum
)
->
field
(
'id as user_id,sex,user_nick,user_phone,agent_id,create_time'
)
->
select
();
}
public
function
all_user_
search_count_phone
(
$phone
)
public
function
all_user_
count
(
$params
=
''
)
{
return
db
(
'u_users'
)
->
where
(
'user_nick|user_phone'
,
'like'
,
"%
$phone
%"
)
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
//->field('id as user_id,sex,user_nick,user_phone,create_time')
->
count
();
}
public
function
all_user_search_name
(
$name
,
$pagesize
,
$pagenum
)
{
return
db
(
'u_users'
)
->
where
(
'user_nick|user_phone'
,
'like'
,
"%
$name
%"
)
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
->
limit
(
$pagesize
)
->
page
(
$pagenum
)
->
field
(
'id as user_id,sex,user_nick,user_phone,agent_id,create_time'
)
->
select
();
}
public
function
all_user_search_count_name
(
$name
)
{
return
db
(
'u_users'
)
->
where
(
'user_nick|user_phone'
,
'like'
,
"%
$name
%"
)
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
//->field('id as user_id,sex,user_nick,user_phone,create_time')
->
where
(
$params
)
->
count
();
}
}
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