first commit
This commit is contained in:
109
app/adminapi/lists/user/UserRelationLists.php
Normal file
109
app/adminapi/lists/user/UserRelationLists.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\user;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\user\{UserRelation,UserRelationAgent};
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 用户关系列表
|
||||
* Class UserRelationLists
|
||||
* @package app\adminapi\listsuser
|
||||
*/
|
||||
class UserRelationLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author BD
|
||||
* @date 2024/01/12 17:21
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user