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
3860777b
Commit
3860777b
authored
Jan 02, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客户绑定
parent
68c53cae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
4 deletions
+119
-4
ImageDepot.php
application/index/controller/ImageDepot.php
+40
-4
UserService.php
application/index/service/UserService.php
+78
-0
Users.php
application/model/Users.php
+1
-0
No files found.
application/index/controller/ImageDepot.php
View file @
3860777b
...
@@ -177,10 +177,46 @@ class ImageDepot extends Basic
...
@@ -177,10 +177,46 @@ class ImageDepot extends Basic
public
function
ceshi
()
public
function
ceshi
()
{
{
$num
=
82.997128371823
;
$s
=
new
UserService
();
$num_ex
=
explode
(
'.'
,
$num
);
//查询
dump
(
$num_ex
);
$user_info_list
=
$s
->
userBindInfo
(
3
);
dump
(
substr
(
$num
,
0
,
-
6
));
return
$this
->
response
(
"200"
,
"成功"
,
$user_info_list
);
//新增
// $user_id = 3;
// $bind_id = 1;
// $add_res = $s->addUserBind($user_id,$bind_id);
// switch ($add_res) {
// case 1 :
// return $this->response("300", "参数不全");
// break;
// case 2 :
// return $this->response("300", "当前客户已经存在绑定关系");
// break;
// case 3 :
// return $this->response("300", "当前客户已经存在绑定关系");
// break;
// case 4 :
// return $this->response("300", "绑定客户关系数超限");
// break;
// case 5 :
// return $this->response("300", "绑定失败");
// break;
// case 0 :
// return $this->response("200", "绑定成功");
// break;
// default :
// return $this->response("300", "绑定失败");
//
// }
//解除
// $rm_res = $s->removeUserBind($user_id);
// if($rm_res == 1){
// return $this->response("200", "解绑成功");
// }else{
// return $this->response("200", "解绑失败");
// }
}
}
...
...
application/index/service/UserService.php
View file @
3860777b
...
@@ -511,4 +511,81 @@ class UserService
...
@@ -511,4 +511,81 @@ class UserService
}
}
/**
* 新增客户绑定
* @param $user_id
* @param $bind_id
* @return int
*/
public
function
addUserBind
(
$user_id
,
$bind_id
){
if
(
!
$user_id
or
!
$bind_id
){
return
1
;
}
// 先查当前用户bind_id是否等于0
$user_info
=
$this
->
user
->
getUserById
(
$field
=
'bind_id'
,
$user_id
);
if
(
$user_info
[
'bind_id'
]
!=
0
){
return
2
;
}
else
{
// 不等于0 查bind_id=当前bind_id 同时查id=bind_id
$user_bind
=
$this
->
userBindInfo
(
$user_id
);
if
(
count
(
$user_bind
)
>
0
){
return
3
;
}
$b_user_bind
=
$this
->
userBindInfo
(
$bind_id
);
if
(
count
(
$b_user_bind
)
>
5
){
return
4
;
}
//
$b_user_info
=
$this
->
user
->
getUserById
(
$field
=
'bind_id'
,
$bind_id
);
if
(
$b_user_info
[
'bind_id'
]
==
0
){
$bind_id_
=
$bind_id
;
}
else
{
$bind_id_
=
$b_user_info
[
'bind_id'
];
}
$params_
[
'bind_id'
]
=
$bind_id_
;
$res
=
$this
->
user
->
updateUsers
(
$user_id
,
$params_
);
if
(
$res
==
1
){
return
0
;
}
else
{
return
5
;
}
}
}
/**
* 解除绑定关系
* @param $user_id
* @return int|string
*/
public
function
removeUserBind
(
$user_id
){
$params_
[
'bind_id'
]
=
0
;
$res
=
$this
->
user
->
updateUsers
(
$user_id
,
$params_
);
return
$res
;
}
/**
* 客户绑定详情
* @param $user_id
* @return false|\PDOStatement|string|\think\Collection
*/
public
function
userBindInfo
(
$user_id
){
if
(
!
$user_id
){
return
''
;
}
// 先查当前用户bind_id是否等于0
$user_info
=
$this
->
user
->
getUserById
(
$field
=
'bind_id'
,
$user_id
);
$field
=
'user_name,user_phone,bind_id'
;
if
(
$user_info
[
'bind_id'
]
==
0
){
//主账号只需要查bind_id等于当前用户的ID
$where
[
'bind_id'
]
=
$user_id
;
}
else
{
// 不等于0副号 把相同bind_id的查出来 主账号查出来 同时排除当前客户
$where
[]
=
[
'EXP'
,
"(bind_id = '
{
$user_info
[
'bind_id'
]
}
' or id = '
{
$user_info
[
'bind_id'
]
}
') and id != '
{
$user_id
}
'"
];
}
$user_info_list
=
$this
->
user
->
getUserByWhere
(
$where
,
$field
);
return
$user_info_list
;
}
}
}
\ No newline at end of file
application/model/Users.php
View file @
3860777b
...
@@ -52,6 +52,7 @@ class Users extends Model
...
@@ -52,6 +52,7 @@ class Users extends Model
->
where
(
$param
)
->
where
(
$param
)
->
order
(
'create_time desc'
)
->
order
(
'create_time desc'
)
->
select
();
->
select
();
// echo $this->getLastSql();
return
$data
;
return
$data
;
}
}
...
...
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