['a1.level'], ]; } /** * @notes 搜索条件 * @author 段誉 * @date 2023/2/24 15:26 */ public function queryWhere() { $where = []; if (!empty($this->params['user_info'])) { $where[] = ['u1.sn|u1.account|u1.mobile', '=', $this->params['user_info']]; } if (!empty($this->params['parent_info'])) { $where[] = ['u2.sn|u2.account|u2.mobile', '=', $this->params['parent_info']]; } return $where; } /** * @notes 获取用户关系列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author BD * @date 2024/01/12 17:21 */ public function lists(): array { $field = 'a1.id,a1.user_id,a1.parent_id,a1.level,a1.create_time,u1.sn as u1_sn,u1.account as u1_account,u1.mobile as u1_mobile,u1.user_money as u1_user_money,u1.total_recharge as u1_total_recharge,u1.total_withdraw u1_total_withdraw,u2.sn as u2_sn,u2.account as u2_account,u2.mobile as u2_mobile'; return UserRelationAgent::alias('a1') ->join('user u1', 'u1.id = a1.user_id') ->join('user u2', 'u2.id = a1.parent_id') ->field($field) ->append(['team_top']) ->where($this->searchWhere) ->where($this->queryWhere()) ->limit($this->limitOffset, $this->limitLength) ->order(['a1.id' => 'desc']) ->select() ->toArray(); } /** * @notes 获取用户关系数量 * @return int * @author BD * @date 2024/01/12 17:21 */ public function count(): int { return UserRelationAgent::alias('a1') ->join('user u1', 'u1.id = a1.user_id') ->join('user u2', 'u2.id = a1.parent_id') ->where($this->searchWhere) ->where($this->queryWhere()) ->count(); } }