|
@@ -1262,12 +1262,18 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
String userLimitKey = String.format(REDPACKET_USER_LIMIT, today, param.getUserId());
|
|
String userLimitKey = String.format(REDPACKET_USER_LIMIT, today, param.getUserId());
|
|
Integer userCount = redisTemplateInteger.opsForValue().get(userLimitKey);
|
|
Integer userCount = redisTemplateInteger.opsForValue().get(userLimitKey);
|
|
|
|
|
|
- if(userCount != null){
|
|
|
|
- if(userCount >= RED_PACKET_LIMIT_COUNT){
|
|
|
|
- return R.error("[红包领取] 当前用户当前已经领取红包已经达到限制!");
|
|
|
|
- }
|
|
|
|
|
|
+ // 首次领取
|
|
|
|
+ if(userCount == null) {
|
|
|
|
+ userCount = 0;
|
|
|
|
+ long expireSeconds = getExpireSeconds();
|
|
|
|
+ redisTemplateInteger.opsForValue().set(userLimitKey, userCount, expireSeconds, TimeUnit.SECONDS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(userCount >= RED_PACKET_LIMIT_COUNT){
|
|
|
|
+ return R.error("[红包领取] 当前用户当前已经领取红包已经达到限制!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
BigDecimal companyMoney = null;
|
|
BigDecimal companyMoney = null;
|
|
if(StringUtils.equals(ENABLE_RED_PACK_ACCOUNT,"1")) {
|
|
if(StringUtils.equals(ENABLE_RED_PACK_ACCOUNT,"1")) {
|
|
companyMoney = redisTemplate.opsForValue().get(REDPACKET_COMPANY_MONEY);
|
|
companyMoney = redisTemplate.opsForValue().get(REDPACKET_COMPANY_MONEY);
|
|
@@ -1333,14 +1339,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
// 用户领取红包次数+1
|
|
// 用户领取红包次数+1
|
|
redisTemplateInteger.opsForValue().increment(userLimitKey, 1);
|
|
redisTemplateInteger.opsForValue().increment(userLimitKey, 1);
|
|
// 设置过期时间为第二天凌晨0点
|
|
// 设置过期时间为第二天凌晨0点
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
|
- calendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
|
- // 计算从现在到明天凌晨的秒数
|
|
|
|
- long expireSeconds = (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
|
|
|
|
|
|
+ long expireSeconds = getExpireSeconds();
|
|
// 设置过期时间
|
|
// 设置过期时间
|
|
redisTemplateInteger.expire(userLimitKey, expireSeconds, TimeUnit.SECONDS);
|
|
redisTemplateInteger.expire(userLimitKey, expireSeconds, TimeUnit.SECONDS);
|
|
return sendRedPacket;
|
|
return sendRedPacket;
|
|
@@ -1349,6 +1348,18 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static long getExpireSeconds() {
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
+ calendar.set(Calendar.MINUTE, 0);
|
|
|
|
+ calendar.set(Calendar.SECOND, 0);
|
|
|
|
+ calendar.set(Calendar.MILLISECOND, 0);
|
|
|
|
+ // 计算从现在到明天凌晨的秒数
|
|
|
|
+ long expireSeconds = (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
|
|
|
|
+ return expireSeconds;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private void handleFsUserWx(FsUser user, String appId) {
|
|
private void handleFsUserWx(FsUser user, String appId) {
|
|
FsUserWx fsUserWx = new FsUserWx();
|
|
FsUserWx fsUserWx = new FsUserWx();
|
|
@@ -1470,10 +1481,15 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
String userLimitKey = String.format(REDPACKET_USER_LIMIT, today, param.getUserId());
|
|
String userLimitKey = String.format(REDPACKET_USER_LIMIT, today, param.getUserId());
|
|
Integer userCount = redisTemplateInteger.opsForValue().get(userLimitKey);
|
|
Integer userCount = redisTemplateInteger.opsForValue().get(userLimitKey);
|
|
|
|
|
|
- if(userCount != null){
|
|
|
|
- if(userCount >= RED_PACKET_LIMIT_COUNT){
|
|
|
|
- return R.error("[红包领取] 当前用户当前已经领取红包已经达到限制!");
|
|
|
|
- }
|
|
|
|
|
|
+ // 首次领取
|
|
|
|
+ if(userCount == null) {
|
|
|
|
+ userCount = 0;
|
|
|
|
+ long expireSeconds = getExpireSeconds();
|
|
|
|
+ redisTemplateInteger.opsForValue().set(userLimitKey, userCount, expireSeconds, TimeUnit.SECONDS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(userCount >= RED_PACKET_LIMIT_COUNT){
|
|
|
|
+ return R.error("[红包领取] 当前用户当前已经领取红包已经达到限制!");
|
|
}
|
|
}
|
|
|
|
|
|
BigDecimal companyMoney = null;
|
|
BigDecimal companyMoney = null;
|
|
@@ -1542,14 +1558,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
// 用户领取红包次数+1
|
|
// 用户领取红包次数+1
|
|
redisTemplateInteger.opsForValue().increment(userLimitKey, 1);
|
|
redisTemplateInteger.opsForValue().increment(userLimitKey, 1);
|
|
// 设置过期时间为第二天凌晨0点
|
|
// 设置过期时间为第二天凌晨0点
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
|
- calendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
|
- // 计算从现在到明天凌晨的秒数
|
|
|
|
- long expireSeconds = (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
|
|
|
|
|
|
+ long expireSeconds = getExpireSeconds();
|
|
// 设置过期时间
|
|
// 设置过期时间
|
|
redisTemplateInteger.expire(userLimitKey, expireSeconds, TimeUnit.SECONDS);
|
|
redisTemplateInteger.expire(userLimitKey, expireSeconds, TimeUnit.SECONDS);
|
|
|
|
|