|
@@ -3,6 +3,7 @@ package com.cyksj.service.chatgpt.impl;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.lang.UUID;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
@@ -92,6 +93,8 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
|
|
private final ChatgptUserTokenPrepareMapper chatgptUserTokenPrepareMapper;
|
|
private final ChatgptUserTokenPrepareMapper chatgptUserTokenPrepareMapper;
|
|
|
|
|
|
|
|
|
|
+ private final ChatgptUserCarUsedRecordMapper chatgptUserCarUsedRecordMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public String addAccount(Account account) {
|
|
public String addAccount(Account account) {
|
|
|
if (isAccountExists(account)) {
|
|
if (isAccountExists(account)) {
|
|
@@ -211,6 +214,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
GroupsRelation groupsRelation = getGroupsRelation(userId, relationId);
|
|
GroupsRelation groupsRelation = getGroupsRelation(userId, relationId);
|
|
|
GroupsTrips groupsTrips = getGroupsTrips(groupsRelation);
|
|
GroupsTrips groupsTrips = getGroupsTrips(groupsRelation);
|
|
|
GoodsDonSku goodsDonSku = skuMapper.selectById(groupsTrips.getSkuId());
|
|
GoodsDonSku goodsDonSku = skuMapper.selectById(groupsTrips.getSkuId());
|
|
|
|
|
+ log.info("用户:{},所在车次:{},座位id:{},在{}获取跳转GPT镜像的登录url", userId, groupsTrips.getId(), relationId, DateTime.now());
|
|
|
|
|
|
|
|
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);
|
|
@@ -807,6 +811,29 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
redisService.set("chatgpt:clears_in:" + carId, expTime, expTime);
|
|
redisService.set("chatgpt:clears_in:" + carId, expTime, expTime);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ //记录用户触发限制
|
|
|
|
|
+ ChatgptUserCarUsedRecord chatgptUserCarUsedRecord = new ChatgptUserCarUsedRecord();
|
|
|
|
|
+ chatgptUserCarUsedRecord.setUserToken(userToken);
|
|
|
|
|
+ chatgptUserCarUsedRecord.setCarId(carId);
|
|
|
|
|
+
|
|
|
|
|
+ String highCarChatKey = RedisService.key.CHATGPT_CAR_HIGH_CHAT.getName() + carId;
|
|
|
|
|
+ String lowCarChatKey = RedisService.key.CHATGPT_CAR_LOW_CHAT.getName() + carId;
|
|
|
|
|
+
|
|
|
|
|
+ String highCarChatNum = redisService.getStr(highCarChatKey);
|
|
|
|
|
+ if (StrUtil.isNotBlank(highCarChatNum)) {
|
|
|
|
|
+ chatgptUserCarUsedRecord.setGptFour(Integer.parseInt(highCarChatNum));
|
|
|
|
|
+ }
|
|
|
|
|
+ String lowCarChatNum = redisService.getStr(lowCarChatKey);
|
|
|
|
|
+ if (StrUtil.isNotBlank(lowCarChatNum)) {
|
|
|
|
|
+ chatgptUserCarUsedRecord.setGpt(Integer.parseInt(lowCarChatNum));
|
|
|
|
|
+ }
|
|
|
|
|
+ chatgptUserCarUsedRecordMapper.insert(chatgptUserCarUsedRecord);
|
|
|
|
|
+ log.info("记录userToken:{}访问对应镜像车队carId:{}操作成功", userToken, carId);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.info("记录userToken:{}访问对应镜像车队carId:{}操作失败e:{}", userToken, carId, StringUtil.getErrorText(e));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostConstruct
|
|
@PostConstruct
|