|
|
@@ -32,15 +32,24 @@ class UserServer
|
|
|
/**
|
|
|
* 微信登陆
|
|
|
* @param $wx_info
|
|
|
+ * @param $invite_code
|
|
|
* @return array|false
|
|
|
*/
|
|
|
- function setWxOpen($wx_info){
|
|
|
+ function setWxOpen($wx_info,$invite_code){
|
|
|
//检查这个微信openid是否存在
|
|
|
$user = WxUser::where('openid',$wx_info['openid'])->select(['id','openid','invite_code'])->first();
|
|
|
if(!$user){//不存在就创建信息
|
|
|
+ //查找推广者
|
|
|
+ if ($invite_code){
|
|
|
+ $p_id = WxUser::where('invite_code', $invite_code)->value('id');
|
|
|
+ }else{
|
|
|
+ $p_id = 0;//找不到推广上级就为0既是上级为平台
|
|
|
+ }
|
|
|
+
|
|
|
$invite_code = $this->randString();
|
|
|
$member_info['invite_code'] = $invite_code;
|
|
|
$member_info['openid'] = $wx_info['openid'];
|
|
|
+ $member_info['p_id'] = $p_id;
|
|
|
|
|
|
$member_info = WxUser::create($member_info);
|
|
|
if (empty($member_info)) {
|