GetFailRedCountController.class.php
1.32 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
<?php
/**
* 【销售活动-后台】获取当前活动领取失败红包数量
*
* author daijun
*/
namespace Apicp\Controller\Red;
use Common\Service\ActivityService;
use Common\Service\PacketrecordService;
class GetFailRedCountController extends \Apicp\Controller\AbstractController
{
/**
* 接收参数
* ac_id int 必填 活动ID
*
* @return bool
*/
public function Index_post()
{
$ac_id = I('post.ac_id', 0, 'intval');
if (empty($ac_id)) {
// 验证数据
E('_EMPTY_ACTIVITY_ID');
}
// 实例化活动表
$activity_serv = new ActivityService();
// 获取活动信息
$activity = $activity_serv->get($ac_id);
if (empty($activity)) {
// 活动信息不存在
E('_ERR_ACTIVITY_DATA');
}
// 实例化用户红包记录表
$packet_records = new PacketrecordService();
$conds = [
'ac_id' => $ac_id, // 当前活动
'packet_status' => PacketrecordService::PACKET_STATUS_FAIL, // 领取失败
];
// 查询领取失败的所有红包记录数
$fail_count = $packet_records->count_by_conds($conds);
$this->_result = [
'fail_count' => (int)$fail_count
];
return true;
}
}