|
|
@@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.imageio.stream.FileImageOutputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -568,7 +569,10 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private Long carOaiLimit(String carId) {
|
|
|
+ private Long carOaiLimit(String carId, Boolean isTeam) {
|
|
|
+ if(isTeam && redisService.hasKey("chatgpt:team:clears_in:" + carId)){
|
|
|
+ return redisService.getExpire("chatgpt:team:clears_in:" + carId);
|
|
|
+ }
|
|
|
if (redisService.hasKey("chatgpt:clears_in:" + carId)) {
|
|
|
return redisService.getExpire("chatgpt:clears_in:" + carId);
|
|
|
}
|
|
|
@@ -692,7 +696,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
Double lowExperienceScore = (double) redisService.zCount(RedisService.key.CHATGPT_CAR_LOW_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp);
|
|
|
double newScore = highExperienceScore + lowExperienceScore;
|
|
|
if(carId.contains("T")){
|
|
|
- newScore = newScore * 0.3D;
|
|
|
+ newScore = BigDecimal.valueOf(newScore).divide(BigDecimal.valueOf(5), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
}
|
|
|
redisService.zAdd(RedisService.key.CHATGPT_CAR_SCORES.getName(), newScore, carId);
|
|
|
}
|
|
|
@@ -747,16 +751,30 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
if(carName.contains("T")){
|
|
|
view.setType("Team");
|
|
|
+ Long team = carOaiLimit(carId, true);
|
|
|
+ if (team != 0L) {
|
|
|
+ view.setTeamExpTime(new DateTime(System.currentTimeMillis() + team * 1000));
|
|
|
+ }
|
|
|
+ Long aLong = carOaiLimit(carId, false);
|
|
|
+ if (aLong != 0L) {
|
|
|
+ view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
|
|
|
+ }
|
|
|
+ if (view.getExpTime() != null && view.getTeamExpTime() != null) {
|
|
|
+ view.setStatus("全部停运");
|
|
|
+ }else if(view.getExpTime() != null || view.getTeamExpTime() != null) {
|
|
|
+ view.setStatus("部分停运");
|
|
|
+ }
|
|
|
}else {
|
|
|
view.setType(isPlus == 1 ? "Plus" : "3.5");
|
|
|
+ Long aLong = carOaiLimit(carId, false);
|
|
|
+ if (aLong != 0L) {
|
|
|
+ view.setStatus("停运");
|
|
|
+ view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
|
|
|
+ }
|
|
|
}
|
|
|
int use = getCarConversationCount(carId, 3L).intValue();
|
|
|
view.setUse(use);
|
|
|
- Long aLong = carOaiLimit(carId);
|
|
|
- if (aLong != 0L) {
|
|
|
- view.setStatus("停运");
|
|
|
- view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
|
|
|
- }
|
|
|
+
|
|
|
view.setCarName(carName);
|
|
|
return view;
|
|
|
}
|
|
|
@@ -813,7 +831,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void carLimited(String carId, String userToken, Long expTime) {
|
|
|
+ public void carLimited(String carId, String userToken, Long expTime, Boolean isTeam) {
|
|
|
if (carId == null) {
|
|
|
if (StringUtils.isNotBlank(userToken)) {
|
|
|
ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class).eq(ChatgptUser::getUserToken, userToken));
|
|
|
@@ -825,7 +843,12 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- redisService.set("chatgpt:clears_in:" + carId, expTime, expTime);
|
|
|
+ if(isTeam){
|
|
|
+ redisService.set("chatgpt:team:clears_in:" + carId, expTime, expTime);
|
|
|
+ }else {
|
|
|
+ redisService.set("chatgpt:clears_in:" + carId, expTime, expTime);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
try {
|
|
|
//记录用户触发限制
|