AdminUsersController.php
2.2 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* 会员相关
* Author : xiaojie
* DateTime: 2018/11/30 10:06
*/
namespace app\portal\controller;
use app\portal\model\UsersModel;
use cmf\controller\AdminBaseController;
/**
* Class AdminUsersController
* @package app\portal\controller
* @adminMenuRoot(
* 'name' =>'会员相关',
* 'action' =>'default',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 30,
* 'icon' =>'th',
* 'remark' =>'会员相关'
* )
*/
class AdminUsersController extends AdminBaseController
{
/**
* 会员管理
* @adminMenu(
* 'name' => '会员管理',
* 'parent' => 'portal/AdminUsers/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '会员管理',
* 'param' => ''
* )
*/
public function index()
{
$param = $this->request->param();
$map = $this->search($param,'create_time','mobile');
$userModel = new UsersModel();
$list = $userModel
->where($map)
->order('id DESC')
->paginate(30);
$this->assign('list',$list);
$this->assign('page',$list->render());
return $this->fetch();
}
/**
* 删除
* @adminMenu(
* 'name' => '删除',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '删除',
* 'param' => ''
* )
*/
public function delete()
{
$userModel = new UsersModel();
$res = $this->del($userModel);
if($res){
$this->success('删除成功');
}
$this->error('请稍后重试');
}
/**
* 会员导出
*/
public function export()
{
$userModel = new UsersModel();
$data = $userModel
->field('id,mobile,create_time')
->select()->each(function ($item){
$item['create_time'] = date('Y-m-d',$item['create_time']);
})->toArray();
$this->exportExcel(array('序号','手机号','注册时间'), $data, '会员资料', './', true);
}
}