|
|
@@ -371,78 +371,6 @@ public class MirrorController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Claude会话限制
|
|
|
- */
|
|
|
- @RequestMapping("/claude/conversation/limit")
|
|
|
- public ClaudeConversionLimitView claudeConversationLimit() {
|
|
|
- //1.从request获取请求头Authorization 并取 值内 'Bearer ' 后的值为usertoken
|
|
|
- String authorization = request.getHeader("Authorization");
|
|
|
- String carid = request.getHeader("Carid");
|
|
|
- String userToken = authorization.substring(7);
|
|
|
- //2.根据usertoken 查询 ClaudeUser 表中的记录
|
|
|
- ClaudeUser user = claudeService.findByUserTokenAndExpireTimeAfter(userToken, LocalDateTime.now());
|
|
|
- //3.如果记录不存在,返回状态码 401
|
|
|
- if (user == null) {
|
|
|
- response.setStatus(400);
|
|
|
- ClaudeConversionLimitView claudeConversionLimitView = new ClaudeConversionLimitView();
|
|
|
- ClaudeConversionLimitView.Error error = new ClaudeConversionLimitView.Error();
|
|
|
- error.setMessage("看来您还没车票呢,是不是还没登录呀,赶紧去车票内重新选择上车 \uD83D\uDE97 [点击直达](https://nf.video/ticket)");
|
|
|
- claudeConversionLimitView.setError(error);
|
|
|
- return claudeConversionLimitView;
|
|
|
- }else {
|
|
|
- if (user.getIsBlock() != null && user.getIsBlock()) {
|
|
|
- response.setStatus(400);
|
|
|
- ClaudeConversionLimitView chatgptConversionLimitView = new ClaudeConversionLimitView();
|
|
|
- ClaudeConversionLimitView.Error error = new ClaudeConversionLimitView.Error();
|
|
|
- error.setMessage("抱歉,您因违反银河录像局使用条款已被封禁.");
|
|
|
- chatgptConversionLimitView.setError(error);
|
|
|
- return chatgptConversionLimitView;
|
|
|
- }
|
|
|
-
|
|
|
- ConversationLimitResponse conversationLimitResponse = claudeService.conversationLimit(userToken, user);
|
|
|
-
|
|
|
- if (conversationLimitResponse.isLimited()) {
|
|
|
- response.setStatus(429);
|
|
|
- ClaudeConversionLimitView claudeConversionLimitView = new ClaudeConversionLimitView();
|
|
|
- ClaudeConversionLimitView.Error error = new ClaudeConversionLimitView.Error();
|
|
|
- //String url = "[点击此处升级](https://nf.video/ticket?relationId=%d&pType=pay)";
|
|
|
- //
|
|
|
- //String format = String.format(url, user.getRelationId());
|
|
|
- error.setMessage("您目前的套餐已达到使用上限,预计 " + DateUtil.format(new Date(conversationLimitResponse.getNextAvailableTime()), "yyyy-MM-dd HH:mm:ss") + " 恢复");
|
|
|
- claudeConversionLimitView.setError(error);
|
|
|
- return claudeConversionLimitView;
|
|
|
- } else {
|
|
|
- response.setStatus(200);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return new ClaudeConversionLimitView();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * Claude触发车队限制
|
|
|
- */
|
|
|
- @GetMapping("/claude/car/limited")
|
|
|
- public Result<String> claudeCarLimited(String carId, Long expTime) {
|
|
|
- String authorization = request.getHeader("Authorization");
|
|
|
- String userToken = "";
|
|
|
- if(StringUtils.isNotBlank(authorization)){
|
|
|
- try {
|
|
|
- userToken = authorization.substring(7);
|
|
|
- }catch (Exception e){
|
|
|
- log.error("获取用户token失败",e);
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
- }
|
|
|
- String finalUserToken = userToken;
|
|
|
- TASK_EXECUTOR.execute(()->{
|
|
|
- claudeService.carLimited(carId, finalUserToken, expTime);
|
|
|
- });
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* Claude获取车队列表
|
|
|
@@ -462,10 +390,9 @@ public class MirrorController {
|
|
|
}
|
|
|
SearchResult<ClaudeCarInfoView> carInfoList = beanSearcher.search(ClaudeCarInfoView.class, MapUtils.flatBuilder(request.getParameterMap()).field(ClaudeCarInfoView::getCsStatus, true).orderBy(ClaudeCarInfoView::getSort).desc().orderBy(ClaudeCarInfoView::getScore).asc().build());
|
|
|
carInfoList.getDataList().forEach((claudeCarInfoView)->{
|
|
|
- Long aLong = claudeService.carLimit(claudeCarInfoView.getCarId());
|
|
|
- if (aLong != 0L) {
|
|
|
+ if (claudeCarInfoView.getClearsIn() > 0) {
|
|
|
claudeCarInfoView.setStatus("停运");
|
|
|
- claudeCarInfoView.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
|
|
|
+ claudeCarInfoView.setExpTime(new DateTime(System.currentTimeMillis() + claudeCarInfoView.getClearsIn() * 1000));
|
|
|
}else {
|
|
|
claudeCarInfoView.setStatus(claudeCarInfoView.getScore() > 50 ? "繁忙":"空闲");
|
|
|
}
|
|
|
@@ -474,34 +401,6 @@ public class MirrorController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * Claude对话成功后记录次数
|
|
|
- */
|
|
|
- @RequestMapping("/claude/conversation/notifyUrl")
|
|
|
- public void claudeConversationNotifyUrl() {
|
|
|
- //1.从request获取请求头Authorization 并取 值内 'Bearer ' 后的值为usertoken
|
|
|
- String authorization = request.getHeader("Authorization");
|
|
|
- String carid = request.getHeader("Carid");
|
|
|
- String model = request.getHeader("Model");
|
|
|
- String conversation_id = request.getHeader("Convid");
|
|
|
- ConversationRequest conversationRequest = new ConversationRequest();
|
|
|
- conversationRequest.setCarId(carid);
|
|
|
- conversationRequest.setModel(model);
|
|
|
- conversationRequest.setConversation_id(conversation_id);
|
|
|
- String userToken = authorization.substring(7);
|
|
|
- //2.根据usertoken 查询 chatgpt_user 表中的记录
|
|
|
- ClaudeUser user = claudeService.findByUserTokenAndExpireTimeAfter(userToken, LocalDateTime.now());
|
|
|
- //3.如果记录不存在,返回状态码 401
|
|
|
- if (user == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if(StringUtils.isNotBlank(conversationRequest.getCarId())){
|
|
|
- TASK_EXECUTOR.execute(() -> {
|
|
|
- claudeService.saveConversationRecord(userToken, conversationRequest);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* luma车票跳转登录
|