SendDrawController.class.php
1.97 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
<?php
/**
* 【积分抽奖-手机端】中奖发消息
*
* @author: heyuelong
* @date: 2018年3月26日11:18:11
*/
namespace Api\Controller\Activity;
use Common\Common\Constant;
use Common\Service\ActivityService;
use Common\Service\RecordService;
class SendDrawController 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()
{
$lr_id = I('post.lr_id', 0);
if (empty($lr_id)) {
E('_EMPTY_ACTIVITY_LR_ID');
}
$conds = [
'lr_id' => $lr_id,
'uid' => $this->uid,
'lr_stauts' => '0'
];
$record_info = $this->_record_service->get_by_conds($conds);
// 获取活动详细内容
$info = $this->_activity_service->get_by_conds(
[
'ac_id' => $record_info['ac_id'],
'activity_status > ?' => 0
]
);
// 如果已经中奖
if (Constant::HAVE_PRIZE == $record_info['is_prize']) {
// 消息参数
$params = [
'uids' => $this->uid,
'ac_id' => $record_info['ac_id'],
'name' => $record_info['lp_name'],
'title' => $info['title'],
'start_time' => $info['start_time'],
'end_time' => $info['end_time'],
'integral' => $info['integral']
];
$this->_record_service->send_msg($params, Constant::MSG_PRIZE);
}
return true;
}
}