DetailController.class.php
2.48 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
<?php
/**
* 【业绩比拼-手机端】获取活动详情
*
* @author: daijun
* @date: 2017-11-02
*/
namespace Api\Controller\Activity;
use Common\Service\ActivityService;
use Common\Service\RightService;
class DetailController extends \Api\Controller\AbstractController
{
/** @var ActivityService */
protected $_activity_serv;
/** @var RightService */
protected $_right_serv;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化活动Service
$this->_activity_serv = new ActivityService();
// 实例化权限表
$this->_right_serv = new RightService();
return true;
}
public function Index_get()
{
// 获取参数
$ac_id = I('get.ac_id', 0, 'intval');
if (empty($ac_id)) {
// 验证参数
E('_EMPTY_ACTIVITY_ID');
}
if (empty($this->uid)) {
// 判断是否外部人员
E('_EMPTY_USER_ID');
}
// 获取活动详细内容
$info = $this->_activity_serv->get_by_conds(
[
'activity_status >?' => ActivityService::ACTIVITY_DRAFT,
'ac_id' => $ac_id,
'is_hide' => ActivityService::CLOSE_ACTIVITY_HIDE
]
);
if (empty($info)) {
// 数据不存在时抛错
E('_ERR_DATA_NOT_EXIST');
}
// 获取是否有参与权限
list($activity_status, $is_join_right, $is_all_look) = $this->_activity_serv->is_join_right($info, $this->_login->user);
// 去除中文空格
$search = [" ", " ", "\n", "\r", "\t", " "];
$replace = ["", "", "", "", "", ''];
// 格式化详情数据
$this->_result = [
'ac_id' => intval($info['ac_id']),
'is_show_red' => intval($info['is_show_red']),
'cover_url' => empty($info['cover_id']) ? '' : imgUrlReal($info['cover_id']),
'subject' => $info['subject'],
'end_time' => $info['end_time'],
'content' => str_replace($search, $replace, strip_tags(unserialize($info['content']))),
'comments' => intval($info['comments']),
'is_check_open' => intval($info['is_check_open']),
'is_join_right' => $is_join_right,
'activity_status' => $activity_status,
'is_all_look' => $is_all_look
];
return true;
}
}