JoinListController.class.php
2.57 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
/**
*【积分抽奖-后台】已参与人员列表接口
* User: daijun
* Date: 2018/3/23
* Time: 下午3:42
*/
namespace Apicp\Controller\Activity;
use Common\Common\Constant;
use Common\Service\ActivityService;
use Common\Service\RecordService;
use Common\Service\RightService;
class JoinListController extends \Apicp\Controller\AbstractController
{
public function Index_post()
{
// 获取参数
$params = I('post.');
if (empty($params['ac_id'])) {
// 活动ID不能为空
E('_EMPTY_ACTIVITY_ID');
}
$activity_serv = new ActivityService();
$detail = $activity_serv->get($params['ac_id']);
if (empty($detail)) {
// 活动信息不存在
E('_ERR_ACTIVITY_DATA');
}
// 默认值
$page = !empty($params['page']) ? intval($params['page']) : Constant::DEFAULT_PAGE;
$limit = !empty($params['limit']) ? intval($params['limit']) : Constant::DEFAULT_LIMIT;
// 分页
list($start, $limit) = page_limit($page, $limit);
$page_option = [$start, $limit];
$record_serv = new RecordService();
// 查询参与人员总数
$total = $record_serv->count_by_where($params);
$list = [];
if ($total > 0) {
// 定义查询字段
$fields = 'lr_id,username,dp_name,mobile,role,job,remark,created';
// 查询列表数据
$list = $record_serv->list_by_where($params, $page_option, $fields);
}
$un_join_uids = [];
if (Constant::DEFAULT_PAGE == $page) {
// 如果是第一页,则需要查询未参与人员总数
$record_list = $record_serv->list_by_conds(['ac_id' => $params['ac_id']], null, [], 'uid');
// 已参与的人员uid集合
$uids = [];
if (!empty($record_list)) {
$uids = array_filter(array_unique(array_column($record_list, 'uid')));
}
// 查询权限人员集合
$right = new RightService();
$all_right_users = $right->get_uids_by_right($detail);
// 获取未参与人员uid集合
$un_join_uids = array_diff($all_right_users, $uids);
}
// 组装返回数据
$this->_result = [
'total' => intval($total),
'limit' => intval($limit),
'join_total' => intval($total),
'un_join_total' => count($un_join_uids),
'page' => intval($page),
'list' => $list
];
return true;
}
}