123
This commit is contained in:
@@ -119,11 +119,11 @@ public class UserGreetServiceImpl extends ServiceImpl<UserGreetMapper,UserGreet>
|
||||
if(val != null && Long.parseLong(val) > max){
|
||||
throw new ServiceException("您今天打招呼的次数已经用完了");
|
||||
}
|
||||
String sendGreetCount = String.format(RedisHttpConstant.USER_GREET_SEND_TIME_REDIS,userId);
|
||||
String lastTime = stringRedisTemplate.opsForValue().get(sendGreetCount);
|
||||
String userGreetSendTime = String.format(RedisHttpConstant.USER_GREET_SEND_TIME_REDIS,userId); // 最近一次的发送时间
|
||||
String lastTime = stringRedisTemplate.opsForValue().get(userGreetSendTime);
|
||||
if(StringUtils.isNotBlank(lastTime)){
|
||||
Integer inter = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.GREET_INTERVAL_MIN);
|
||||
long jiange = Long.parseLong(lastTime) - DateUtil.currentSeconds();
|
||||
int inter = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.GREET_INTERVAL_MIN) * 60;
|
||||
long jiange = DateUtil.currentSeconds() - Long.parseLong(lastTime); // 距离上次发送的间隔
|
||||
long diff = inter - jiange;
|
||||
if(diff > 0){
|
||||
if(diff > 60){
|
||||
@@ -141,7 +141,7 @@ public class UserGreetServiceImpl extends ServiceImpl<UserGreetMapper,UserGreet>
|
||||
if(!r.isSuccess()){
|
||||
throw new ServiceException("发送失败");
|
||||
}
|
||||
stringRedisTemplate.opsForValue().set(sendGreetCount,DateUtil.currentSeconds()+"",1,TimeUnit.DAYS);
|
||||
stringRedisTemplate.opsForValue().set(userGreetSendTime,DateUtil.currentSeconds()+"",1,TimeUnit.DAYS);
|
||||
stringRedisTemplate.opsForValue().increment(numKey);
|
||||
stringRedisTemplate.expire(numKey,1,TimeUnit.DAYS);
|
||||
}finally {
|
||||
|
||||
Reference in New Issue
Block a user