Browse Source

会员代理

afa 1 year ago
parent
commit
05949aa97b
1 changed files with 14 additions and 1 deletions
  1. 14 1
      application/admin/controller/user/User.php

+ 14 - 1
application/admin/controller/user/User.php

@@ -283,6 +283,16 @@ class User extends Backend
             }else{
                 unset($params['fund_pwd']);
             }
+
+            //修改代理
+            if($row->agent_id !=$params['agent_id'] && empty($row->is_agent)) {
+
+                //伞下不是代理/代理是他的
+                $this->model->where('id','IN', UsersPath::where('parent_id', $ids)->column('user_id'))
+                ->where('is_agent', 0)
+                ->update(['agent_id'=>$params['agent_id']]);
+            }
+          
             $result = $row->allowField(true)->save($params);
             Db::commit();
         } catch (ValidateException|PDOException|Exception $e) {
@@ -365,7 +375,10 @@ class User extends Backend
             if($key == 'is_agent'){
                 //默认开启:设置伞下当前会员所属代理id    
                 $map['agent_id'] = $values[$key] == 0? $row->agent_id: $ids;
-                $this->model->where('id','IN', UsersPath::where('parent_id', $ids)->column('user_id'))->update($map);
+                //伞下/代理是自己, 是agent_id = 自己user_id吗
+                $this->model->where('id','IN', UsersPath::where('parent_id', $ids)->column('user_id'))
+                ->where('is_agent', 0)
+                ->update($map);
             }
             $count = $row->allowField(true)->isUpdate(true)->save($values);
             Db::commit();