fix update openid
This commit is contained in:
parent
e83fd9594f
commit
27d6c7f889
@ -101,13 +101,19 @@ class StudentService
|
||||
$code = $request->post('code');
|
||||
$user_info = WechatSubscriptController::getCodeAccessToken($code);
|
||||
if (isset($result['code'])) {
|
||||
$message = '获取信息失败';
|
||||
throw new Exception('获取信息失败');
|
||||
}
|
||||
$openid = $user_info['openid'];
|
||||
$teacher = Student::where(['id'=>$request->student->id])->findOrEmpty();
|
||||
$teacher->save([
|
||||
|
||||
$student = Student::where(['id'=>$request->student->id])->findOrEmpty();
|
||||
if($student->openid && $student->openid != $openid){
|
||||
throw new Exception('当前账号已绑定其它学生,不能重复绑定');
|
||||
}else{
|
||||
$student->save([
|
||||
'openid' => $openid,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
|
@ -141,9 +141,13 @@ class TeacherService
|
||||
}
|
||||
$openid = $user_info['openid'];
|
||||
$teacher = Teacher::where(['id'=>$request->teacher->id])->findOrEmpty();
|
||||
if($teacher->openid && $teacher->openid != $openid){
|
||||
throw new Exception('当前账号已绑定其它教师,不能重复绑定');
|
||||
}else{
|
||||
$teacher->save([
|
||||
'openid' => $openid,
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
|
Loading…
x
Reference in New Issue
Block a user