yujian
2020-03-24 f15acf7f2d57db3a32c574b0dfc21f564dca6024
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
package com.yeshi.fanli.service.manger.user;
 
import java.util.Date;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Component;
 
import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
 
@Component
public class UserLevelManager {
    @Resource
    private UserVIPInfoService userVIPInfoService;
 
    @Resource
    private UserVIPPreInfoService userVIPPreInfoService;
 
    /**
     * 获取用户等级
     * @Title: getUserLevel
     * @Description: 
     * @param uid
     * @return 
     * UserLevelEnum 返回类型
     * @throws
     */
    public UserLevelEnum getUserLevel(Long uid) {
        if (userVIPInfoService.isVIP(uid))
            return UserLevelEnum.superVIP;
        UserVIPPreInfo info = userVIPPreInfoService.getLatestProcessInfo(uid);
        if (info != null)
            for (UserLevelEnum level : UserLevelEnum.values())
                if (level.getLevel() == info.getProcess())
                    return level;
        return UserLevelEnum.daRen;
    }
 
    /**
     * 获取当时的用户等级
     * @Title: getUserLevel
     * @Description: 
     * @param uid
     * @param date
     * @return 
     * UserLevelEnum 返回类型
     * @throws
     */
    public UserLevelEnum getUserLevel(Long uid, Date date) {
        if (userVIPInfoService.isVIP(uid, date.getTime()))
            return UserLevelEnum.superVIP;
        UserVIPPreInfo info = userVIPPreInfoService.getProcessInfo(uid, date);
        if (info != null)
            for (UserLevelEnum level : UserLevelEnum.values())
                if (level.getLevel() == info.getProcess())
                    return level;
        return UserLevelEnum.daRen;
    }
 
}