HideController.class.php
2.45 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
<?php
/**
* 【销售活动-后台】隐藏活动接口
*
* User: 何岳龙
* Date: 2018年1月25日11:26:03
*/
namespace Apicp\Controller\Activity;
use Common\Common\Helper;
use Common\Model\ActivityModel;
use Common\Service\ActivityService;
class HideController extends \Apicp\Controller\AbstractController
{
/** @var ActivityService */
protected $activity_s;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化活动信息表
$this->activity_s = new ActivityService();
return true;
}
public function Index_post()
{
$params = I('post.');
// 隐藏活动接口
$this->hide_activity($params);
$this->_result = [];
return true;
}
/**
* 隐藏活动(后端)
*
* @param array $reqData 请求数据
*
* @return bool
*/
public function hide_activity($reqData)
{
$ac_id = intval($reqData['ac_id']);
// 活动ID不能为空
if (empty($ac_id)) {
E('_ERR_AC_ID_EMPTY');
}
// 活动不存在
if (!$old_activity = $this->activity_s->get($ac_id)) {
E('_ERR_ARTICLE_NOT_FOUND');
}
// 未发布的的活动不能够隐藏
if (ActivityModel::ACTIVITY_DRAFT == $old_activity['activity_status']) {
E('_ERR_ACTIVITY_NOT_PUSH_NOT_HIDE');
}
// 已发布的活动且没有开启红包
if (ActivityModel::ACTIVITY_PUBLISH == $old_activity['activity_status'] && $old_activity['is_red_open'] == ActivityService::RED_NOT_OPEN) {
E('_ERR_ACTIVITY_NOT_OPEN_RED_NOT_HIDE');
}
// 已发布的活动且开启红包
if (ActivityModel::ACTIVITY_PUBLISH == $old_activity['activity_status'] && $old_activity['is_red_open'] == ActivityService::RED_OPEN) {
// 活动进行中不能隐藏
if ($old_activity['begin_time'] <= MILLI_TIME && $old_activity['end_time'] > MILLI_TIME) {
E('_ERR_ACTIVITY_STATUS_START_NOT_HIDE');
}
// 活动未开始不能隐藏
if ($old_activity['begin_time'] > MILLI_TIME) {
E('_ERR_ACTIVITY_STATUS_NOT_START_NOT_HIDE');
}
}
// 隐藏活动操作
$this->activity_s->update($ac_id, ['is_hide' => ActivityService::OPEN_ACTIVITY_HIDE]);
return true;
}
}