...
|
...
|
@@ -153,4 +153,47 @@ class Teacher extends Backend |
|
|
$this->view->assign("row", $row);
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
public function del($ids = "")
|
|
|
{
|
|
|
if ($ids) {
|
|
|
$pk = $this->model->getPk();
|
|
|
$adminIds = $this->getDataLimitAdminIds();
|
|
|
if (is_array($adminIds)) {
|
|
|
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
|
|
}
|
|
|
$list = $this->model->where($pk, 'in', $ids)->select();
|
|
|
|
|
|
$teacher = Db::name('teacher')
|
|
|
->where('id',$ids)
|
|
|
->find();
|
|
|
Db::name('user')->where('id',$teacher['user_id'])->update(['identity'=>1]);
|
|
|
Db::name('good')->where('teacher_id',$ids)->delete();
|
|
|
Db::name('order')->where('teacher_id',$ids)->delete();
|
|
|
|
|
|
$count = 0;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
foreach ($list as $k => $v) {
|
|
|
$count += $v->delete();
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if ($count) {
|
|
|
$this->success();
|
|
|
} else {
|
|
|
$this->error(__('No rows were deleted'));
|
|
|
}
|
|
|
}
|
|
|
$this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
}
|
|
|
} |
...
|
...
|
|