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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
31 deletions
+90
-31
Register.php
application/api/controller/Register.php
+46
-21
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
+11
-3
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
...
...
@@ -38,13 +38,13 @@ class Register extends Basic
{
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
params
;
/* $params = array(
"phone" => "13817616471",
"device_id" => "86280603569236"
);*/
if
(
!
isset
(
$params
[
"phone"
]))
{
return
$this
->
response
(
"101"
,
"手机号为必填字段"
);
}
/* $params = array(
"phone" => "13817616471",
"device_id" => "86280603569236"
);*/
if
(
!
isset
(
$params
[
"phone"
]))
{
return
$this
->
response
(
"101"
,
"手机号为必填字段"
);
}
$checkResult
=
$this
->
validate
(
$params
,
"RegisterValidate.verify"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
...
...
@@ -65,15 +65,15 @@ class Register extends Basic
public
function
registerVerify
()
{
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
params
;
/* $params = array(
"phone" => "16617616471",
"device_id" => "1111",
"code" => 1231,
"wx_union_id" => "oNOSMwfDsUAXGdq0B-NzNYSep_xw", //false
"referrer_id" => 1, //邀请人id 经纪人or客户 也用于判断是否是分享出去的请求
"referrer_source" => 20, //false
);*/
$params
=
$this
->
params
;
/* $params = array(
"phone" => "16617616471",
"device_id" => "1111",
"code" => 1231,
"wx_union_id" => "oNOSMwfDsUAXGdq0B-NzNYSep_xw", //false
"referrer_id" => 1, //邀请人id 经纪人or客户 也用于判断是否是分享出去的请求
"referrer_source" => 20, //false
);*/
$checkResult
=
$this
->
validate
(
$params
,
"RegisterValidate.register"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$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,13 +14,19 @@ 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'
,
'phone'
=>
[
'regex'
=>
'/^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(16[0-9])|(17[0-9])|(19[0-9]))\\d{8}$/i'
],
'phone'
=>
[
'regex'
=>
'/^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(16[0-9])|(17[0-9])|(19[0-9]))\\d{8}$/i'
],
];
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'
=>
'手机号格式不正确'
,
...
...
@@ -30,7 +36,8 @@ class RegisterValidate extends Validate
];
protected
$scene
=
[
'verify'
=>
[
'phone'
,
'device_id'
],
'register'
=>
[
'phone'
,
'device_id'
,
'code'
],
'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