ReleaseNowController.class.php
2.04 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
<?php
/**
* 【调研中心-后台】14_立即发布调研
* ReleaseNowController.class.php
* CreateBy:dj
* Date:2017-03-07
*/
namespace Apicp\Controller\Questionnaire;
use VcySDK\Cron;
use VcySDK\Service;
use Common\Service\BaseinfoService;
class ReleaseNowController extends \Apicp\Controller\AbstractController
{
public function Index_post()
{
// 调研id
$qu_id = I('post.qu_id', 0, 'intval');
// 调研id为空
if (empty($qu_id)) {
E('_EMPTY_BASEINFO_ID');
}
// 实例化调研基本信息Service
$base_info_s = new BaseinfoService();
// 调研基本信息
$data = $base_info_s->get($qu_id);
// 调研信息不存在
if (empty($data)) {
E('_ERR_BASEINFOID_NO_EXISTENT');
}
// 调研发布状态:预发布(只有预发布状态的调研才可以立即发布)
if (BaseinfoService::PRE_PUBLISH_STATUS == $data['release_status']) {
// 组装调研基本信息更新数据
$new_data = [
'release_time' => MILLI_TIME, // 发布时间
'release_status' => BaseinfoService::PUBLISH_STATUS // 发布
];
// 修改调研为发布状态
$result = $base_info_s->update($qu_id, $new_data);
// 调研立即发布失败
if (!$result) {
E('_ERR_QUESTIONNAIRE_RELEASE_NOW_FAIL');
}
if (!empty($data['release_crid'])) {
// 实例化定时任务类
$cron_s = new Cron(Service::instance());
$cron_info = $cron_s->get($data['release_crid']);
if (!empty($cron_info)) {
// 删除定时发布任务
$cron_s->delete($data['release_crid']);
}
}
// 发布调研推送提醒
$base_info_s->sendmsg_release($data);
}
return true;
}
}