RegiveController.class.php
1.18 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
<?php
/**
* 【销售活动-后台】管理员补发红包接口
*
* author daijun
*/
namespace Apicp\Controller\Red;
use Common\Service\PacketrecordService;
class RegiveController extends \Apicp\Controller\AbstractController
{
/**
* 接收参数
* red_id int 必填 红包ID
*
* @return bool
*/
public function Index_post()
{
$red_id = I('post.red_id', 0, 'intval');
if (empty($red_id)) {
// 验证数据
E('_EMPTY_RED_ID');
}
// 实例化用户红包记录表
$packet_records = new PacketrecordService();
// 查询红包记录
$record_info = $packet_records->get($red_id);
if (empty($record_info)) {
// 如果记录为空
E('_ERR_PACKET_RECORD_DATA');
}
if ($record_info['packet_status'] != PacketrecordService::PACKET_STATUS_FAIL) {
// 如果原红包记录的领取状态不是失败状态
E('_ERR_PACKET_STATUS');
}
// 补发新的红包关联为旧红包的子红包,并推送消息
$packet_records->regive_red($record_info, $this->_login->user);
return true;
}
}