GetKeyController.class.php
1.56 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
<?php
/**
* 根据liveId获取k
* User: zoulongbo
* Date: 2018/7/26
* Time: 14:52
*/
namespace Api\Controller\VhLiveTotal;
use Common\Common\Constant;
use Common\Common\Vhall;
use VcySDK\Exception;
class GetKeyController extends AbstractController
{
public function Index_post()
{
$params = I('post.');
$params['memUid'] = $this->uid;
if (empty($params['liveId'])) {
E('_EMPTY_LIVE_ID');
}
// 获取配置详情
$info = $this->vhall_service->get_by_conds(['vh_id' => $params['liveId']]);
// 如果当前用户为内部讲师
if (Constant::INSIDE_TEACHER_TYPE == $info['teacher_type'] && $this->uid == $info['teacher_id']) {
$params['memUid'] = 'admin';
}
try {
$data = Vhall::instance()->getKey($params);
// 兼容前端错误码
} catch (Exception $e) {
// 用户不在权限范围内
if ($e->getSdkCode() == 'OUT_OF_BUSINESS_SCOPE') {
E('_ERR_NOT_WATCHED_RANGE');
}
// 直播信息不存在或者未发布
if ($e->getSdkCode() == 'NOT_PUBLISHED' || $e->getSdkCode() == 'ERROR_LIVE_NOT_FOUNT') {
E('_ERR_LIVE_NOT_EXISTS');
}
// 直播并发信息已用完
if ($e->getSdkCode() == 'OUT_OF_BALANCE') {
E('_ERR_PLEASE_TRY_AGAIN_LATER');
}
// 返回原始错误
E($e->getMessage(), 700);
}
$this->_result = $data;
return true;
}
}