PushVhMsgController.class.php
2.32 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
<?php
/**
* 微吼直播活动消息回调通知
*/
namespace Frontend\Controller\Callback;
use Common\Common\Vhall;
use Common\Model\CronModel;
use Common\Service\MainService;
use Common\Service\RangeService;
use Common\Service\VhallService;
use Common\Service\VhMsgLogService;
use Think\Log;
class PushVhMsgController extends AbstractController
{
public function __construct()
{
parent::__construct();
}
public function Index()
{
if (empty($this->callBackData) || !isset($this->callBackData['type']) || !isset($this->callBackData['lm_id'])) {
exit('SUCCESS');
}
Log::write('欢迎进入定时任务-------------' . print_r($this->callBackData, true));
// 获取直播活动数据
$uc_info = Vhall::instance()->details($this->callBackData['lm_id']);
if (empty($uc_info)) {
exit('SUCCESS');
}
Log::write('欢迎进入定时任务详情-------------' . print_r($uc_info, true));
$liveScops = $uc_info['liveScope'];
$uc_info['liveScopeAll'] = $liveScops['brAll'];
$vh_msg = new VhMsgLogService();
$auth_info['liveScopeUsers'] = $liveScops['userIds'];
$auth_info['liveScopeDepts'] = $liveScops['dpIds'];
$auth_info['liveScopeTags'] = $liveScops['tagIds'];
$auth_info['liveScopeJobs'] = $liveScops['jobIds'];
$auth_info['liveScopeRoles'] = $liveScops['roleIds'];
// 获取有权限的用户UIDS集合
$uc_info['liveScopeUsers'] = $vh_msg->get_auth_uids($auth_info);
Log::write('权限用户-------------' . print_r($uc_info, true));
$service = new VhallService();
$info = $service->get_by_conds(['vh_id' => $this->callBackData['lm_id']]);
$uc_info = array_merge($uc_info, $info);
// 根据类型处理消息回调
if ($this->callBackData['type'] == CronModel::TYPE_LIVE_WILL_START) {
Log::write('直播前推动消息');
// 直播前X分钟推送消息
$vh_msg->send_vh_Msg($uc_info, $vh_msg::MSG_LIVE_WILL_START);
} elseif ($this->callBackData['type'] == CronModel::TYPE_LIVE_START) {
Log::write('直播开始推动消息');
// 直播开始时
$vh_msg->send_vh_Msg($uc_info, $vh_msg::MSG_LIVE_START);
};
exit('SUCCESS');
}
}