作者 开飞机的舒克

绑定学生之后更改用户昵称

@@ -39,11 +39,12 @@ class Bind extends Api @@ -39,11 +39,12 @@ class Bind extends Api
39 if (empty($unique)) { 39 if (empty($unique)) {
40 $this->error('参数错误', ['status' => 2]); 40 $this->error('参数错误', ['status' => 2]);
41 } 41 }
42 - $res = \db('study')->where(['unique'=>$unique,'user_id'=>$user['id']])->find();  
43 - if (!empty($res)){ 42 + $res = \db('study')->where(['unique'=>$unique])->find();
  43 + if (!empty($res['user_id'])){
44 $this->error('当前学生已经被绑定了'); 44 $this->error('当前学生已经被绑定了');
45 } 45 }
46 $users = db('user')->where('id', $user['id'])->find(); 46 $users = db('user')->where('id', $user['id'])->find();
  47 + //halt($users);
47 if ($users['bind_study'] == 1) { 48 if ($users['bind_study'] == 1) {
48 $this->error('您当前已经绑定过学生了,请勿重复操作'); 49 $this->error('您当前已经绑定过学生了,请勿重复操作');
49 } 50 }
@@ -55,7 +56,7 @@ class Bind extends Api @@ -55,7 +56,7 @@ class Bind extends Api
55 'user_id' => $user['id'], 56 'user_id' => $user['id'],
56 'updatetime' => time() 57 'updatetime' => time()
57 ]); 58 ]);
58 - if ($users['is_tech'] == 0){ 59 + if ($users['is_teach'] == 0){
59 $update['nickname'] = $res['name']."家长"; 60 $update['nickname'] = $res['name']."家长";
60 } 61 }
61 $update = [ 62 $update = [
@@ -91,8 +92,8 @@ class Bind extends Api @@ -91,8 +92,8 @@ class Bind extends Api
91 if (empty($unique)) { 92 if (empty($unique)) {
92 $this->error('参数错误', ['status' => 2]); 93 $this->error('参数错误', ['status' => 2]);
93 } 94 }
94 - $res = \db('study')->where(['unique'=>$unique,'user_id'=>$user['id']])->find();  
95 - if (!empty($res)){ 95 + $res = \db('study')->where(['unique'=>$unique])->find();
  96 + if (!empty($res['user_id'])){
96 $this->error('当前学生已经被绑定了'); 97 $this->error('当前学生已经被绑定了');
97 } 98 }
98 $users = db('user')->where('id', $user['id'])->find(); 99 $users = db('user')->where('id', $user['id'])->find();
@@ -107,7 +108,7 @@ class Bind extends Api @@ -107,7 +108,7 @@ class Bind extends Api
107 'user_id' => $user['id'], 108 'user_id' => $user['id'],
108 'updatetime' => time() 109 'updatetime' => time()
109 ]); 110 ]);
110 - if ($users['is_tech'] == 0){ 111 + if ($users['is_teach'] == 0){
111 $update['nickname'] = $res['name']."家长"; 112 $update['nickname'] = $res['name']."家长";
112 } 113 }
113 $update = [ 114 $update = [