AddRemarkController.class.php
2.06 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
<?php
/**
* 【积分抽奖-手机端】添加中奖信息
*
* @author: heyuelong
* @date: 2018年3月26日11:18:07
*/
namespace Api\Controller\Activity;
use Common\Common\Constant;
use Common\Service\ActivityService;
use Common\Service\RecordService;
class AddRemarkController extends \Api\Controller\AbstractController
{
/** @var ActivityService */
protected $_activity_service;
/** @var RecordService */
protected $_record_service;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化活动表
$this->_activity_service = new ActivityService();
// 实例化活动奖品记录表
$this->_record_service = new RecordService();
return true;
}
/**
* @return bool
*/
public function Index_post()
{
$params = I('post.');
// 获取参数
$lr_id = $params['lr_id'] ? intval($params['lr_id']) : 0;
if (empty($lr_id)) {
// 验证参数
E('_EMPTY_ACTIVITY_LR_ID');
}
// 获取活动详细内容
$info = $this->_record_service->get_by_conds(
[
'lr_id' => $lr_id,
'uid' => $this->uid
]
);
if (empty($info)) {
// 如果没有数据
E('_ERR_DATA_NOT_AUTH');
}
// 获取活动详细内容
$activity_info = $this->_activity_service->get_by_conds(
[
'ac_id' => $info['ac_id'],
'activity_status > ?' => 0
]
);
// 如果活动不存在
if (empty($activity_info)) {
// 数据不存在时抛错
E('_ERR_DATA_NOT_EXIST');
}
// 订单已发货
if (Constant::SEND_GOODS_STATUS_TRUE == $info['lr_status']) {
E('_ERR_SEND_GOODS_STATUS');
}
// 更新数据
$this->_record_service->update($lr_id, $params);
$this->_result = [];
return true;
}
}