ソースを参照

fix gpt车票使用信息

zoujiajian 1 年間 前
コミット
995631f8c2

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/chatgpt/ChatGptAccountService.java

@@ -1,5 +1,6 @@
 package com.cyksj.service.chatgpt;
 
+import cn.hutool.json.JSONObject;
 import com.cyksj.model.dto.ChatgptUserVerifyDto;
 import com.cyksj.model.entity.ChatgptSession;
 import com.cyksj.model.entity.ChatgptUser;
@@ -87,4 +88,6 @@ public interface ChatGptAccountService {
      * gpt3日体验卡
      */
     String trialGpt(String clientIP, String trialToken, String userAgent);
+
+    JSONObject getGptUseInfo(String userToken);
 }

+ 21 - 0
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -820,6 +820,27 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         return chatgptUser.getUserToken();
     }
 
+    @Override
+    public JSONObject getGptUseInfo(String userToken) {
+        ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class)
+                .eq(ChatgptUser::getUserToken, userToken)
+                .last("limit 1"));
+        if (chatgptUser == null) {
+            throw BusinessRuntimeException.getInstance("车票不存在");
+        }
+        Long relationId = chatgptUser.getRelationId();
+        GroupsRelation relation = groupsRelationMapper.selectById(relationId);
+        if (relation == null) {
+            throw BusinessRuntimeException.getInstance("车票不存在");
+        }
+        try {
+            String res = HttpUtil.get(String.format("https://image.yhlxj.com/api/getCount?usertoken=%s&limit=%s&time=%s&isVip=%s", userToken, chatgptUser.getLimitNum(), chatgptUser.getLimitTime(), relation.getIsVip()), 5000);
+            return new JSONObject(res);
+        }catch (Exception e){
+            return new JSONObject("{\"count\": 0,\"o1_mini\": 0,\"o1_p\": 0}");
+        }
+    }
+
     private synchronized ChatgptUser createTrialUser(String clientIP) {
         //固定 sku id
         GoodsDonSku goodsDonSku = skuMapper.selectById(535L);

+ 9 - 0
netflix-web/src/main/java/com/cyksj/web/controller/mirror/MirrorController.java

@@ -198,6 +198,15 @@ public class MirrorController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(user);
     }
 
+    /**
+     * gpt车票使用信息
+     */
+    @GetMapping("/get/gptUseInfo")
+    public Result getGptUseInfo(String userToken) {
+        JSONObject re = chatGptAccountService.getGptUseInfo(userToken);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
+    }
+
     /**
      * 获取车队历史记录
      */