|
@@ -852,14 +852,24 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
String monthKey = CompanyTrafficConstants.CACHE_KEY+ ":1:"+ YearMonth.now();
|
|
String monthKey = CompanyTrafficConstants.CACHE_KEY+ ":1:"+ YearMonth.now();
|
|
String lockKey = companyKey + ":lock";
|
|
String lockKey = companyKey + ":lock";
|
|
//销售公司剩余流量
|
|
//销售公司剩余流量
|
|
- Long companyTraffic = ((Integer)redisCache.getCacheObject(companyKey)).longValue();
|
|
|
|
- if(companyTraffic == null || companyTraffic<0){
|
|
|
|
- return companyTraffic == null?0:companyTraffic;
|
|
|
|
|
|
+ Object companyTraffic = redisCache.getCacheObject(companyKey);
|
|
|
|
+ Long balance;
|
|
|
|
+ if(companyTraffic instanceof Long) {
|
|
|
|
+ balance = (Long) companyTraffic;
|
|
|
|
+ }else if(companyTraffic instanceof Integer){
|
|
|
|
+ balance = ((Integer) companyTraffic).longValue();
|
|
|
|
+ }else if(companyTraffic instanceof String){
|
|
|
|
+ balance = Long.parseLong(companyTraffic.toString());
|
|
|
|
+ }else{
|
|
|
|
+ throw new IllegalArgumentException("流量转换异常");
|
|
|
|
+ }
|
|
|
|
+ if(balance<0){
|
|
|
|
+ return balance;
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
if (redisCache.setIfAbsent(lockKey, "1", 3, TimeUnit.SECONDS)) {
|
|
if (redisCache.setIfAbsent(lockKey, "1", 3, TimeUnit.SECONDS)) {
|
|
try {
|
|
try {
|
|
- companyTraffic = redisCache.decr(companyKey, traffic);
|
|
|
|
|
|
+ balance = redisCache.decr(companyKey, traffic);
|
|
redisCache.decr(deptKey, traffic);
|
|
redisCache.decr(deptKey, traffic);
|
|
redisCache.incr(companyDayKey, traffic);
|
|
redisCache.incr(companyDayKey, traffic);
|
|
redisCache.incr(dayKey, traffic);
|
|
redisCache.incr(dayKey, traffic);
|
|
@@ -873,7 +883,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
logger.error("【更新Redis缓存失败】企业ID: {}, 流量: {}, 错误信息:{}", company.getCompanyId(), traffic, e.getMessage(), e);
|
|
logger.error("【更新Redis缓存失败】企业ID: {}, 流量: {}, 错误信息:{}", company.getCompanyId(), traffic, e.getMessage(), e);
|
|
throw e;
|
|
throw e;
|
|
}
|
|
}
|
|
- return companyTraffic;
|
|
|
|
|
|
+ return balance;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|