getInfo(['id' => $param['parent']], 'chain,district,depth_level,parent,grand_parent'); if ($pidInfo) { $depth_level = $pidInfo['depth_level'] + 1; $district = $pidInfo['district'] + 1; $chain = $pidInfo['chain'] . $param['manage_id'] . '#'; $grand_parent = $pidInfo['grand_parent']; } } $data = [ 'parent' => $param['parent'], 'grand_parent' => $grand_parent, 'district' => $param['district'] ?? $district, 'depth_level' => $depth_level, 'chain' => $chain, ]; return $data; } return []; } /** * 移动节点 * @param $id 移动会员iD * @param $pid 所属ID */ public function moveNode($manage_id, $pid) { } /*** * 获取上级节点 * @param $id 管理ID * @param $depth_level 层级深度 * @param $depth_group 分组 */ public function getUpUserNode($id, $field = '*', $depth_level = '', $ext_where = []) { $where[] = ['id', '=', $id]; $chain = model('manage_user')->getvalue($where, 'chain'); $uids = array_filter(explode('#', $chain)); arsort($uids); $w[] = ['id', 'in', $uids]; $w[] = ['id', '<>', $id]; $userInfo = model('manage_user')->getList($w, $field, 'depth_level desc,create_time desc'); return $userInfo; } /*** * 获取下级全部用户 * @param $id * @param string $depth_group * @param string $field * @param string $depth_level * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getUserNodeDownALL($id, $depth_group = '', $field = '*', $depth_level = '') { $where = []; if ($depth_group) { $where[] = ['depth_group', '=', $depth_group]; } if ($depth_level) { if (!is_numeric($depth_level)) { $depth_level = $this->where('id', $id)->value('depth_level') + 1; } $where[] = ['depth_level', '>', $depth_level]; } $where[] = ['id', '<>', $id]; $where[] = ['chain', 'like', "%#{$id}-%"]; $info = $this->where($where)->field($field)->select()->toArray(); return $info; } }