添加是否vip接口、扣除次数接口
This commit is contained in:
@@ -7,4 +7,8 @@ public interface AiVipLogService extends IService<AiVipLog> {
|
||||
|
||||
void openAiVip(int aiBuyConfigId);
|
||||
|
||||
boolean isAiVip();
|
||||
|
||||
void userCount();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.DateUtil;
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.dao.AiBuyConfigDao;
|
||||
@@ -13,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonAiVipLogService")
|
||||
@@ -42,4 +45,38 @@ public class AiVipLogServiceImpl extends ServiceImpl<AiVipLogDao, AiVipLog> impl
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAiVip() {
|
||||
List<AiVipLog> aiVipLogs = this.list(new LambdaQueryWrapper<AiVipLog>()
|
||||
.eq(AiVipLog::getUserId,ShiroUtils.getUId())
|
||||
.orderByAsc(AiVipLog::getStartTime));
|
||||
for (AiVipLog aiVipLog:aiVipLogs){
|
||||
if (aiVipLog.getSurplusCount()>0&&new Date().getTime()<aiVipLog.getEndTime().getTime()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userCount() {
|
||||
List<AiVipLog> aiVipLogs = this.list(new LambdaQueryWrapper<AiVipLog>()
|
||||
.eq(AiVipLog::getUserId,ShiroUtils.getUId())
|
||||
.orderByAsc(AiVipLog::getStartTime));
|
||||
boolean flag = false;
|
||||
for (AiVipLog aiVipLog:aiVipLogs){
|
||||
if (aiVipLog.getSurplusCount()>0&&new Date().getTime()<aiVipLog.getEndTime().getTime()){
|
||||
aiVipLog.setSurplusCount(aiVipLog.getSurplusCount()-1);
|
||||
this.updateById(aiVipLog);
|
||||
flag = true;
|
||||
}
|
||||
if (aiVipLog.getSurplusCount()==0||aiVipLog.getEndTime().getTime()<new Date().getTime()){
|
||||
this.removeById(aiVipLog);
|
||||
}
|
||||
if (flag){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user