正在显示
1 个修改的文件
包含
41 行增加
和
0 行删除
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace app\admin\controller\user; | 3 | namespace app\admin\controller\user; |
4 | 4 | ||
5 | use app\common\controller\Backend; | 5 | use app\common\controller\Backend; |
6 | +use think\Db; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * 会员管理 | 9 | * 会员管理 |
@@ -72,4 +73,44 @@ class User extends Backend | @@ -72,4 +73,44 @@ class User extends Backend | ||
72 | return parent::edit($ids); | 73 | return parent::edit($ids); |
73 | } | 74 | } |
74 | 75 | ||
76 | + /** | ||
77 | + * 删除 | ||
78 | + */ | ||
79 | + public function del($ids = "") | ||
80 | + { | ||
81 | + if ($ids) { | ||
82 | + | ||
83 | + $user_id = explode(',',$ids); | ||
84 | + Db::name('user_token')->whereIn('user_id',$user_id)->delete(); | ||
85 | + Db::name('third')->whereIn('user_id',$user_id)->delete(); | ||
86 | + $pk = $this->model->getPk(); | ||
87 | + $adminIds = $this->getDataLimitAdminIds(); | ||
88 | + if (is_array($adminIds)) { | ||
89 | + $this->model->where($this->dataLimitField, 'in', $adminIds); | ||
90 | + } | ||
91 | + $list = $this->model->where($pk, 'in', $ids)->select(); | ||
92 | + | ||
93 | + $count = 0; | ||
94 | + Db::startTrans(); | ||
95 | + try { | ||
96 | + foreach ($list as $k => $v) { | ||
97 | + $count += $v->delete(); | ||
98 | + } | ||
99 | + Db::commit(); | ||
100 | + } catch (PDOException $e) { | ||
101 | + Db::rollback(); | ||
102 | + $this->error($e->getMessage()); | ||
103 | + } catch (Exception $e) { | ||
104 | + Db::rollback(); | ||
105 | + $this->error($e->getMessage()); | ||
106 | + } | ||
107 | + if ($count) { | ||
108 | + $this->success(); | ||
109 | + } else { | ||
110 | + $this->error(__('No rows were deleted')); | ||
111 | + } | ||
112 | + } | ||
113 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
114 | + } | ||
115 | + | ||
75 | } | 116 | } |
-
请 注册 或 登录 后发表评论