|
@@ -453,13 +453,14 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
chatgptUserConversationRecord.setModel(conversationRequest.getModel());
|
|
chatgptUserConversationRecord.setModel(conversationRequest.getModel());
|
|
|
chatgptUserConversationRecordMapper.insert(chatgptUserConversationRecord);
|
|
chatgptUserConversationRecordMapper.insert(chatgptUserConversationRecord);
|
|
|
|
|
|
|
|
- String key = RedisService.key.CHATGPT_CONVERSATION_LIMIT.getName() + ":" + userToken;
|
|
|
|
|
- long currentTimeMillis = System.currentTimeMillis();
|
|
|
|
|
-
|
|
|
|
|
- // 如果未超过限制,记录当前请求的时间戳
|
|
|
|
|
- redisService.zAdd(key, currentTimeMillis, currentTimeMillis);
|
|
|
|
|
- // 设置ZSet的过期时间,窗口大小加上一段冗余时间
|
|
|
|
|
- redisService.expire(key, (chatgptUser.getLimitTime() * 60 * 60) + 20);
|
|
|
|
|
|
|
+ if(!"text-davinci-002-render-sha".equals(conversationRequest.getModel())){
|
|
|
|
|
+ String key = RedisService.key.CHATGPT_CONVERSATION_LIMIT.getName() + ":" + userToken;
|
|
|
|
|
+ long currentTimeMillis = System.currentTimeMillis();
|
|
|
|
|
+ // 如果未超过限制,记录当前请求的时间戳
|
|
|
|
|
+ redisService.zAdd(key, currentTimeMillis, currentTimeMillis);
|
|
|
|
|
+ // 设置ZSet的过期时间,窗口大小加上一段冗余时间
|
|
|
|
|
+ redisService.expire(key, (chatgptUser.getLimitTime() * 60 * 60) + 20);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(chatgptSession.getCarId())) {
|
|
if (StringUtils.isNotBlank(chatgptSession.getCarId())) {
|
|
|
redisService.del();
|
|
redisService.del();
|
|
@@ -801,7 +802,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
.expireTime(chatgptUser.getExpireTime())
|
|
.expireTime(chatgptUser.getExpireTime())
|
|
|
.limitNum(chatgptUser.getLimitNum())
|
|
.limitNum(chatgptUser.getLimitNum())
|
|
|
.limitTime(chatgptUser.getLimitTime())
|
|
.limitTime(chatgptUser.getLimitTime())
|
|
|
- .use(getConversationCount(chatgptUser.getUserToken(), chatgptUser.getLimitTime()))
|
|
|
|
|
|
|
+ .use(Math.min(chatgptUser.getLimitNum(),getConversationCount(chatgptUser.getUserToken(), chatgptUser.getLimitTime())))
|
|
|
.build();
|
|
.build();
|
|
|
} else {
|
|
} else {
|
|
|
throw BusinessRuntimeException.getInstance("您还未购买该车票");
|
|
throw BusinessRuntimeException.getInstance("您还未购买该车票");
|