Ver código fonte

Merge remote-tracking branch 'origin/master'

zoujiajian 1 ano atrás
pai
commit
7a03c28309

+ 11 - 0
netflix-dao/src/main/java/com/cyksj/model/views/ChatGptUserView.java

@@ -44,6 +44,17 @@ public class ChatGptUserView {
      */
     private Long use;
 
+
+    /**
+     * o1-p
+     */
+    private Long o1PUse;
+
+    /**
+     * o1-mini
+     */
+    private Long o1MiniUse;
+
     /**
      * 是否可升级套餐
      */

+ 20 - 6
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -42,10 +42,7 @@ import java.math.RoundingMode;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.time.LocalDateTime;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author chan
@@ -372,6 +369,15 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         }
     }
 
+    public JSONObject getConversationCount(String userToken) {
+        try {
+            String res = HttpUtil.get("http://154.198.213.52:9611/getConversationCount?userToken=" + userToken);
+            return new JSONObject(res);
+        }catch (Exception e){
+            return new JSONObject("{\"count\": 0,\"o1_mini\": 0,\"o1_p\": 0}");
+        }
+    }
+
 
     @Override
     public ChatgptSession checkSession(String carId) {
@@ -546,7 +552,9 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
                 UpgradePackage upgradePackage = upgradePackageMapper.selectById(chatgptUser.getPackageId());
                 packagePrice = upgradePackage.getPrice();
             }
-            return ChatGptUserView.builder()
+            JSONObject conversationCount = getConversationCount(chatgptUser.getUserToken());
+
+            ChatGptUserView view = ChatGptUserView.builder()
                     .skuName(goodsDonSku.getSubTitle())
                     .specVal(goodsDonSku.getSpecVal())
                     .expireTime(chatgptUser.getExpireTime())
@@ -557,17 +565,23 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
                     .goodsId(goodsDonSku.getGoodsId())
                     .skuId(goodsDonSku.getId())
                     .months(goodsDonSku.getMonths())
-                    .use(Math.min(chatgptUser.getLimitNum(), getConversationCount(chatgptUser.getUserToken(), chatgptUser.getLimitTime())))
+                    .use(Math.min(chatgptUser.getLimitNum(), Optional.ofNullable(conversationCount.getLong("count")).orElse(0L)))
                     .packageId(chatgptUser.getPackageId())
                     .packagePrice(packagePrice)
                     .isRenewPackage(chatgptUser.getRenewOrderId() != null ? true : false)
                     .renewSkuId(chatgptUser.getRenewSkuId())
                     .renewOrderId(chatgptUser.getRenewOrderId())
                     .build();
+            if (chatgptUser.getLimitNum() > 20) {
+                view.setO1PUse(Math.min(chatgptUser.getLimitNum() < 60 ? 5L : 15L, Optional.ofNullable(conversationCount.getLong("o1_p")).orElse(0L)));
+                view.setO1MiniUse(Math.min(chatgptUser.getLimitNum() < 60 ? 10L : 25L, Optional.ofNullable(conversationCount.getLong("o1_mini")).orElse(0L)));
+            }
+            return view;
         } else {
             throw BusinessRuntimeException.getInstance("您还未购买该车票");
         }
     }
+
     @Override
     public ChatGptUserView getUserInfoWithToken(String userToken) {
         if (checkCarAccountWithToken(userToken)) {