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

39 lines
1.6 KiB
PHP

<?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 [
'=' => ['status','province','city','area','street','village','brigade'],
'%like%' => ['nick_name','real_name','phone'],
];
}
// 获取用户列表
public function lists(): array
{
$field = "id,phone,avatar,nick_name,real_name,id_card,gender,age,total_balance,total_integral,province,city,area,street,village,brigade,address,status,create_time";
return User::field($field)->where('status','<>',2)->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)->order('id desc')
->select()->each(function($item){
$item['address'] = $item->province_text.$item->city_text.$item->area_text.$item->street_text.$item->village_text.$item->brigade_text.$item->address;
$item['gender_text'] = $item->gender_text;
$item['status_text'] = $item->status_text;
unset($item['province'],$item['city'],$item['area'],$item['street'],$item['village'],$item['brigade']);
})->toArray();
}
// 获取数量
public function count(): int
{
return User::field('id')->where('status','<>',2)->where($this->searchWhere)->count();
}
}