2023-09-18 09:11:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\adminapi\lists\user;
|
|
|
|
|
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
|
use app\common\model\user\User;
|
|
|
|
|
|
|
|
class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
|
{
|
|
|
|
// 搜索条件
|
|
|
|
public function setSearch(): array
|
|
|
|
{
|
|
|
|
return [
|
2023-09-19 15:39:19 +08:00
|
|
|
'=' => ['status'],
|
|
|
|
'%like%' => ['nick_name','phone'],
|
2023-09-18 09:11:13 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取用户列表
|
|
|
|
public function lists(): array
|
|
|
|
{
|
2023-09-19 15:39:19 +08:00
|
|
|
$field = "id,phone,avatar,nick_name,real_name,id_card,gender,age,total_balance,total_integral,status,create_time";
|
|
|
|
$lists = User::field($field)->where($this->searchWhere)->where('status','<>',2)
|
2023-09-18 09:11:13 +08:00
|
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
|
|
->order('id desc')->select()->each(function($item){
|
2023-09-19 15:39:19 +08:00
|
|
|
$item['status_text'] = $item->status_text;
|
|
|
|
$item['gender_text'] = $item->gender_text;
|
2023-09-18 09:11:13 +08:00
|
|
|
})->toArray();
|
|
|
|
return $lists;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取数量
|
|
|
|
public function count(): int
|
|
|
|
{
|
2023-09-19 15:39:19 +08:00
|
|
|
return User::field('id')->where($this->searchWhere)->where('status','<>',2)->count();
|
2023-09-18 09:11:13 +08:00
|
|
|
}
|
|
|
|
}
|