data_center/app/adminapi/lists/user/UserLists.php

39 lines
1.5 KiB
PHP
Raw Normal View History

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-11-17 11:44:51 +08:00
'=' => ['status','phone'],
'%like%' => ['nickname'],
2023-09-18 09:11:13 +08:00
];
}
// 获取用户列表
public function lists(): array
{
2023-11-16 09:56:15 +08:00
$field = "id,phone,avatar,nickname,realname,id_card,gender,age,total_balance,total_integral,province,city,area,street,village,brigade,address,status,create_time";
2023-09-21 15:31:01 +08:00
return User::field($field)->where('status','<>',2)->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)->order('id desc')
2023-09-20 17:15:43 +08:00
->select()->each(function($item){
2023-09-21 15:31:01 +08:00
$item['address'] = $item->province_text.$item->city_text.$item->area_text.$item->street_text.$item->village_text.$item->brigade_text.$item->address;
2023-09-20 17:15:43 +08:00
$item['gender_text'] = $item->gender_text;
$item['status_text'] = $item->status_text;
2023-09-21 15:31:01 +08:00
unset($item['province'],$item['city'],$item['area'],$item['street'],$item['village'],$item['brigade']);
2023-09-20 17:15:43 +08:00
})->toArray();
2023-09-18 09:11:13 +08:00
}
// 获取数量
public function count(): int
{
2023-09-21 15:31:01 +08:00
return User::field('id')->where('status','<>',2)->where($this->searchWhere)->count();
2023-09-18 09:11:13 +08:00
}
}