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
0f49ef43
Commit
0f49ef43
authored
Jun 22, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解绑微信
parent
3fd3f224
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
14 deletions
+73
-14
Register.php
application/api/controller/Register.php
+32
-7
WxSdk.php
application/api/controller/WxSdk.php
+4
-1
RegisterService.php
application/api/service/RegisterService.php
+13
-1
RegisterValidate.php
application/api/validate/RegisterValidate.php
+8
-0
Users.php
application/model/Users.php
+15
-5
route.php
application/route.php
+1
-0
No files found.
application/api/controller/Register.php
View file @
0f49ef43
...
...
@@ -42,8 +42,8 @@ class Register extends Basic
"phone" => "13817616471",
"device_id" => "86280603569236"
);*/
if
(
!
isset
(
$params
[
"phone"
]))
{
return
$this
->
response
(
"101"
,
"手机号为必填字段"
);
if
(
!
isset
(
$params
[
"phone"
]))
{
return
$this
->
response
(
"101"
,
"手机号为必填字段"
);
}
$checkResult
=
$this
->
validate
(
$params
,
"RegisterValidate.verify"
);
if
(
true
!==
$checkResult
)
{
...
...
@@ -88,12 +88,36 @@ class Register extends Basic
$referrer_source
=
!
empty
(
$params
[
"referrer_source"
])
?
$params
[
"referrer_source"
]
:
0
;
$last_login_ip
=
ip2long
(
$this
->
request
->
ip
());
$msg
=
$this
->
service_
->
userRegister
(
$phone
,
$referrer_id
,
$referrer_source
,
$wx_union_id
,
$last_login_ip
);
if
(
$msg
[
"code"
]
==
101
){
return
$this
->
response
(
"101"
,
$msg
[
"data"
]);
}
else
{
return
$this
->
response
(
"200"
,
"request success"
,
$msg
[
"data"
]);
$msg
=
$this
->
service_
->
userRegister
(
$phone
,
$referrer_id
,
$referrer_source
,
$wx_union_id
,
$last_login_ip
);
if
(
$msg
[
"code"
]
==
101
)
{
return
$this
->
response
(
"101"
,
$msg
[
"data"
]);
}
else
{
return
$this
->
response
(
"200"
,
"request success"
,
$msg
[
"data"
]);
}
}
/**
* 解绑微信
* @return \think\Response
*/
public
function
removeBinding
()
{
$params
=
$this
->
params
;
/* $params = array(
"buyer_id" => 1,
"user_id" => 12,
);*/
$checkResult
=
$this
->
validate
(
$params
,
"RegisterValidate.removeBind"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$is_up
=
$this
->
service_
->
unbundling
(
$params
[
"buyer_id"
],
$params
[
"user_id"
]);
if
(
$is_up
>
0
)
{
return
$this
->
response
(
"200"
,
"解绑成功"
);
}
else
{
return
$this
->
response
(
"101"
,
"解绑失败"
);
}
}
}
\ No newline at end of file
application/api/controller/WxSdk.php
View file @
0f49ef43
...
...
@@ -52,6 +52,7 @@ class WxSdk extends Basic
}
$wx_union_id
=
$params
[
"wx_union_id"
];
$buyer_nick
=
$params
[
"buyer_nick"
];
// 验证open_id是否已经存在,存在则更新
$wxInfoObj
=
$this
->
wxInfoModel
->
getWxInfoByOpenId
(
$wx_union_id
);
...
...
@@ -84,11 +85,13 @@ class WxSdk extends Basic
$data
[
"id"
]
=
$user_id
;
$data
[
"user_nick"
]
=
$user_nick
;
$data
[
"buyer_id"
]
=
$id
;
$data
[
"buyer_nick"
]
=
$buyer_nick
;
$data
[
"user_phone"
]
=
$user_phone
;
$data
[
"user_pic"
]
=
!
empty
(
$user_pic
)
?
HEADERIMGURL
.
$user_pic
:
$other_pic
;
$data
[
"AuthToken"
]
=
$jwt
->
createToken
(
$jwt_data
);;
return
$this
->
response
(
"200"
,
"request success"
,
$data
);
return
$this
->
response
(
"200"
,
"request success"
,
$data
);
}
elseif
(
$id
>
0
&&
count
(
$user_info
)
<=
0
)
{
return
$this
->
response
(
"200"
,
"request success"
);
}
else
{
...
...
application/api/service/RegisterService.php
View file @
0f49ef43
...
...
@@ -97,7 +97,7 @@ class RegisterService
}
//todo 此处有个关系,解绑上一个的id
$this
->
userModel
->
unbundlingWx
(
$buyer_id
);
$this
->
userModel
->
unbundlingWx
(
[
"buyer_id"
=>
$buyer_id
]
);
$userArr
=
$this
->
userBin
(
$user_nick
,
$sex
,
$id
,
$buyer_id
,
$status
,
$agent_id
,
$phone
,
$referrer_id
,
$referrer_source
,
$last_login_ip
,
$other_pic
);
...
...
@@ -124,6 +124,18 @@ class RegisterService
}
/**
* @param $buyer_id
* @param $user_id
* @return int
*/
public
function
unbundling
(
$buyer_id
,
$user_id
)
{
$params
[
"buyer_id"
]
=
$buyer_id
;
$params
[
"user_id"
]
=
$user_id
;
return
$this
->
userModel
->
unbundlingWx
(
$params
);
}
/**
* 组装bin
* @param $user_nick
...
...
application/api/validate/RegisterValidate.php
View file @
0f49ef43
...
...
@@ -14,6 +14,8 @@ use think\Validate;
class
RegisterValidate
extends
Validate
{
protected
$rule
=
[
'user_id'
=>
'require|number'
,
'buyer_id'
=>
'require|number'
,
'wx_union_id'
=>
'require|length:10,50'
,
'code'
=>
'require|number'
,
'device_id'
=>
'require'
,
...
...
@@ -21,6 +23,10 @@ class RegisterValidate extends Validate
];
protected
$message
=
[
'user_id.require'
=>
'user_id为必填字段'
,
'user_id.number'
=>
'user_id只能为数字'
,
'buyer_id.require'
=>
'buyer_id为必填字段'
,
'buyer_id.number'
=>
'buyer_id只能为数字'
,
'wx_union_id.require'
=>
'微信union_id不能为空'
,
'wx_union_id.length:10,50'
=>
'微信union_id错误'
,
'phone.regex'
=>
'手机号格式不正确'
,
...
...
@@ -32,5 +38,6 @@ class RegisterValidate extends Validate
protected
$scene
=
[
'verify'
=>
[
'phone'
,
'device_id'
],
'register'
=>
[
'phone'
,
'device_id'
,
'code'
],
'removeBind'
=>
[
'user_id'
,
'buyer_id'
],
];
}
\ No newline at end of file
application/model/Users.php
View file @
0f49ef43
...
...
@@ -60,7 +60,7 @@ class Users extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getUserForInviteList
(
$pageNo
,
$pageSize
,
$param
,
$fields
=
'id,user_phone'
)
public
function
getUserForInviteList
(
$pageNo
,
$pageSize
,
$param
,
$fields
=
'id,user_phone'
)
{
$data
=
$this
->
field
(
$fields
)
...
...
@@ -453,7 +453,7 @@ class Users extends Model
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public
function
getAddUserList
(
$params
,
$field
,
$page_no
,
$page_size
)
public
function
getAddUserList
(
$params
,
$field
,
$page_no
,
$page_size
)
{
$where_
=
[];
if
(
isset
(
$params
[
"agent_id"
]))
{
...
...
@@ -647,12 +647,22 @@ class Users extends Model
}
/**
* @param $
buyer_id
* @param $
params
* @return int
*/
public
function
unbundlingWx
(
$
buyer_id
)
public
function
unbundlingWx
(
$
params
)
{
return
$this
->
where
(
"buyer_id"
,
$buyer_id
)
->
setField
(
"buyer_id"
,
0
);
$where_
=
[];
if
(
!
isset
(
$params
[
"buyer_id"
]))
{
$where_
[
"buyer_id"
]
=
$params
[
"buyer_id"
];
}
else
{
//防止传入错误参数修改掉大面积数据此字段必填
return
0
;
}
if
(
!
isset
(
$params
[
"user_id"
]))
{
$where_
[
"id"
]
=
$params
[
"user_id"
];
}
return
$this
->
where
(
$where_
)
->
setField
(
"buyer_id"
,
0
);
}
}
application/route.php
View file @
0f49ef43
...
...
@@ -320,6 +320,7 @@ Route::group('api', [
'sendCode'
=>
[
'api/Register/registerSendCode'
,
[
'method'
=>
'POST'
]
],
'userVerify'
=>
[
'api/Register/registerVerify'
,
[
'method'
=>
'POST'
]
],
'removeBind'
=>
[
'api/Register/removeBinding'
,
[
'method'
=>
'POST'
]
],
]);
...
...
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