RemindController.class.php
2.86 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
<?php
/**
* 【后台】培训计划提醒接口
* RemindController.class.php
* User: yingcai
* Date: 2017/8/29
* Time: 下午6:13
*/
namespace Apicp\Controller\Education;
use Common\Service\CategoryService;
use Common\Service\EducationService;
use Common\Service\RightUsersService;
class RemindController extends \Apicp\Controller\AbstractController
{
public function Index_post()
{
$ed_id = I('ed_id', 0, 'intval');
$send_type = I('send_type', 0, 'intval');
$content = I('content', '', 'raddslashes');
if (!$ed_id) {
E('_EMPTY_ED_ID');
}
$education_service = new EducationService();
$education = $education_service->get($ed_id);
$category = new CategoryService();
$cate = $category->get($education['ca_id']);
if (empty($education)) {
E('_ERR_EDUCATION_NOT_EXIST');
}
if (CategoryService::CATEGORY_CLOSE == $cate['ca_status']) {
// 分类被禁用
E('_ERR_EDUCATION_CATEGORY_CLOSE');
}
// 初始化查询条件
$condition['ed_id'] = $ed_id;
/*
// 初始化报名成功
$condition['ru_sign_status'] = RightUsersService::SIGN_SUCCESS;
// 如果开启报名
if (EducationService::EDUCATION_SIGN_OPEN == $education['ed_is_sign_up']) {
// 如果开启收费
if (EducationService::EDUCATION_CHARGE == $education['ed_is_charge']) {
$condition['ru_pay_status'] = RightUsersService::SIGN_CHARGE_PAY;
}
// 如果开启审核
if (EducationService::EDUCATION_CHARGE == $education['ed_is_check']) {
$condition['ru_check_status'] = RightUsersService::SIGN_CHECK_PASS;
}
}
*/
if (!empty($send_type)) {
// 已报名
if ($send_type == RightUsersService::SIGN_STATUS_SIGNED) {
$condition['ru_sign_status'] = RightUsersService::SIGN_STATUS_SIGNED;
// 未报名
} else {
$condition['ru_sign_status'] = RightUsersService::SIGN_STATUS_UN_SIGN;
}
}
// 获取班级所有人员
$right_users_server = new RightUsersService();
$right_users = $right_users_server->list_by_conds(
$condition,
null,
[],
'ru_uid'
);
// 班级人员数据不为空
if (!empty($right_users)) {
$uids = array_column($right_users, 'ru_uid');
$params = [
'ed_id' => $ed_id,
'name' => $education['ed_name'],
'content' => $content,
'uids' => $uids,
];
// 发送提醒消息
$education_service->send_msg($params, EducationService::MSG_EDUCATION_REMIND);
}
return true;
}
}