DetailController.class.php
6.65 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
<?php
/**
* 【后台】直播活动详情接口
* Created by PhpStorm.
* User: yingcai
* Date: 2018/1/10
* Time: 上午10:58
*/
namespace Apicp\Controller\Room;
use Common\Common\Constant;
use Common\Common\User;
use Common\Service\MainService;
use Common\Service\RangeService;
use Common\Service\RoleService;
use Common\Service\StudioService;
class DetailController extends AbstractController
{
/**
* Detail
* @author houyingcai
* @desc 直播活动详情接口
* @param Int lm_id:true:1 直播活动ID
* @return array|bool 直播列表
array(
'live_status' => 1, // 直播状态(1:草稿,2:未开始,3:进行中,4:已结束)
'start_time' => 1515407868910, // 直播开始时间
'name' => '产品培训讲解', // 直播名称
'estimated_duration' => 45, // 预计时长(单位:分钟)
'live_desc' => '直播描述', // 直播描述
'pic' => 'b3ddbc502e307665f346cbd6e52cc10d', // 封面图ID
'pic_url' => 'http://qy.vchangyi.org', // 封面图片URL
'lecturer' => '王宇', // 讲师姓名
'avatar' => 'http://qy.vchangyi.org', // 讲师头像URL
'lecturer_uid' => 'B4B3BA5B7F00000173E870DA6ADFEA2A', // 讲师UID
'lecturer_title' => '金牌讲师', // 讲师头衔
'lecturer_desc' => '讲师简介', // 讲师简介
'notice_posting' => 2, // 是否推送发布消息提醒(1:推送,2:不推送)
'notice_will_start' => 0, // 直播开始前(分钟)推送消息提醒(0:不推送,大于0表示推送)
'notice_start' => 1, // 直播开始时推送消息提醒 (1: 推送 2: 不推送)
'recomend' => 1, // 移动端首页推荐 (1: 推荐 2: 不推荐)
'range' => array(
'is_all' => 1, // 是否全公司(1=是,2=否)
'dp_list' => array(// 部门
array(
'dp_id' => 'B65085507F0000017D3965FCB20CA747',// 部门ID
'dp_name' => '一飞冲天',// 部门名
),
),
'user_list' => array(// 人员
array(
'uid' => 'B4B3BA5B7F00000173E870DA6ADFEA2A',// 人员UID
'username' => '缘来素雅',// 人员姓名
'face' => 'http://shp.qpic.cn/bizmp/gdZUibR6BHrmiar6pZ6pLfRyZSVaXJicn2CsvKRdI9gccXRfP2NrDvJ8A/'// 人员头像
),
),
'job_list' => array(// 职位
array(
'job_id' => '62C316437F0000017AE8E6ACC7EFAC22',// 职位ID
'job_name' => '攻城狮',// 职位名称
),
),
'role_list' => array(// 角色
array(
'role_id' => '62C354B97F0000017AE8E6AC4FD6F429',// 角色ID
'role_name' => '国家元首',// 角色名称
),
),
'tag_list' => array(// 标签
array(
'tag_id' => '62C354B97F0000017AE8E6AC4FD6F429',// 标签ID
'tag_name' => '外贸客户',// 标签名称
),
),
),
'stream_name' => '2334_f40d273cafbd57d0be02091d7c128ecb', // 流名称
'stream_url' => 'rtmp://2334.livepush.myqcloud.com/live/', // 推流地址
'live_password' => 'abc123', // 直播密令
)
*/
public function Index_post()
{
$lmId = I('post.lm_id', 0, 'rintval');
// 直播ID不存在
if (!$lmId) {
E('_EMPTY_LIVE_ID');
}
// 获取直播信息
$mainService = new MainService();
$mainDetail = $mainService->get($lmId);
// 直播信息不存在
if (empty($mainDetail)) {
E('_ERR_LIVE_IS_NOT_EXIST');
}
// 格式化直播状态
$live_status = $mainService->live_status($mainDetail['live_status'], $mainDetail['start_time']);
// 获取讲师信息
$roleService = new RoleService();
$roleInfo = $roleService->get_by_conds([
'lm_id' => $lmId,
]);
if ($roleInfo['type'] == Constant::LIVE_ROLE_TYPE_DEFAULT) {
$lecturer = $roleInfo['obj_id'];
// 系统管理员没有头像
$avatar = '';
$roleInfo['obj_id'] = '';
} else {
// 获取讲师个人信息
$userService = &User::instance();
$lecturerInfo = $userService->getByUid($roleInfo['obj_id']);
$lecturer = $lecturerInfo['memUsername'];
$avatar = $userService->avatar($roleInfo['obj_id'], $lecturerInfo);
}
// 获取权限范围
$rangeServ = new RangeService();
$range = $rangeServ->getData(['lm_id' => $lmId]);
// 获取直播推流信息
$studioServ = new StudioService();
$studio = $studioServ->get_by_conds(['lm_id' => $lmId]);
// 返回数据
$this->_result = [
'live_status' => intval($live_status),
'start_time' => $mainDetail['start_time'],
'name' => $mainDetail['name'],
'estimated_duration' => $mainDetail['estimated_duration'],
'live_desc' => $mainDetail['desc'],
'pic' => $mainDetail['pic'],
'pic_url' => $mainService->formatCover($mainDetail['pic']),
'lecturer' => $lecturer,
'avatar' => $avatar,
'lecturer_uid' => $roleInfo['obj_id'],
'lecturer_title' => $roleInfo['title'],
'lecturer_desc' => $roleInfo['desc'],
'notice_posting' => intval($mainDetail['notice_posting']),
'notice_will_start' => intval($mainDetail['notice_will_start']),
'notice_start' => intval($mainDetail['notice_start']),
'recomend' => intval($mainDetail['recomend']),
'range' => $range,
'stream_name' => (string)$studio['stream_name'],
'stream_url' => (string)$studio['stream_url'],
'live_password' => $roleInfo['password'],
];
return true;
}
}