ClassHourDictServiceImpl.java
3.19 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
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.common.RedisPrefixConstant;
import com.subsidy.mapper.ClassHourDictMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.ClassHourDictDO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.VodPlayHistoryDO;
import com.subsidy.service.ClassHourDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.RedisUtil;
import com.subsidy.vo.hour.PollingGetVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
* <p>
* 课时 服务实现类
* </p>
*
* @author DengMin
* @since 2021-11-26
*/
@Service
public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, ClassHourDictDO> implements ClassHourDictService {
@Autowired
private VodPlayHistoryMapper vodPlayHistoryMapper;
@Autowired
private MemberMapper memberMapper;
@Autowired
private RedisUtil redisUtil;
public ClassHourDictDO getSetting(ClassHourDictDO classHourDictDO) {
return (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId());
}
@Async
public String updateSetting(ClassHourDictDO classHourDictDO) {
ClassHourDictDO classHourDictDO1 = (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId());
BeanUtils.copyProperties(classHourDictDO, classHourDictDO1);
redisUtil.set(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + classHourDictDO.getCompanyId(), classHourDictDO1);
return ConstantUtils.SET_SUCCESS;
}
public PollingGetVO pollingGet(VodPlayHistoryDO vodPlayHistoryDO) {
PollingGetVO pollingGetVO = new PollingGetVO();
MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId());
//查看系统设定的时长
ClassHourDictDO classHourDictDO = (ClassHourDictDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_SETTINGS_PREFIX + memberDO.getCompanyId());
if (classHourDictDO.getStatus() == 0) {
pollingGetVO.setBool(false);
return pollingGetVO;
}
//查看当天这个人看了多少时间
Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId());
//是否超过时长 没超过 false 超过 true
if (classHourDictDO == null) {
pollingGetVO.setBool(true);
} else {
if (total + vodPlayHistoryDO.getPlayLength() <= classHourDictDO.getClassHour() * 3600) {
pollingGetVO.setBool(false);
} else {
pollingGetVO.setBool(true);
}
}
return pollingGetVO;
}
}