Bladeren bron

修改 team 号评分标准

chenbiao 2 jaren geleden
bovenliggende
commit
fbea09274d

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/views/ChatgptCarInfoView.java

@@ -39,6 +39,11 @@ public class ChatgptCarInfoView {
      */
     private Date expTime;
 
+    /**
+     * 车队可用时间
+     */
+    private Date teamExpTime;
+
     /**
      * 车次类型 team plus 3.5
      */

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

@@ -68,7 +68,7 @@ public interface ChatGptAccountService {
     /**
      * oai 触发车队限制
      */
-    void carLimited(String carId, String userToken, Long expTime);
+    void carLimited(String carId, String userToken, Long expTime, Boolean isTeam);
 
     /**
      * 获取GPT session

+ 32 - 9
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.imageio.stream.FileImageOutputStream;
+import java.math.BigDecimal;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.time.LocalDateTime;
@@ -568,7 +569,10 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
     }
 
 
-    private Long carOaiLimit(String carId) {
+    private Long carOaiLimit(String carId, Boolean isTeam) {
+        if(isTeam && redisService.hasKey("chatgpt:team:clears_in:" + carId)){
+            return redisService.getExpire("chatgpt:team:clears_in:" + carId);
+        }
         if (redisService.hasKey("chatgpt:clears_in:" + carId)) {
             return redisService.getExpire("chatgpt:clears_in:" + carId);
         }
@@ -692,7 +696,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         Double lowExperienceScore = (double) redisService.zCount(RedisService.key.CHATGPT_CAR_LOW_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp);
         double newScore = highExperienceScore + lowExperienceScore;
         if(carId.contains("T")){
-            newScore = newScore * 0.3D;
+            newScore = BigDecimal.valueOf(newScore).divide(BigDecimal.valueOf(5), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
         }
         redisService.zAdd(RedisService.key.CHATGPT_CAR_SCORES.getName(), newScore, carId);
     }
@@ -747,16 +751,30 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
 
         if(carName.contains("T")){
             view.setType("Team");
+            Long team = carOaiLimit(carId, true);
+            if (team != 0L) {
+                view.setTeamExpTime(new DateTime(System.currentTimeMillis() + team * 1000));
+            }
+            Long aLong = carOaiLimit(carId, false);
+            if (aLong != 0L) {
+                view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
+            }
+            if (view.getExpTime() != null && view.getTeamExpTime() != null) {
+                view.setStatus("全部停运");
+            }else if(view.getExpTime() != null || view.getTeamExpTime() != null) {
+                view.setStatus("部分停运");
+            }
         }else {
             view.setType(isPlus == 1 ? "Plus" : "3.5");
+            Long aLong = carOaiLimit(carId, false);
+            if (aLong != 0L) {
+                view.setStatus("停运");
+                view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
+            }
         }
         int use = getCarConversationCount(carId, 3L).intValue();
         view.setUse(use);
-        Long aLong = carOaiLimit(carId);
-        if (aLong != 0L) {
-            view.setStatus("停运");
-            view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
-        }
+
         view.setCarName(carName);
         return view;
     }
@@ -813,7 +831,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
     }
 
     @Override
-    public void carLimited(String carId, String userToken, Long expTime) {
+    public void carLimited(String carId, String userToken, Long expTime, Boolean isTeam) {
         if (carId == null) {
             if (StringUtils.isNotBlank(userToken)) {
                 ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class).eq(ChatgptUser::getUserToken, userToken));
@@ -825,7 +843,12 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
                 }
             }
         }
-        redisService.set("chatgpt:clears_in:" + carId, expTime, expTime);
+        if(isTeam){
+            redisService.set("chatgpt:team:clears_in:" + carId, expTime, expTime);
+        }else {
+            redisService.set("chatgpt:clears_in:" + carId, expTime, expTime);
+        }
+
 
         try {
             //记录用户触发限制

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

@@ -224,7 +224,7 @@ public class MirrorController {
      * oai触发车队限制
      */
     @GetMapping("/gpt/car/limited")
-    public Result<String> carLimited(String carId, Long expTime) {
+    public Result<String> carLimited(String carId, Long expTime, Boolean isTeam) {
         String authorization = request.getHeader("Authorization");
         String userToken = "";
         if(StringUtils.isNotBlank(authorization)){
@@ -238,7 +238,7 @@ public class MirrorController {
 
         String finalUserToken = userToken;
         TASK_EXECUTOR.execute(()->{
-            chatGptAccountService.carLimited(carId, finalUserToken, expTime);
+            chatGptAccountService.carLimited(carId, finalUserToken, expTime,isTeam);
         });
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }