|
@@ -211,8 +211,8 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
|
|
if (goodsDonSku != null && goodsDonSku.getIsMirror()) {
|
|
if (goodsDonSku != null && goodsDonSku.getIsMirror()) {
|
|
|
ChatgptUser chatgptUser = getChatgptUser(userId, relationId, groupsRelation, groupsTrips, goodsDonSku);
|
|
ChatgptUser chatgptUser = getChatgptUser(userId, relationId, groupsRelation, groupsTrips, goodsDonSku);
|
|
|
- if(214610L == relationId){
|
|
|
|
|
- return "https://cdn.galaxydvd.com/login_token?access_token=" + chatgptUser.getUserToken();
|
|
|
|
|
|
|
+ if (214610L == relationId) {
|
|
|
|
|
+ return "https://cdn.galaxydvd.com/login_token?access_token=" + chatgptUser.getUserToken();
|
|
|
}
|
|
}
|
|
|
return GPT_DOMAIN + "/login_token?access_token=" + chatgptUser.getUserToken();
|
|
return GPT_DOMAIN + "/login_token?access_token=" + chatgptUser.getUserToken();
|
|
|
} else {
|
|
} else {
|
|
@@ -239,6 +239,18 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
throw BusinessRuntimeException.getInstance("服务器出了点问题");
|
|
throw BusinessRuntimeException.getInstance("服务器出了点问题");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据userToken获取车队登录url
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getCarLoginUrlWithToken(String userToken, String carId) {
|
|
|
|
|
+ ChatgptUser chatgptUser = getCarChatGptUserWithToken(userToken);
|
|
|
|
|
+ if (chatgptUser != null) {
|
|
|
|
|
+ return CAR_GPT_DOMAIN + "/auth/logintoken?carid=" + carId + "&usertoken=" + chatgptUser.getUserToken();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("服务出了点问题");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取车位信息
|
|
* 获取车位信息
|
|
@@ -377,9 +389,9 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
public void saveConversationRecord(String userToken, ConversationRequest conversationRequest) {
|
|
public void saveConversationRecord(String userToken, ConversationRequest conversationRequest) {
|
|
|
LambdaQueryWrapper<ChatgptSession> wrapper = Wrappers.lambdaQuery(ChatgptSession.class);
|
|
LambdaQueryWrapper<ChatgptSession> wrapper = Wrappers.lambdaQuery(ChatgptSession.class);
|
|
|
|
|
|
|
|
- if(StringUtils.isNotBlank(conversationRequest.getCarId())){
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(conversationRequest.getCarId())) {
|
|
|
wrapper.eq(ChatgptSession::getCarId, conversationRequest.getCarId());
|
|
wrapper.eq(ChatgptSession::getCarId, conversationRequest.getCarId());
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class).eq(ChatgptUser::getUserToken, userToken));
|
|
ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class).eq(ChatgptUser::getUserToken, userToken));
|
|
|
if (chatgptUser.getSessionId() != null) {
|
|
if (chatgptUser.getSessionId() != null) {
|
|
|
wrapper.eq(ChatgptSession::getId, chatgptUser.getSessionId());
|
|
wrapper.eq(ChatgptSession::getId, chatgptUser.getSessionId());
|
|
@@ -399,7 +411,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
chatgptUserConversationRecord.setModel(conversationRequest.getModel());
|
|
chatgptUserConversationRecord.setModel(conversationRequest.getModel());
|
|
|
chatgptUserConversationRecordMapper.insert(chatgptUserConversationRecord);
|
|
chatgptUserConversationRecordMapper.insert(chatgptUserConversationRecord);
|
|
|
|
|
|
|
|
- if(StringUtils.isNotBlank(chatgptSession.getCarId())){
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(chatgptSession.getCarId())) {
|
|
|
updateExperienceAndScore(chatgptSession.getCarId(), !"text-davinci-002-render-sha".equals(conversationRequest.getModel()), System.currentTimeMillis());
|
|
updateExperienceAndScore(chatgptSession.getCarId(), !"text-davinci-002-render-sha".equals(conversationRequest.getModel()), System.currentTimeMillis());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -458,7 +470,6 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取指定用户ID在滑动窗口内的提问次数
|
|
* 获取指定用户ID在滑动窗口内的提问次数
|
|
|
*
|
|
*
|
|
@@ -532,6 +543,15 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean checkCarAccountWithToken(String userToken) {
|
|
|
|
|
+
|
|
|
|
|
+ ChatgptUser chatgptUser = getCarChatGptUserWithToken(userToken);
|
|
|
|
|
+
|
|
|
|
|
+ return chatgptUser != null;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public ChatgptUser getCarChatGptUser(long userId, Long relationId) {
|
|
public ChatgptUser getCarChatGptUser(long userId, Long relationId) {
|
|
|
GroupsRelation groupsRelation = getGroupsRelation(userId, relationId);
|
|
GroupsRelation groupsRelation = getGroupsRelation(userId, relationId);
|
|
@@ -539,7 +559,18 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
GoodsDonSku goodsDonSku = skuMapper.selectById(groupsTrips.getSkuId());
|
|
GoodsDonSku goodsDonSku = skuMapper.selectById(groupsTrips.getSkuId());
|
|
|
|
|
|
|
|
if (goodsDonSku != null && goodsDonSku.getIsMirror() && goodsDonSku.getIsCar()) {
|
|
if (goodsDonSku != null && goodsDonSku.getIsMirror() && goodsDonSku.getIsCar()) {
|
|
|
- ChatgptUser chatgptUser = getChatgptCarUser(userId, relationId, groupsRelation, goodsDonSku);
|
|
|
|
|
|
|
+ return getChatgptCarUser(userId, relationId, groupsRelation, goodsDonSku);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ChatgptUser getCarChatGptUserWithToken(String userToken) {
|
|
|
|
|
+ ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class).eq(ChatgptUser::getUserToken, userToken).last(" limit 1"));
|
|
|
|
|
+ if (chatgptUser != null) {
|
|
|
|
|
+ if(!chatgptUser.getIsCar()){
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("您非车队用户,请购买车队套餐");
|
|
|
|
|
+ }
|
|
|
return chatgptUser;
|
|
return chatgptUser;
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
@@ -624,7 +655,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
lowestScorecarIds = redisService.zRangeWithScores(RedisService.key.CHATGPT_CAR_SCORES.getName(), 0L, count - 1);
|
|
lowestScorecarIds = redisService.zRangeWithScores(RedisService.key.CHATGPT_CAR_SCORES.getName(), 0L, count - 1);
|
|
|
Map<Object, Double> collect = lowestScorecarIds.stream().collect(Collectors.toMap(ZSetOperations.TypedTuple::getValue, ZSetOperations.TypedTuple::getScore));
|
|
Map<Object, Double> collect = lowestScorecarIds.stream().collect(Collectors.toMap(ZSetOperations.TypedTuple::getValue, ZSetOperations.TypedTuple::getScore));
|
|
|
List<ChatgptSession> chatgptSessions = chatgptSessionMapper.selectList(Wrappers.lambdaQuery(ChatgptSession.class).in(ChatgptSession::getCarId, collect.keySet()));
|
|
List<ChatgptSession> chatgptSessions = chatgptSessionMapper.selectList(Wrappers.lambdaQuery(ChatgptSession.class).in(ChatgptSession::getCarId, collect.keySet()));
|
|
|
- return chatgptSessions.stream().map((chatgptSession)-> buildChatgptCarInfoView(chatgptSession.getCarId(),chatgptSession.getCarName(), chatgptSession.getIsPlus(), collect.get(chatgptSession.getCarId())))
|
|
|
|
|
|
|
+ return chatgptSessions.stream().map((chatgptSession) -> buildChatgptCarInfoView(chatgptSession.getCarId(), chatgptSession.getCarName(), chatgptSession.getIsPlus(), collect.get(chatgptSession.getCarId())))
|
|
|
.sorted(Comparator.comparing(ChatgptCarInfoView::getScore)).collect(Collectors.toCollection(LinkedHashSet::new));
|
|
.sorted(Comparator.comparing(ChatgptCarInfoView::getScore)).collect(Collectors.toCollection(LinkedHashSet::new));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -653,7 +684,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
ChatgptCarInfoView view = new ChatgptCarInfoView();
|
|
ChatgptCarInfoView view = new ChatgptCarInfoView();
|
|
|
view.setCarId(carId);
|
|
view.setCarId(carId);
|
|
|
// 假设以下方法从Redis或其他服务获取数据
|
|
// 假设以下方法从Redis或其他服务获取数据
|
|
|
- view.setScore(Math.min(score,100));
|
|
|
|
|
|
|
+ view.setScore(Math.min(score, 100));
|
|
|
view.setStatus(score >= 50 ? "繁忙" : "空闲"); // 或“繁忙”
|
|
view.setStatus(score >= 50 ? "繁忙" : "空闲"); // 或“繁忙”
|
|
|
|
|
|
|
|
view.setType(isPlus == 1 ? "plus" : "3.5");
|
|
view.setType(isPlus == 1 ? "plus" : "3.5");
|
|
@@ -687,6 +718,21 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
throw BusinessRuntimeException.getInstance("您还未购买该车票");
|
|
throw BusinessRuntimeException.getInstance("您还未购买该车票");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ChatGptUserView getUserInfoWithToken(String userToken) {
|
|
|
|
|
+ if (checkCarAccountWithToken(userToken)) {
|
|
|
|
|
+ ChatgptUser chatgptUser = getCarChatGptUserWithToken(userToken);
|
|
|
|
|
+ return ChatGptUserView.builder()
|
|
|
|
|
+ .skuName("")
|
|
|
|
|
+ .expireTime(chatgptUser.getExpireTime())
|
|
|
|
|
+ .limitNum(chatgptUser.getLimitNum())
|
|
|
|
|
+ .limitTime(chatgptUser.getLimitTime())
|
|
|
|
|
+ .use(getConversationCount(chatgptUser.getUserToken(), chatgptUser.getLimitTime()))
|
|
|
|
|
+ .build();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("您还未购买该车票");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void genTitleSync(String conversationId, String carid, String userToken) {
|
|
public void genTitleSync(String conversationId, String carid, String userToken) {
|
|
@@ -705,12 +751,12 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void carLimited(String carId, String userToken, Long expTime) {
|
|
public void carLimited(String carId, String userToken, Long expTime) {
|
|
|
- if(carId == null){
|
|
|
|
|
|
|
+ if (carId == null) {
|
|
|
if (StringUtils.isNotBlank(userToken)) {
|
|
if (StringUtils.isNotBlank(userToken)) {
|
|
|
ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class).eq(ChatgptUser::getUserToken, userToken));
|
|
ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class).eq(ChatgptUser::getUserToken, userToken));
|
|
|
if (chatgptUser != null && chatgptUser.getSessionId() != null) {
|
|
if (chatgptUser != null && chatgptUser.getSessionId() != null) {
|
|
|
ChatgptSession chatgptSession = chatgptSessionMapper.selectById(chatgptUser.getSessionId());
|
|
ChatgptSession chatgptSession = chatgptSessionMapper.selectById(chatgptUser.getSessionId());
|
|
|
- if(chatgptSession != null){
|
|
|
|
|
|
|
+ if (chatgptSession != null) {
|
|
|
carId = chatgptSession.getCarId();
|
|
carId = chatgptSession.getCarId();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|