...
|
...
|
@@ -76,29 +76,17 @@ class OpenServerController extends HomeBaseController |
|
|
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$token&openid=$openid&lang=zh_CN";
|
|
|
$user_data = json_decode($this->http_get($url),true);
|
|
|
$user_id = $this->new_user($user_data,$openid,$options['app_id']);
|
|
|
cache('user_id',$user_id);
|
|
|
|
|
|
}else{
|
|
|
$user_id = $third_party_user['user_id'];
|
|
|
}
|
|
|
// cache('third_party_user',$third_party_user);
|
|
|
// if(!empty($third_party_user)){
|
|
|
// $user = Db::name('user')->where('id',$third_party_user['user_id'])->find();
|
|
|
// cache('user',$user);
|
|
|
// if($user['channel'] == 2){
|
|
|
// $result1 = Db::name('user')->where('id',$user['id'])->update(['admin_id'=>$admin_id,'channel'=>1]);
|
|
|
// cache('result1',$result1);
|
|
|
// }
|
|
|
// }else{
|
|
|
// //储存到推荐人推荐列表
|
|
|
// $referrer = Db::name('referrer')->where(array('openid'=>$openid))->find();
|
|
|
// cache('referrer',$referrer);
|
|
|
// if(empty($referrer)){
|
|
|
// $result = Db::name('referrer')->insert(array('admin_id'=>$admin_id,'openid'=>$openid,'create_time'=>time()));
|
|
|
// cache('result',$result);
|
|
|
//// return "推荐人关注!";
|
|
|
// }else{
|
|
|
//// return "已有推荐人!";
|
|
|
// }
|
|
|
// }
|
|
|
$new_data = [
|
|
|
'my_user_id' => $my_user_id,
|
|
|
'status_id' => $status,
|
|
|
];
|
|
|
$this->bind($user_id,$new_data);
|
|
|
return '您好,欢迎关注“学考无忧”公众号。
|
|
|
我们致力于打造一个为广大家长和同学们提升知识视野,提高学习成绩的优质服务号,这里有热门的教育资讯,海量的免费资源,优质的学习干货,会为大家提供教辅类以及课外阅读阅读书籍,帮助同学们提高学习成绩。
|
|
|
真正让家长省心,孩子无忧。感谢关注。';
|
|
|
}
|
|
|
break;
|
|
|
|
...
|
...
|
@@ -185,4 +173,118 @@ class OpenServerController extends HomeBaseController |
|
|
]);
|
|
|
return $userId;
|
|
|
}
|
|
|
|
|
|
public function bind($uid,$data_id){
|
|
|
$data_my_user = Db::name('my_user') -> where('uid',$uid) -> find();
|
|
|
if($data_my_user){
|
|
|
//用户是否为自由人 是自由人则绑定 不是自由人判断是不是老师
|
|
|
if($data_my_user['status'] == 0 || $data_my_user['status'] == 1 || $data_my_user['status'] == 5 || $data_my_user['status'] == 6){
|
|
|
//判断跳转链接是否存在数据 存在则绑定关系
|
|
|
if(!empty($data_id)){
|
|
|
//判断上级权限是否存在
|
|
|
$my_user = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
if(empty($my_user)){
|
|
|
$this->error('查无此人','','','');
|
|
|
}
|
|
|
if($my_user['status'] != $data_id['status_id']){
|
|
|
$this->error('该二维码已失效','','','');
|
|
|
}
|
|
|
//判断数据是老师还是业务员
|
|
|
if($data_id['status_id'] == 2){
|
|
|
//业务员分享 更改用户身份为老师
|
|
|
$my_user_phone = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
$data_update['status'] = 3;
|
|
|
$data_update['inviter_phone'] = $my_user_phone['phone'];
|
|
|
$data_update['is_pro'] = 1;
|
|
|
$data_update['pid'] = $my_user_phone['id'];
|
|
|
$data_update['bind_time'] = time();
|
|
|
$data_update['bind_status'] = 1;
|
|
|
Db::name('my_user') -> where('uid',$uid) -> update($data_update);
|
|
|
}elseif ($data_id['status_id'] == 3){
|
|
|
//老师分享 更改用户身份为学生
|
|
|
$my_user_phone = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
$data_update['status'] = 4;
|
|
|
$data_update['inviter_phone'] = $my_user_phone['phone'];
|
|
|
$data_update['is_pro'] = 0;
|
|
|
$data_update['pid'] = $my_user_phone['id'];
|
|
|
$data_update['bind_time'] = time();
|
|
|
$data_update['bind_status'] = 1;
|
|
|
Db::name('my_user') -> where('uid',$uid) -> update($data_update);
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
//判断跳转链接是否存在数据
|
|
|
if(!empty($data_id['status_id'])){
|
|
|
//判断上级权限是否存在
|
|
|
$my_user = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
if(empty($my_user)){
|
|
|
$this->error('查无此人','','','');
|
|
|
}
|
|
|
if($my_user['status'] != $data_id['status_id']){
|
|
|
$this->error('该二维码已失效','','','');
|
|
|
}
|
|
|
//判断用户是不是老师
|
|
|
if($data_my_user['status'] == 3){
|
|
|
//是老师则判断老师绑定状态
|
|
|
if($data_my_user['bind_status'] = 2){
|
|
|
//判断是否为业务员分享的链接
|
|
|
if($data_id['status_id'] == 2){
|
|
|
//是业务员分享则更新老师的pid
|
|
|
$my_user_phone = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
$data_update['pid'] = $my_user_phone['id'];
|
|
|
$data_update['bind_time'] = time();
|
|
|
$data_update['bind_status'] = 1;
|
|
|
Db::name('my_user') -> where('uid',$uid) -> update($data_update);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
//判断跳转链接是否存在数据 如果不存在添加一条自由人用户
|
|
|
if(!empty($data_id)){
|
|
|
//判断上级权限是否存在
|
|
|
$my_user = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
if(empty($my_user)){
|
|
|
$this->error('查无此人','','','');
|
|
|
}
|
|
|
if($my_user['status'] != $data_id['status_id']){
|
|
|
$this->error('该二维码已失效','','','');
|
|
|
}
|
|
|
//判断数据是老师还是业务员
|
|
|
if($data_id['status_id'] == 2){
|
|
|
//业务员分享 添加老师
|
|
|
$my_user_phone = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
$data_inser['status'] = 3;
|
|
|
$data_inser['uid'] = $uid;
|
|
|
$data_inser['inviter_phone'] = $my_user_phone['phone'];
|
|
|
$data_inser['create_time'] = time();
|
|
|
$data_inser['is_pro'] = 1;
|
|
|
$data_inser['pid'] = $my_user_phone['id'];
|
|
|
$data_inser['bind_time'] = time();
|
|
|
$data_inser['bind_status'] = 1;
|
|
|
Db::name('my_user') -> insert($data_inser);
|
|
|
}elseif ($data_id['status_id'] == 3){
|
|
|
//老师分享 添加学生
|
|
|
$my_user_phone = Db::name('my_user') -> where('id',$data_id['my_user_id']) -> find();
|
|
|
$data_inser['status'] = 4;
|
|
|
$data_inser['uid'] = $uid;
|
|
|
$data_inser['inviter_phone'] = $my_user_phone['phone'];
|
|
|
$data_inser['create_time'] = time();
|
|
|
$data_inser['is_pro'] = 0;
|
|
|
$data_inser['pid'] = $my_user_phone['id'];
|
|
|
$data_inser['bind_time'] = time();
|
|
|
$data_inser['bind_status'] = 1;
|
|
|
Db::name('my_user') -> insert($data_inser);
|
|
|
}
|
|
|
}else{
|
|
|
$data_inser['status'] = 0;
|
|
|
$data_inser['uid'] = $uid;
|
|
|
$data_inser['create_time'] = time();
|
|
|
$data_inser['is_pro'] = 0;
|
|
|
Db::name('my_user') -> insert($data_inser);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|