QrCodeController.class.php
1.85 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
<?php
/**
* 扫二维码签到
* User: 蔡建华
* Date: 17-9-1
* Time: 下午7:55
*/
namespace Frontend\Controller\Index;
use Common\Service\PlanService;
class QrCodeController extends AbstractController
{
// 可以签到
const PLAN_OPEN = 1;
// 不在签到范围内
const PLAN_NOT_DATE = 2;
// 没有签到计划
const PLAN_NOT_SIGN = 3;
// 扫描签到
const IS_SIGN = 1;
/** @var PlanService */
protected $plan_s;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化培训计划service
$this->plan_s = new PlanService();
return true;
}
public function Index()
{
$ed_id = I('get.ed_id');
// 签到计划
$conds = [
'ed_id' => $ed_id,
'plan_type' => PlanService::PLAN_TYPE_SIGN
];
$plan_id = 0;
$data = $this->plan_s->list_by_conds($conds, null, null);
// 不在签到范围内2
$status = self::PLAN_NOT_DATE;
if (empty($data)) {
// 没有考勤计划
$status = self::PLAN_NOT_SIGN;
} else {
foreach ($data as $val) {
if (PlanService::PLAN_OPERATE_OPEN == $val['plan_use_status'] && $val['plan_sign_begin'] <= MILLI_TIME && $val['plan_sign_end'] >= MILLI_TIME) {
// 1
$status = self::PLAN_OPEN;
$plan_id = $val['plan_id'];
break;
}
}
}
// 扫二维码跳转签到地址
redirectFront('/app/page/train/train-sign',
[
'ed_id' => $ed_id,
'plan_id' => $plan_id,
'status' => $status,
'is_sign' => self::IS_SIGN
]);
}
}