RemindBeginAllController.class.php
2.83 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
<?php
/**
* 考试开始前提醒
*/
namespace Frontend\Controller\Temp;
use Common\Common\Cache;
use Common\Service\AnswerService;
use Common\Service\PaperService;
use Common\Service\RightService;
class RemindBeginAllController extends AbstractController
{
/** @var RightService 用户回复信息表 */
protected $right_s;
/** @var PaperService 试卷信息表 */
protected $paper_s;
/** @var AnswerService 回答信息表 */
protected $answer_s;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化权限表
$this->right_s = new RightService();
// 实例化试卷表
$this->paper_s = new PaperService();
// 实例化回答表
$this->answer_s = new AnswerService();
return true;
}
public function Index()
{
set_time_limit(0);
// 获取需要发送的试卷id
$ep_id = I('get.ep_id');
// 非空判断
if (empty($ep_id)) {
return true;
}
// 获取试卷基本详情
$data = $this->paper_s->get($ep_id);
if (empty($data)) {
return true;
}
$paper_info = [];
try {
// 实例化缓存
$cache = &Cache::instance();
// 获取当前试卷缓存信息
$paper_info = $cache->get('Common.Exam_' . $ep_id);
} catch (\Think\Exception $e) {
\Think\Log::record($e);
} catch (\Exception $e) {
\Think\Log::record($e);
}
if (!empty($paper_info['join_uids'])) {
$params['uids'] = $paper_info['join_uids'];
} else {
$conds = array(
'epc_id' => $ep_id,
'er_type' => AnswerService::RIGHT_PAPER
);
$right_serv = new RightService();
// 参与考试的权限范围
if ($data['is_all'] != RightService::AUTH_ALL) {
$rights = $right_serv->list_by_conds($conds);
// 格式化权限范围
$right_view = $right_serv->format_db_data($rights);
}
$right_view['is_all'] = $data['is_all'];
// 获取要参加考试的全部人员
$all_join = $right_serv->list_uids_by_right($right_view);
$params['uids'] = $all_join;
}
$params['name'] = $data['ep_name'];
$params['description'] = $data['intro'];
$params['img_id'] = $data['cover_id'];
$params['is_cover_open'] = $data['is_cover_open'];
$params['begin_time'] = $data['begin_time'];
$params['end_time'] = $data['end_time'];
$params['id'] = $ep_id;
// 发送考试前提醒
$this->paper_s->send_msg($params, 3);
return true;
}
}