MsgController.class.php
2.04 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
<?php
/**
* Created by PhpStorm.
* User: yingcai
* Date: 2017/9/7
* Time: 上午10:49
*/
namespace Frontend\Controller\Index;
use Common\Service\EducationService;
use Common\Service\RightUsersService;
class MsgController extends AbstractController
{
/** 不是必须登录 @var string $_require_login */
protected $_require_login = false;
public function Index()
{
// 培训ID
$ed_id = I('ed_id', 0, 'rintval');
// 勋章消息标识
$my_medal = I('my_medal', 0, 'rintval');
// 获取培训信息
$education_service = new EducationService();
$education = $education_service->get($ed_id);
// 页面跳转参数
$jump_params = [
'_identifier' => APP_IDENTIFIER,
'ed_id' => $ed_id
];
// 勋章推送消息
if ($my_medal) {
// 直接跳转到我的勋章页面
$jump_medal_params['_identifier'] = 'Integral';
redirectFront('/app/page/integral/medal-list', $jump_medal_params,'Integral');
} else {
// 如果未开启报名
if (!$education['ed_is_sign_up']) {
// 直接跳转到已报名页面
redirectFront('/app/page/train/train-detail-register', $jump_params);
} else {
$right_users_service = new RightUsersService();
// 查询用户报名数据
$cond = ['ed_id' => $ed_id, 'ru_uid' => $this->uid];
$right_users = $right_users_service->get_by_conds($cond);
// 用户报名状态
$sign_up_status = $right_users_service->get_sign_up_status($education, $right_users);
// 报名成功
if (RightUsersService::SIGN_SUCCESS == $sign_up_status) {
redirectFront('/app/page/train/train-detail-register', $jump_params);
} else { // 未报名
redirectFront('/app/page/train/train-detail', $jump_params);
}
}
}
}
}