DepartmentMemberController.class.php
5.08 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/17
* Time: 23:15
*/
namespace Apicp\Controller\User;
use Common\Common\Integral;
use Common\Common\Tag;
use Common\Common\User;
use Common\Service\TagService;
use \Common\Service\UserService;
class DepartmentMemberController extends AbstractController
{
/**
* 【通讯录】部门人员列表、人员搜索
* @author liyifei
* @time 2016-09-17 23:15:42
* FIXME 需要重构 zs_anything 2017-06-21
*/
public function Index_post()
{
$role = $this->_login->role;
// 接收定义参数
$dpId = I('post.department_id', '', 'trim');
$keyword = I('post.keyword', '', 'trim');
$status = I('post.status', '', 'trim');
$active = I('post.active', '', 'trim');
$mobile = I('post.mobile', '', 'trim');
$email = I('post.email', '', 'trim');
$page = I('post.page', 1, 'intval');
$limit = I('post.limit', 30, 'intval');
$jobIds = I('post.job_ids', '', 'trim');
$roleIds = I('post.role_ids', '', 'trim');
$tagIds = I('post.tag_ids', '', 'trim');
// UC查询条件
$conds = [
'departmentChildrenFlag' => UserService::DEPT_CHILDREN_FLAG,
'memUsername' => $keyword,
'memSubscribeStatus' => $status,
'memMobile' => $mobile,
'memEmail' => $email,
'memActive' => $active
];
if (!empty($dpId)) {
$conds['dpIdList'] = (array)$dpId;
} elseif (!empty($role['readDpIdList'])) {
$conds['dpIdList'] = $role['readDpIdList'];
}
if (!empty($jobIds)) {
$conds['jobIdList'] = (array)$jobIds;
}
if (!empty($roleIds)) {
$conds['roleIdList'] = (array)$roleIds;
}
if (!empty($tagIds)) {
$conds['tagIdList'] = (array)$tagIds;
// 只查询标签下的人员
$conds['tagType'] = 1;
}
// UC排序规则(不传排序参数时,UC根据姓名全拼排序,如姓名是英文或中英文混合,则英文优先)
$orderList = [
// 'memIndex' => 'ASC',
];
$newUser = new User();
$result = $newUser->listByConds($conds, $page, $limit, $orderList);
// 整理返回值
$list = [
'page' => $result['pageNum'],
'limit' => $result['pageSize'],
'total' => $result['total'],
'status_list' => [
[
"status" => UserService::USER_STATUS_ALL,
"name" => "全部",
"user_total" => $result['amount'],
],
[
"status" => UserService::USER_STATUS_FOLLOW,
"name" => "已加入",
"user_total" => $result['alreadyConcerned'],
],
[
"status" => UserService::USER_STATUS_DISABLE,
"name" => "已禁用",
"user_total" => $result['disable'],
],
[
"status" => UserService::USER_STATUS_UNFOLLOW,
"name" => "未加入",
"user_total" => $result['notConcerned'],
],
]
];
// 获取积分列表
if (!empty($result['list'])) {
$integrals = Integral::instance()->listByUid(array_column($result['list'], 'memUid'));
} else {
$integrals = array();
}
// 获取用户获得的勋章总数
$rpcUrl = rpcUrl('/Integral/Rpc/Medal/UserMedalTotal');
$postData = [array_column($result['list'], 'memUid')];
$memMedalTotals = \Com\Rpc::phprpc($rpcUrl)->invoke('Index', $postData);
$memMedalTotals = settype($memMedalTotals, 'array');
// 返回部门成员列表
$list['list'] = array();
foreach ($result['list'] as $k => $v) {
$tags=[];
$conds['userIds'] = [$v['memUid']];
$tags = \Common\Common\Tag::instance()->listAll([], $conds);
$list['list'][$k]['uid'] = $v['memUid'];
$list['list'][$k]['face'] = $v['memFace'];
$list['list'][$k]['name'] = $v['memUsername'];
$list['list'][$k]['sex'] = $v['memGender'];
$list['list'][$k]['mobile'] = $v['memMobile'];
$list['list'][$k]['email'] = $v['memEmail'];
$list['list'][$k]['status'] = $v['memSubscribeStatus'];
$list['list'][$k]['job'] = $v['memJob'];
$list['list'][$k]['active'] = $v['memActive'];
$list['list'][$k]['dp_name'] = $v['dpName'];
$list['list'][$k]['integral'] = $integrals[$v['memUid']];
$list['list'][$k]['role_name'] = $v['memRole'];
$list['list'][$k]['medal_total'] = isset($memMedalTotals[$v['memUid']]) ? $memMedalTotals[$v['memUid']] : 0;
$list['list'][$k]['wxplugin_status'] = $v['memWxpluginStatus'];
$list['list'][$k]['tags'] = $tags ? $tags : [];
}
$this->_result = $list;
}
}