64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\store\lists\user;
|
|
|
|
|
|
use app\store\lists\BaseAdminDataLists;
|
|
use app\common\model\user\User;
|
|
use app\common\model\user\UserShip;
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
|
class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
/**
|
|
* @notes 搜索条件
|
|
* @return array
|
|
* @author 乔峰
|
|
* @date 2022/9/22 15:50
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['id'],
|
|
'%like%' => ['mobile'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @notes 获取用户列表
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @author 乔峰
|
|
* @date 2022/9/22 15:50
|
|
*/
|
|
public function lists(): array
|
|
{
|
|
|
|
$field = "id,nickname,real_name,sex,avatar,account,mobile,now_money,user_ship,create_time";
|
|
$lists = User::where($this->searchWhere)
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->field($field)
|
|
->order('id desc')
|
|
->select()->each(function($data){
|
|
$data['sex_text'] = $data->sex_text;
|
|
$data['mobile'] = substr_replace($data['mobile'], '****', 3, 4);
|
|
$data['user_ship_name'] =$data['user_ship']==0?'一般用户':UserShip::where('id',$data['user_ship'])->value('title');
|
|
})->toArray();
|
|
return $lists;
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取数量
|
|
* @return int
|
|
* @author 乔峰
|
|
* @date 2022/9/22 15:51
|
|
*/
|
|
public function count(): int
|
|
{
|
|
return User::where($this->searchWhere)->count();
|
|
}
|
|
} |