UserType.php
1.5 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
namespace addons\exam\enum;
/**
* 会员类型
*/
class UserType extends BaseEnum
{
/** 普通用户 */
const NORMAL = 'NORMAL';
/** 月卡会员 */
const VIP_MONTH = 'VIP_MONTH';
/** 年卡会员 */
const VIP_YEAR = 'VIP_YEAR';
/** 终身会员 */
const VIP_LIFE = 'VIP_LIFE';
/**
* 获取会员类型时限说明
* @param $type
* @return string
*/
public static function getDurationDesc($type)
{
switch ($type) {
case self::VIP_MONTH:
return '1个月';
case self::VIP_YEAR:
return '12个月';
case self::VIP_LIFE:
return '终身会员';
default:
return '非会员';
}
}
/**
* 获取会员类型时限值
* @param $type
* @return int
*/
public static function getDurationVal($type)
{
switch ($type) {
case self::VIP_MONTH:
return intval(date("t", strtotime(date('Y-m-d'))));
case self::VIP_YEAR:
$year = date('Y');
$days = 0;
for ($month = 1; $month <= 12; $month++) {
$days = $days + date("t", strtotime("{$year}-{$month}"));
}
return $days;
case self::VIP_LIFE:
return 365 * 100;
default:
return 0;
}
}
}