AdminUsersController.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Created by PhpStorm.
* User: ruidiudiu
* Date: 2018/11/20
* Time: 14:26
*/
namespace app\portal\controller;
use app\portal\model\UsersModel;
use cmf\controller\AdminBaseController;
use think\Db;
/**
* Class AdminUsersController
* @package app\portal\controller
* @adminMenuRoot(
* 'name' =>'用户管理',
* 'action' =>'index',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 30,
* 'icon' =>'th',
* 'remark' =>'用户管理'
* )
*/
class AdminUsersController extends AdminBaseController{
public function index(){
$param=$this->request->param();
$where=[];
if (!empty($param['keyword'])){
$where['phone']=['like','%'.$param['keyword'].'%'];
}
$users=new UsersModel();
$data=$users->where($where)->order('create_time','desc')->paginate(10)->each(function ($item) {
if ($item['is_use']==1){
$item['eq']=Db::name('order')
->alias('o')
->join('equipment e','o.eq_name=e.name')
->where(['o.users_id'=>$item['id'],'o.state'=>1])->find()['serial_number'];
}
$re=Db::name('order')->where(['type'=>2,'state'=>3,'users_id'=>$item['id']])->find();
if ($re){
$item['recharge']=1;
}else{
$item['recharge']=0;
}
return $item;
});
$data->appends($param);
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
$this->assign('data',$data);
return $this->fetch();
}
}