作者 开飞机的舒克

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

... ... @@ -39,13 +39,13 @@ class Bind extends Api
if (empty($unique)) {
$this->error('参数错误', ['status' => 2]);
}
$res = \db('study')->where('unique',$unique)->value('user_id');
$res = \db('study')->where(['unique'=>$unique,'user_id'=>$user['id']])->find();
if (!empty($res)){
$this->error('当前学生已经被绑定了');
}
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
if ($is_bind == 1) {
$this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
$users = db('user')->where('id', $user['id'])->find();
if ($users['bind_study'] == 1) {
$this->error('您当前已经绑定过学生了,请勿重复操作');
}
Db::startTrans();
try {
... ... @@ -55,12 +55,16 @@ class Bind extends Api
'user_id' => $user['id'],
'updatetime' => time()
]);
if ($users['is_tech'] == 0){
$update['nickname'] = $res['name']."家长";
}
$update = [
'bind_study' => 1,
'updatetime' => time()
];
\db('user')
->where('id', $user['id'])
->update([
'bind_study' => 1,
'updatetime' => time()
]);
->update($update);
Db::commit();
} catch (Exception $e) {
Db::rollback();
... ... @@ -87,13 +91,13 @@ class Bind extends Api
if (empty($unique)) {
$this->error('参数错误', ['status' => 2]);
}
$res = \db('study')->where('unique',$unique)->value('user_id');
$res = \db('study')->where(['unique'=>$unique,'user_id'=>$user['id']])->find();
if (!empty($res)){
$this->error('当前学生已经被绑定了');
}
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
if ($is_bind == 1) {
$this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
$users = db('user')->where('id', $user['id'])->find();
if ($users['bind_study'] == 1) {
$this->error('您当前已经绑定过学生了,请勿重复操作');
}
Db::startTrans();
try {
... ... @@ -103,12 +107,16 @@ class Bind extends Api
'user_id' => $user['id'],
'updatetime' => time()
]);
if ($users['is_tech'] == 0){
$update['nickname'] = $res['name']."家长";
}
$update = [
'bind_study' => 1,
'updatetime' => time()
];
\db('user')
->where('id', $user['id'])
->update([
'bind_study' => 1,
'updatetime' => time()
]);
->update($update);
Db::commit();
} catch (Exception $e) {
Db::rollback();
... ...
... ... @@ -6324,7 +6324,7 @@
</div>
<div class="col-md-6" align="right">
Generated on 2023-04-23 14:14:47 <a href="./" target="_blank">校园活动</a>
Generated on 2023-04-23 14:59:57 <a href="./" target="_blank">校园活动</a>
</div>
</div>
... ...