89 lines
2.9 KiB
PHP
89 lines
2.9 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace app\middleapi\controller;
|
||
|
|
||
|
use app\common\enum\user\AccountLogEnum;
|
||
|
use app\common\model\user\User;
|
||
|
use app\common\model\user\UserRole;
|
||
|
use app\common\enum\user\UserTerminalEnum;
|
||
|
use think\facade\Db;
|
||
|
use app\common\controller\BaseLikeAdminController;
|
||
|
|
||
|
/***
|
||
|
* 用户控制器
|
||
|
* Class AccountLogController
|
||
|
* @package app\adminapi\controller
|
||
|
*/
|
||
|
class UserController extends BaseLikeAdminController
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
* @notes 账户流水明细
|
||
|
* @return \think\response\Json
|
||
|
* @author 段誉
|
||
|
* @date 2023/2/24 15:25
|
||
|
*/
|
||
|
public function lists()
|
||
|
{
|
||
|
if(!$this->request->isPost()){
|
||
|
return $this->fail('请求方式错误');
|
||
|
}
|
||
|
$params = $this->request->post(['page_no','page_size', 'account', 'mobile', 'company_id']);
|
||
|
$where = [];
|
||
|
if(isset($params['company_id']) && $params['company_id'] > 0){
|
||
|
$where[] = ['company_id', '=', $params['company_id']];
|
||
|
}
|
||
|
if(isset($params['account']) && $params['account'] != ''){
|
||
|
$where[] = ['account', '=', $params['account']];
|
||
|
}
|
||
|
if(isset($params['mobile']) && $params['mobile'] != ''){
|
||
|
$where[] = ['mobile', 'like', '%'.$params['mobile'].'%'];
|
||
|
}
|
||
|
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||
|
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||
|
$field = "id,id contract,sn,nickname,sex,avatar,account,mobile,channel,create_time,admin_id,company_id,street,street as street_name,is_contract";
|
||
|
$lists = User::where($where)
|
||
|
->with(['company'])
|
||
|
->page($pageNo, $pageSize)
|
||
|
->field($field)
|
||
|
->order('id desc')
|
||
|
->select()
|
||
|
->toArray();
|
||
|
foreach ($lists as &$item) {
|
||
|
$item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
|
||
|
}
|
||
|
$count = User::where($where)->count();
|
||
|
$result = [
|
||
|
'lists' => $lists,
|
||
|
'count' => $count,
|
||
|
'page_no' => $pageNo,
|
||
|
'page_size' => $pageSize
|
||
|
];
|
||
|
return $this->success('请求成功',$result);
|
||
|
}
|
||
|
|
||
|
public function roleLists()
|
||
|
{
|
||
|
if(!$this->request->isPost()){
|
||
|
return $this->fail('请求方式错误');
|
||
|
}
|
||
|
$params = $this->request->post(['page_no','page_size']);
|
||
|
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||
|
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||
|
$lists = UserRole::field(['id', 'name', 'desc', 'menu_arr', 'sort'])
|
||
|
->page($pageNo, $pageSize)
|
||
|
->order(['id' => 'desc'])
|
||
|
->select()
|
||
|
->toArray();
|
||
|
|
||
|
$count = UserRole::count();
|
||
|
$result = [
|
||
|
'lists' => $lists,
|
||
|
'count' => $count,
|
||
|
'page_no' => $pageNo,
|
||
|
'page_size' => $pageSize
|
||
|
];
|
||
|
return $this->success('请求成功',$result);
|
||
|
}
|
||
|
|
||
|
}
|