Sfoglia il codice sorgente

增加节点人修改功能

sunxiaobiao 1 anno fa
parent
commit
3bb4f68b16

+ 28 - 0
app/common/repositories/user/UserRepository.php

@@ -834,6 +834,20 @@ class UserRepository extends BaseRepository
834
      * @author xaboy
834
      * @author xaboy
835
      * @day 2020-05-07
835
      * @day 2020-05-07
836
      */
836
      */
837
+    public function changeProFormLevel($id)
838
+    {
839
+        return Elm::createForm(Route::buildUrl('systemMerchantChangeProLevel', compact('id'))->build(), [
840
+            Elm::input('level_account', '节点人(上级)')->required()->placeholder("请填写节点人(上级)手机号")
841
+        ])->setTitle('修改用户节点人(上级)');
842
+    }
843
+
844
+    /**
845
+     * @param $id
846
+     * @return Form
847
+     * @throws FormBuilderException
848
+     * @author xaboy
849
+     * @day 2020-05-07
850
+     */
837
     public function changeAwardForm($id)
851
     public function changeAwardForm($id)
838
     {
852
     {
839
         $user = $this->dao->get($id);
853
         $user = $this->dao->get($id);
@@ -3024,6 +3038,20 @@ class UserRepository extends BaseRepository
3024
 
3038
 
3025
     }
3039
     }
3026
 
3040
 
3041
+    public function update_level_uid($uid, $level_account){
3042
+        $level = Db::name("user")->where('account',$level_account)->field("uid")->find();
3043
+        if($level){
3044
+            try{
3045
+                return Db::name("user")->where(["uid"=>$uid])->update(['level_id'=>$level['uid']]);
3046
+            }catch (\Exception $e) {
3047
+                return false;
3048
+            }
3049
+        }else{
3050
+            return false;
3051
+        }
3052
+
3053
+    }
3054
+
3027
 
3055
 
3028
     /*获取协议列表*/
3056
     /*获取协议列表*/
3029
     public function getXieYi(){
3057
     public function getXieYi(){

+ 32 - 0
app/controller/admin/user/User.php

@@ -812,6 +812,38 @@ class User extends BaseController
812
     }
812
     }
813
 
813
 
814
     /**
814
     /**
815
+     * @param $id
816
+     * @return mixed
817
+     * @throws FormBuilderException
818
+     * @author xaboy
819
+     * @day 2020-05-07
820
+     */
821
+    public function changeProLevelForm($id)
822
+    {
823
+        if (!$this->repository->exists($id))
824
+            return app('json')->fail('数据不存在');
825
+        return app('json')->success(formToData($this->repository->changeProFormLevel($id)));
826
+    }
827
+
828
+    /*
829
+     * 更改用户节点人信息
830
+     * cabbage
831
+     * 2020-11-04
832
+     * */
833
+    public function changeProLevel($id,UserRepository $repository)
834
+    {
835
+        $level_account = $this->request->param('level_account');
836
+        if (!$level_account || !$id){
837
+            return app('json')->fail('参数丢失');
838
+        }
839
+        if($repository->update_level_uid($id,$level_account)){
840
+            return app('json')->success("修改成功");
841
+        }else{
842
+            return app('json')->fail("失败");
843
+        }
844
+    }
845
+
846
+    /**
815
      * 修改用户奖励表单
847
      * 修改用户奖励表单
816
      * @param $id
848
      * @param $id
817
      * @return mixed
849
      * @return mixed

+ 3 - 0
route/admin.php

@@ -283,6 +283,9 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
283
             //修改用户推广人
283
             //修改用户推广人
284
             Route::get('change_pro/form/:id', '.Merchant/changeProForm')->name('systemMerchantChangeProForm');
284
             Route::get('change_pro/form/:id', '.Merchant/changeProForm')->name('systemMerchantChangeProForm');
285
             Route::post('change_pro/:id', '.Merchant/changePro')->name('systemMerchantChangePro');
285
             Route::post('change_pro/:id', '.Merchant/changePro')->name('systemMerchantChangePro');
286
+            //修改用户节点人(上级)
287
+            Route::get('change_pro_level/form/:id', '.Merchant/changeProLevelForm')->name('systemMerchantChangeProLevelForm');
288
+            Route::post('change_pro_level/:id', '.Merchant/changeProLevel')->name('systemMerchantChangeProLevel');
286
 
289
 
287
             Route::post('update_dc','.Merchant/update_dc') -> name('systemMerchantUpdateDc');
290
             Route::post('update_dc','.Merchant/update_dc') -> name('systemMerchantUpdateDc');
288
             Route::post('update_level','.Merchant/update_level') -> name('systemMerchantUpdateLevel');
291
             Route::post('update_level','.Merchant/update_level') -> name('systemMerchantUpdateLevel');