ParticipateService.class.php
6.09 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
/**
* 直播参与表
* @author: houyingcai
* @email: 594609175@qq.com
* @date : 2018-01-08 16:05:17
* @version $Id$
*/
namespace Common\Service;
use Common\Common\Constant;
use Common\Common\User;
use Common\Model\ParticipateModel;
class ParticipateService extends AbstractService
{
// 构造方法
public function __construct()
{
$this->_d = new ParticipateModel();
parent::__construct();
}
/**
* @desc 获取已观看人员信息
* @author houyingcai
* @param array $postData 参数数组
* @return array|bool
*/
public function getWatchedData($postData)
{
// 分页默认值
$postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE;
$postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT;
list($start, $limit) = page_limit($postData['page'], $postData['limit']);
// 条件
$conds = [
'lm_id' => $postData['lm_id'],
];
// 排序
$orderOption = ['created' => 'DESC'];
// 查询字段
$fields = 'obj_id,created,updated';
$watched_list = $this->_d->list_by_conds($conds, [$start, $limit], $orderOption, $fields);
$uids = array_column($watched_list, 'obj_id');
$userServ = &User::instance();
$user_list = $userServ->listByUid($uids);
$list = [];
foreach ($watched_list as $watch_k => $watch_v) {
// 获取用户信息
$user_info = $user_list[$watch_v['obj_id']];
// 获取被删除的用户信息
if (empty($user_info)) {
$user_info = $userServ->getByUid($watch_v['obj_id']);
}
$list[$watch_k]['memUid'] = $watch_v['obj_id'];
$list[$watch_k]['memUsername'] = $user_info['memUsername'];
$list[$watch_k]['dpName'] = $user_info['dpName'][0]['dpName'];
$list[$watch_k]['roleName'] = $user_info['memRole'];
$list[$watch_k]['tagName'] = $user_info['memTag'];
$list[$watch_k]['jobName'] = $user_info['memJob'];
$list[$watch_k]['telephone'] = $user_info['memMobile'];
$list[$watch_k]['last_watched_time'] = $watch_v['updated'] ? $watch_v['updated'] : $watch_v['created'];
}
return $list;
}
/**
* @desc 获取围观看人员信息
* @author houyingcai
* @param array $postData 参数数组
* @param array $uids_unwatch 围观看人员UID列表
* @return array
*/
public function getUnwatchData($postData, $uids_unwatch)
{
// 数组分页
$postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE;
$postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT;
list($start, $limit) = page_limit($postData['page'], $postData['limit']);
$uids = array_slice($uids_unwatch, $start, $limit);
// 查询用户信息
$userServ = &User::instance();
$user_list = $userServ->listByUid($uids);
$unwatch_list = [];
foreach ($user_list as $user_v) {
$unwatch_list[] = [
'memUid' => $user_v['memUid'],
'memUsername' => $user_v['memUsername'],
'dpName' => $user_v['dpName'][0]['dpName'],
'roleName' => $user_v['memRole'],
'tagName' => $user_v['memTag'],
'jobName' => $user_v['memJob'],
'telephone' => $user_v['memMobile'],
];
}
return $unwatch_list;
}
/**
* @desc 下载已观看人员信息
* @author caijianhua
* @param array $postData 参数数组
* @return array|bool
*/
public function DownWatchedData($postData)
{
// 条件
$conds = [
'lm_id' => $postData['lm_id'],
];
// 排序
$orderOption = ['created' => 'DESC'];
// 查询字段
$fields = 'obj_id,created,updated';
$watched_list = $this->_d->list_by_conds($conds,null, $orderOption, $fields);
$uids = array_column($watched_list, 'obj_id');
$userServ = &User::instance();
$user_list = $userServ->listByUid($uids);
$list = [];
foreach ($watched_list as $watch_k => $watch_v) {
// 获取用户信息
$user_info = $user_list[$watch_v['obj_id']];
// 获取被删除的用户信息
if (empty($user_info)) {
$user_info = $userServ->getByUid($watch_v['obj_id']);
}
$list[$watch_k]['memUid'] = $watch_v['obj_id'];
$list[$watch_k]['memUsername'] = $user_info['memUsername'];
$list[$watch_k]['dpName'] = $user_info['dpName'][0]['dpName'];
$list[$watch_k]['roleName'] = $user_info['memRole'];
$list[$watch_k]['tagName'] = $user_info['memTag'];
$list[$watch_k]['jobName'] = $user_info['memJob'];
$list[$watch_k]['telephone'] = $user_info['memMobile'];
$list[$watch_k]['last_watched_time'] = $watch_v['updated'] ? $watch_v['updated'] : $watch_v['created'];
}
return $list;
}
/**
* @desc 下载围观看人员信息
* @author caijianhua
* @param array $uids_unwatch 围观看人员UID列表
* @return array
*/
public function DownUnwatchData($uids_unwatch)
{
$uids = $uids_unwatch;
// 查询用户信息
$userServ = &User::instance();
$user_list = $userServ->listByUid($uids);
$unwatch_list = [];
foreach ($user_list as $user_v) {
$unwatch_list[] = [
'memUid' => $user_v['memUid'],
'memUsername' => $user_v['memUsername'],
'dpName' => $user_v['dpName'][0]['dpName'],
'roleName' => $user_v['memRole'],
'tagName' => $user_v['memTag'],
'jobName' => $user_v['memJob'],
'telephone' => $user_v['memMobile'],
];
}
return $unwatch_list;
}
}