Sfoglia il codice sorgente

Merge branch 'dev' into dev-sxb

sunxbiao 11 mesi fa
parent
commit
31d106a964

+ 23 - 6
app/common/repositories/user/UserRepository.php

@@ -879,9 +879,20 @@ class UserRepository extends BaseRepository
879
 
879
 
880
     public function changeProFormGroup($id)
880
     public function changeProFormGroup($id)
881
     {
881
     {
882
-        return Elm::createForm(Route::buildUrl('systemUserChangeusergroupPro', compact('id'))->build(), [
883
-            Elm::input('group_id', '新的用户身份')->required()->placeholder("请填写新的用户身份")
884
-        ],[Elm::input('mark', '备注')->placeholder("请填写备注信息")])->setTitle('修改用户身份');
882
+        $userGroup = Db::name('user')->where('uid', $id)->where('is_del', '=', 0)->value('user_group');
883
+        $identityList = Db::name('user_identity')->field('user_group_name label,user_group_id value')->select()->toArray();
884
+        $oldIdentity = [];
885
+        foreach ($identityList as $item) {
886
+            if ($item['value'] == $userGroup) {
887
+                $oldIdentity = $item;
888
+                break;
889
+            }
890
+        }
891
+        return Elm::createForm(Route::buildUrl('systemUserChangeGroupPro', compact('id'))->build(), [
892
+            Elm::select('old_identity_id', '当前用户身份')->options([$oldIdentity])->value($oldIdentity['value'])->disabled(true),
893
+            Elm::select('new_identity_id', '新的用户身份')->options($identityList),
894
+            Elm::textarea('mark', '备注', '')->required()->placeholder('请填写备注信息')
895
+        ])->setTitle('修改用户身份');
885
     }
896
     }
886
 
897
 
887
     /**
898
     /**
@@ -3157,11 +3168,17 @@ class UserRepository extends BaseRepository
3157
 
3168
 
3158
     }
3169
     }
3159
 
3170
 
3160
-    public function update_user_group($id,$group_id,$adminid,$mark)
3171
+    public function update_user_group($id, $old_identity_id, $new_identity_id, $adminid, $mark)
3161
     {
3172
     {
3162
         try {
3173
         try {
3163
-            Db::name("user_group_record")->insert(['adminid' => $adminid,'uid' => $id,'mark' => $mark]);
3164
-            return Db::name("user")->where("uid", $id)->update(['user_group' => $group_id]);
3174
+            Db::name("user_identity_change_records")->insert([
3175
+                'operation_id' => $adminid,
3176
+                'uid' => $id,
3177
+                'old_identity_id' => $old_identity_id,
3178
+                'new_identity_id' => $new_identity_id,
3179
+                'mark' => $mark
3180
+            ]);
3181
+            return Db::name("user")->where("uid", $id)->update(['user_group' => $new_identity_id]);
3165
         } catch (\Exception $e) {
3182
         } catch (\Exception $e) {
3166
             return false;
3183
             return false;
3167
         }
3184
         }

+ 11 - 5
app/controller/admin/user/User.php

@@ -53,7 +53,6 @@ class User extends BaseController
53
      * @var UserRepository
53
      * @var UserRepository
54
      */
54
      */
55
     protected $repository;
55
     protected $repository;
56
-    private $request;
57
 
56
 
58
     /**
57
     /**
59
      * User constructor.
58
      * User constructor.
@@ -866,17 +865,18 @@ class User extends BaseController
866
         if (!$this->repository->exists($id))
865
         if (!$this->repository->exists($id))
867
             return app('json')->fail('数据不存在');
866
             return app('json')->fail('数据不存在');
868
         $formData = formToData($this->repository->changeProFormGroup($id));
867
         $formData = formToData($this->repository->changeProFormGroup($id));
869
-        return app('json')->success(array_merge($formData));
868
+        return app('json')->success($formData);
870
     }
869
     }
871
     public function changeProGroup($id,UserRepository $repository)
870
     public function changeProGroup($id,UserRepository $repository)
872
     {
871
     {
873
-        $group_id = $this->request->param('group_id');
874
         $adminid = $this->request->adminId();
872
         $adminid = $this->request->adminId();
873
+        $old_identity_id = $this->request->param('old_identity_id');
874
+        $new_identity_id = $this->request->param('new_identity_id');
875
         $mark = $this->request->param('mark');
875
         $mark = $this->request->param('mark');
876
-        if (!$id) {
876
+        if (empty($id) || empty($old_identity_id) || empty($new_identity_id)) {
877
             return app('json')->fail("参数丢失");
877
             return app('json')->fail("参数丢失");
878
         }
878
         }
879
-        if ($repository->update_user_group($id, $group_id,$adminid,$mark)) {
879
+        if ($repository->update_user_group($id, $old_identity_id, $new_identity_id, $adminid, $mark)) {
880
             return app('json')->success("修改成功");
880
             return app('json')->success("修改成功");
881
         } else {
881
         } else {
882
             return app('json')->fail("失败");
882
             return app('json')->fail("失败");
@@ -2026,5 +2026,11 @@ class User extends BaseController
2026
             ->toArray();
2026
             ->toArray();
2027
         return app('json')->success($records, '获取成功');
2027
         return app('json')->success($records, '获取成功');
2028
     }
2028
     }
2029
+    /**
2030
+     * 查询用户上下级
2031
+     */
2032
+    public function getusersxj(){
2033
+
2034
+    }
2029
 
2035
 
2030
 }
2036
 }