ReleaseController.class.php
2.06 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
<?php
/**
* 定时发布回调
* Created by PhpStorm.
* User: 大熊
* Date: 2018/5/16
* Time: 19:21
*/
namespace Frontend\Controller\Callback;
use Common\Common\Constant;
use Common\Common\NewsHelper;
use Common\Service\ArticleService;
use Common\Service\ClassService;
use Think\Log;
class ReleaseController extends AbstractController
{
public function index()
{
$param = $this->callBackData;
if (empty($param)) {
$param = I('post.');
}
if (empty($param)) {
return true;
}
// 获取数据信息
$service = new ArticleService();
$data = $service->get($param['article_id']);
// 不为定时发布时不做处理
if ($data['news_status'] != Constant::NEWS_STATUS_TIMING_RELEASE) {
return true;
}
// 判断素材状态,若转码成功则为发布状态,否则为预发布状态
$updateData = ['news_status' => Constant::NEWS_STATUS_SEND];
if ($data['convert_status'] == Constant::FILE_STATUS_CONVERT) {
$updateData['news_status'] = Constant::NEWS_STATUS_READY_SEND;
}
$service->update($param['article_id'], $updateData);
// 当为发布时
if ($updateData['news_status'] == Constant::NEWS_STATUS_SEND) {
// 获取顶级分类名称
$classServ = new ClassService();
$class = $classServ->getTopClass($data['class_id']);
$data['class_name'] = $class['class_name'];
// 发送未读提醒
if ($data['is_notice'] == Constant::NEWS_IS_NOTICE_TRUE) {
$newsHelper = &NewsHelper::instance();
list($uids_all, $uids_read, $uids_unread) = $newsHelper->getReadData($param['article_id']);
$newsHelper->sendUnreadMsg($uids_unread, $data);
}
// RPC推送到运营中心
if ($data['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) {
$service->addNewsRpc($param['article_id'], []);
}
}
return true;
}
}