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
164f4de9
Commit
164f4de9
authored
Aug 16, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上页下页加搜索条件
parent
185d0fa3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
290 additions
and
20 deletions
+290
-20
User.php
application/api_broker/controller/User.php
+247
-16
Users.php
application/model/Users.php
+43
-4
No files found.
application/api_broker/controller/User.php
View file @
164f4de9
...
...
@@ -183,19 +183,248 @@ class User extends Basic
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
params
;
$checkResult
=
$this
->
validate
(
$params
,
"UserGetLastOrNextUserIdValidate.verifyStatus"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"300"
,
$checkResult
);
}
/*$params = array(
"user_id" => 59089,
"agent_id" => 9,
"type" =>"next",
);*/
$type
=
-
1
;
//APP状态
if
(
!
empty
(
$params
[
'activate'
])
&&
$params
[
'activate'
]
!=
-
1
)
{
if
(
$params
[
'activate'
]
==
1
)
{
$where
[
'a.status'
]
=
0
;
}
else
{
$where
[
'a.status'
]
=
-
1
;
}
}
else
{
$where
[
'a.status'
]
=
[
'<>'
,
1
];
}
$checkResult
=
$this
->
validate
(
$params
,
"UserGetLastOrNextUserIdValidate.verifyStatus"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"300"
,
$checkResult
);
//客户手机号
if
(
!
empty
(
$params
[
'phone'
]))
{
$if_search_user
=
true
;
//$where[0] = ['EXP','a.user_phone LIKE "%'.$this->params['phone'].'%" or a.user_nick LIKE "%'.$this->params['phone'].'%"'];
$where
[
'a.user_phone'
]
=
[
'LIKE'
,
'%'
.
$params
[
'phone'
]
.
'%'
];
}
if
(
!
empty
(
$params
[
'user_nick'
]))
{
$if_search_user
=
true
;
//$where[0] = ['EXP','a.user_phone LIKE "%'.$this->params['phone'].'%" or a.user_nick LIKE "%'.$this->params['phone'].'%"'];
$where
[
'a.user_name'
]
=
[
'LIKE'
,
'%'
.
$params
[
'user_nick'
]
.
'%'
];
}
//是否公客
if
(
!
empty
(
$params
[
'public_user'
])
&&
$params
[
'public_user'
]
!=
-
1
)
{
if
(
$params
[
'public_user'
]
==
1
)
{
$where
[
'a.agent_id'
]
=
0
;
}
else
{
$where
[
'a.agent_id'
]
=
[
'>'
,
0
];
}
}
//邀请人
if
(
!
empty
(
$params
[
'invite_phone'
]))
{
$where
[
'a.referrer_id'
]
=
[
'NOT NULL'
];
//覆盖上面的值
$referrer_id
=
$this
->
user
->
findUserByPhone
(
'id'
,
$params
[
'invite_phone'
]);
$where
[
'a.referrer_id'
]
=
$referrer_id
[
'id'
];
//覆盖上面的值
$where
[
'referrer_source'
]
=
10
;
$type
=
1
;
}
//创建开始时间
if
(
!
empty
(
$params
[
'start_date'
])
&&
empty
(
$params
[
'end_date'
]))
{
$where
[
'a.create_time'
]
=
[
'> time'
,
$params
[
'start_date'
]
.
'00:00:00'
];
}
elseif
(
!
empty
(
$params
[
'end_date'
])
&&
empty
(
$params
[
'start_date'
]))
{
$where
[
'a.create_time'
]
=
[
'< time'
,
$params
[
'end_date'
]
.
'23:59:59'
];
}
elseif
(
!
empty
(
$params
[
'start_date'
])
&&
!
empty
(
$params
[
'end_date'
]))
{
$where
[
'a.create_time'
]
=
[
'between time'
,
[
$params
[
'start_date'
]
.
' 00:00:00'
,
$params
[
'end_date'
]
.
' 23:59:59'
]];
}
else
{
if
(
empty
(
$params
[
'id'
])
&&
empty
(
$params
[
'phone'
]))
{
$time_
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
"-1 day"
));
$where
[
'a.create_time'
]
=
array
(
'lt'
,
$time_
);
}
}
//跟进结束时间
if
(
!
empty
(
$params
[
'follow_start'
])
&&
empty
(
$params
[
'follow_end'
]))
{
$where
[
'b.create_time'
]
=
[
'> time'
,
$params
[
'follow_start'
]
.
' 00:00:00'
];
$type
=
2
;
}
//跟进时间
if
(
!
empty
(
$params
[
'follow_end'
])
&&
empty
(
$params
[
'follow_start'
]))
{
$where
[
'b.create_time'
]
=
[
'< time'
,
$params
[
'follow_end'
]
.
' 23:59:59'
];
$type
=
2
;
}
//跟进时间
if
(
!
empty
(
$params
[
'follow_start'
])
&&
!
empty
(
$params
[
'follow_end'
]))
{
$where
[
'b.create_time'
]
=
[
'between time'
,
[
$params
[
'follow_start'
]
.
' 00:00:00'
,
$params
[
'follow_end'
]
.
' 23:59:59'
]];
$type
=
2
;
}
//客户编号
if
(
!
empty
(
$params
[
'id'
]))
{
$if_search_user
=
true
;
$where
[
'a.id'
]
=
$params
[
'id'
];
}
//是否登录过
if
(
!
empty
(
$params
[
'login_status'
])
&&
$params
[
'login_status'
]
!=
-
1
)
{
if
(
$params
[
'login_status'
]
==
1
)
{
$where
[]
=
[
'EXP'
,
'a.first_login_time IS NOT NULL OR a.last_login_time IS NOT NULL'
];
}
else
{
$where
[
'a.first_login_time'
]
=
[
'NULL'
];
}
}
//客户状态(0:求租;1:已租;-1:无效)
if
(
isset
(
$params
[
'rent_user'
])
&&
$params
[
'rent_user'
]
!=
2
)
{
$where
[
'a.user_status'
]
=
$params
[
'rent_user'
];
}
//注册时间
if
(
!
empty
(
$params
[
'registration_start'
])
&&
empty
(
$params
[
'registration_end'
]))
{
$where
[
'a.registration_time'
]
=
[
'< time'
,
$params
[
'registration_start'
]
.
' 23:59:59'
];
}
//注册时间
if
(
!
empty
(
$params
[
'registration_end'
])
&&
empty
(
$params
[
'registration_start'
]))
{
$where
[
'a.registration_time'
]
=
[
'< time'
,
$params
[
'registration_end'
]
.
' 23:59:59'
];
}
//注册时间
if
(
!
empty
(
$params
[
'registration_start'
])
&&
!
empty
(
$params
[
'registration_end'
]))
{
$where
[
'a.registration_time'
]
=
[
'between time'
,
[
$params
[
'registration_start'
]
.
' 00:00:00'
,
$params
[
'registration_end'
]
.
' 23:59:59'
]];
$type
=
2
;
}
//业态
if
(
!
empty
(
$params
[
'industry_type'
]))
{
$where
[
'a.industry_type'
]
=
$params
[
'industry_type'
];
}
//面积需求
if
(
!
empty
(
$params
[
'area_type'
]))
{
switch
(
$params
[
'area_type'
])
{
case
1
:
$where
[
'a.area_demand'
]
=
[
'<='
,
30
];
break
;
case
2
:
$where
[
'a.area_demand'
]
=
[
'between'
,
[
30
,
60
]];
break
;
case
4
:
$where
[
'a.area_demand'
]
=
[
'between'
,
[
60
,
100
]];
break
;
default
:
$where
[
'a.area_demand'
]
=
[
'>'
,
100
];
}
}
//价格需求
if
(
!
empty
(
$params
[
'price_type'
]))
{
switch
(
$params
[
'price_type'
])
{
case
1
:
$where
[
'a.price_demand'
]
=
[
'<='
,
10000
];
break
;
case
2
:
$where
[
'a.price_demand'
]
=
[
'between'
,
[
10000
,
30000
]];
break
;
default
:
$where
[
'a.price_demand'
]
=
[
'>'
,
30000
];
}
}
if
(
!
empty
(
$params
[
'invite_agent_phone'
]))
{
$type
=
4
;
$where
[
'b.phone'
]
=
$params
[
'invite_agent_phone'
];
}
/* //最后登录开始时间
if (!empty($params['login_time_start']) && empty($params['login_time_end'])) {
$where['a.last_login_time'] = ['> time',$params['last_login_time']. ' 00:00:00'];
}
//最后登录结束时间
if (!empty($params['login_time_end']) && empty($params['login_time_start'])) {
$where['a.last_login_time'] = ['< time',$params['login_time_end']. ' 23:59:59'];
}
//最后登录时间
if (!empty($params['login_time_end']) && !empty($params['login_time_start'])) {
$where['a.last_login_time'] = ['between time', [$params['login_time_start']. ' 00:00:00', $params['login_time_end']. ' 23:59:59']];
}*/
//客方门店
if
(
!
empty
(
$params
[
'store_id'
])
&&
empty
(
$params
[
'referrer_store_id'
]))
{
$where
[
'b.store_id'
]
=
$params
[
'store_id'
];
$type
=
3
;
}
//邀请人门店
if
(
!
empty
(
$params
[
'referrer_store_id'
])
&&
empty
(
$params
[
'store_id'
]))
{
$where
[
'b.store_id'
]
=
$params
[
'referrer_store_id'
];
$type
=
4
;
}
//客方部门
if
(
!
empty
(
$params
[
'district_id'
])
&&
$params
[
'district_id'
]
!=
-
1
&&
empty
(
$params
[
'referrer_district_id'
]))
{
$where
[
'b.district_id'
]
=
$params
[
'district_id'
];
$type
=
3
;
}
//邀请人部门
if
(
!
empty
(
$params
[
'referrer_district_id'
])
&&
empty
(
$params
[
'district_id'
]))
{
$where
[
'b.district_id'
]
=
$params
[
'referrer_district_id'
];
$type
=
4
;
}
//客方手机号
if
(
!
empty
(
$params
[
'user_agent'
]))
{
$where
[
'b.phone'
]
=
$params
[
'user_agent'
];
$type
=
3
;
}
if
(
!
empty
(
$params
[
'first_login_start'
]))
{
$where
[
'a.first_login_time'
]
=
$params
[
'first_login_start'
]
.
' 00:00:00'
;
}
if
(
!
empty
(
$params
[
'first_login_end'
]))
{
$where
[
'a.first_login_time'
]
=
$params
[
'first_login_end'
]
.
' 23:59:59'
;
}
if
(
!
empty
(
$params
[
'first_login_start'
])
&&
!
empty
(
$params
[
'first_login_end'
]))
{
$where
[
'a.first_login_time'
]
=
[
'between time'
,
[
$params
[
'first_login_start'
]
.
' 00:00:00'
,
$where
[
'a.first_login_time'
]
=
$params
[
'first_login_end'
]
.
' 23:59:59'
]];
}
if
(
isset
(
$params
[
'vip'
])
&&
$params
[
'vip'
]
!=
-
1
)
{
if
(
$params
[
'vip'
]
==
1
)
{
$where
[
'a.vip'
]
=
1
;
}
else
{
$where
[
'a.vip'
]
=
0
;
}
}
if
(
!
empty
(
$params
[
'province'
]))
{
$where
[
'a.province'
]
=
$params
[
'province'
];
}
if
(
!
empty
(
$params
[
'city'
]))
{
$where
[
'a.city'
]
=
$params
[
'city'
];
}
else
{
// 判断是 杭州还是上海
$where
[
'a.city'
]
=
trim
(
$this
->
city
)
?
trim
(
$this
->
city
)
:
'上海市'
;
}
// 判断是 杭州还是上海
$where
[
'city'
]
=
trim
(
$this
->
city
)
?
trim
(
$this
->
city
)
:
'上海市'
;
if
(
!
empty
(
$params
[
'disc'
]))
{
$where
[
'a.disc'
]
=
$params
[
'disc'
];
}
if
(
$params
[
'type'
]
==
'last'
)
{
$where
[
'id'
]
=
[
'gt'
,
$params
[
'user_id'
]
];
$order
=
'id asc'
;
...
...
@@ -206,27 +435,29 @@ class User extends Basic
}
$field
=
'id,user_nick,agent_id,vip,create_time'
;
$user
=
new
Users
();
$user_res
=
$user
->
getLastOrNextUserID
(
$where
,
$field
,
$limit
=
1
,
$order
);
$user_res
=
$user
->
getLastOrNextUserID
(
$where
,
$field
,
$limit
=
1
,
$order
,
$type
);
if
(
!
$user_res
)
{
return
$this
->
response
(
"201"
,
"查无数据"
,
[
'user_id'
=>
$params
[
'user_id'
]]);
}
// 判断是否vip客户,如果是 只有是当前经纪人自己的客户才能查看
//vip客户 0:否 1:是
if
((
$user_res
[
0
][
'vip'
]
==
1
)
&&
(
$user_res
[
0
][
'agent_id'
]
!=
$params
[
'agent_id'
]))
{
return
$this
->
response
(
"201"
,
"vip 非客方"
,
[
'user_id'
=>
$user_res
[
0
][
'id'
]]);
}
// 判断当天被拨打是否超过5次
$clientService
=
new
ClientService
();
if
(
!
$clientService
->
dialTotal
(
$params
[
'user_id'
]))
{
return
$this
->
response
(
"201"
,
"当天被拨打超过5次"
,
[
'user_id'
=>
$user_res
[
0
][
'id'
]]);
}
// 判断是否24小时保护期内
if
((
time
()
-
strtotime
(
$user_res
[
0
][
'create_time'
]))
<
(
60
*
60
*
24
)){
return
$this
->
response
(
"201"
,
"24小时保护期内"
,
[
'user_id'
=>
$user_res
[
0
][
'id'
]]);
//如果非客方
if
(
$user_res
[
0
][
'agent_id'
]
!=
$params
[
'agent_id'
]){
// 判断是否vip客户,如果是 只有是当前经纪人自己的客户才能查看
//vip客户 0:否 1:是
if
((
$user_res
[
0
][
'vip'
]
==
1
))
{
return
$this
->
response
(
"201"
,
"vip 非客方"
,
[
'user_id'
=>
$user_res
[
0
][
'id'
]]);
}
// 判断是否24小时保护期内
if
((
time
()
-
strtotime
(
$user_res
[
0
][
'create_time'
]))
<
(
60
*
60
*
24
)){
return
$this
->
response
(
"201"
,
"24小时保护期内"
,
[
'user_id'
=>
$user_res
[
0
][
'id'
]]);
}
}
$where
=
[];
...
...
application/model/Users.php
View file @
164f4de9
...
...
@@ -777,17 +777,56 @@ class Users extends Model
}
public
function
getLastOrNextUserID
(
$where
,
$field
,
$limit
,
$order
)
public
function
getLastOrNextUserID
(
$where
,
$field
,
$limit
,
$order
,
$type
)
{
$return
=
Db
::
name
(
$this
->
table
)
if
(
$type
==
1
)
{
$result
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
where
(
$where
)
->
order
(
$order
)
->
limit
(
$limit
)
->
select
();
}
elseif
(
$type
==
2
)
{
$result
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'u_phone_follow_up b'
,
'a.id = b.user_id'
,
'left'
)
->
where
(
$where
)
->
order
(
$order
)
->
limit
(
$limit
)
->
select
();
}
elseif
(
$type
==
3
)
{
$result
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.agent_id = b.id'
,
'left'
)
->
where
(
$where
)
->
order
(
$order
)
->
limit
(
$limit
)
->
select
();
}
elseif
(
$type
==
4
)
{
$result
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.referrer_id = b.id'
,
'left'
)
->
where
(
$where
)
->
where
(
'a.referrer_source'
,
20
)
->
order
(
$order
)
->
limit
(
$limit
)
->
select
();
}
else
{
$result
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
where
(
$where
)
->
order
(
$order
)
->
select
();
}
/*$return = Db::name($this->table)
->field($field)
->where($where)
->limit($limit)
->order($order)
->
select
();
->select();
*/
//dump($this->getLastSql());
return
$re
turn
;
return
$re
sult
;
}
public
function
getUserCityInfo
(
$id
)
...
...
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