CommentListOldController.class.php
4.13 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* 【销售活动-后台】获取评论列表接口
*
* User: WJY
* Date: 2017-11-02
*/
namespace Apicp\Controller\Comment;
use Common\Service\ActivityService;
use Common\Service\CommentService;
use Common\Service\PacketService;
class CommentListOldController extends \Apicp\Controller\AbstractController
{
/** @var ActivityService */
protected $activity_s;
/** @var PacketService */
protected $packet_s;
/** @var CommentService */
protected $comment_s;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化活动信息表
$this->activity_s = new ActivityService();
// 实例化红包表
$this->packet_s = new PacketService();
// 实例化评论表
$this->comment_s = new CommentService();
return true;
}
public function Index_post()
{
$params = I('post.');
$result = $this->comment_list($params);
$this->_result = $result;
return true;
}
/**
* 获取评论列表(后台)
*
* @param array $reqData 请求数据
*
* @return array
*/
protected function comment_list($reqData)
{
// 活动存在性判断
$ac_id = intval($reqData['ac_id']);
if (empty($ac_id)) {
E('_EMPTY_ACTIVITY_ID');
}
// 查询活动信息
$activity_info = $this->activity_s->get($ac_id);
if (empty($activity_info)) {
E('_ERR_ACTIVITY_DATA');
}
// 红包开启状态,审核开启状态
$red_status = $activity_info['is_red_open'];
$is_check_open = $activity_info['is_check_open'];
// 默认值
$page = isset($reqData['page']) ? intval($reqData['page']) : ActivityService::DEFAULT_PAGE;
// 默认每页条数
$limit = isset($reqData['limit']) ? intval($reqData['limit']) : ActivityService::DEFAULT_LIMIT;
// 分页
list($start, $limit) = page_limit($page, $limit);
$page_option = [$start, $limit];
// 排序
$order_option = ['check_time' => 'DESC'];
// 审核状态
$check_status = isset($reqData['check_status']) ? $reqData['check_status'] : ActivityService::CHECK_PASS;
// 条件组装
$conds = [
'ac_id' => $ac_id,
'check_status' => $check_status
];
// 查询总记录数
$total = $this->comment_s->count_by_conds($conds);
// 初始化审核统计字段
$passtotal = 0;
$checkingtotal = 0;
$failtotal = 0;
if (ActivityService::IS_CHECK_OPEN == $is_check_open) {
//统计通过/审核中/已驳回的数目
$passtotal = $this->comment_s->count_by_conds([
'ac_id' => $ac_id,
'check_status' => ActivityService::CHECK_PASS
]);
$checkingtotal = $this->comment_s->count_by_conds([
'ac_id' => $ac_id,
'check_status' => ActivityService::CHECK_ING
]);
$failtotal = $this->comment_s->count_by_conds([
'ac_id' => $ac_id,
'check_status' => ActivityService::CHECK_FAIL
]);
}
// 查询列表
$list = [];
$datalist = [
'red_status' => $red_status,
'is_check_open' => $is_check_open,
'check_status' => $check_status
];
if ($total > 0) {
$comm_list = $this->comment_s->list_by_conds($conds, $page_option, $order_option);
// 格式化列表数据
$list = $this->comment_s->format_comment_list_admin($comm_list, $datalist);
}
$result = [
'check_status' => $check_status,
'page' => $page,
'limit' => $limit,
'total' => (int)$total,
'pass_total' => (int)$passtotal,
'checking_total' => (int)$checkingtotal,
'fail_total' => (int)$failtotal,
'is_red_open' => (int)$red_status,
'list' => $list
];
return $result;
}
}