From 64c7b8c1fdaea6140a185198dba94c63a48f8e1d Mon Sep 17 00:00:00 2001 From: xupei Date: Mon, 8 Jul 2024 19:05:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=20total=5Fcast=20?= =?UTF-8?q?=E4=B8=8A=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/service/impl/ChatRobotServiceImpl.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java index 11f4126a..686e5376 100644 --- a/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ChatRobotServiceImpl.java @@ -151,11 +151,9 @@ public class ChatRobotServiceImpl implements ChatRobotService { log.info("chatRobot请求python 参数:####{}", param); RequestBody body = RequestBody.create(mediaType, param); Request request = new Request.Builder() -// .url("http://127.0.0.1:5000/api/chat_stream_test") +// .url("http://127.0.0.1:8000/api/chat_robot") // .url(accessPythonIp + ":" + accessPythonPort + "/api/chat_stream_test") .url(accessPythonIp + ":" + accessPythonPort + "/api/chat_robot") -// .url(fastApiPythonAddress + "/api/chat_robot") -// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate") .method("POST", body) .addHeader("Content-Type", "application/json") .build(); @@ -268,15 +266,17 @@ public class ChatRobotServiceImpl implements ChatRobotService { BigDecimal totalCostUsed = chatRobots.get(0).getTotalCost(); Account account = accountMapper.selectById(userId); ChatRobot chatRobot = new ChatRobot(); - if (account.getIsTrial() == 1) { - if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(0.1)) > 0) { + if (account.getIsTrial() == 3) { +// if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(0.1)) > 0) { + if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(0.7)) > 0) { String messageFromResource = BusinessException.getMessageFromResource("balance.insufficient.for.trial"); chatRobot.setOutput(messageFromResource); // throw new BusinessException("Your balance is insufficient"); return CopyUtil.copyObject(chatRobot, ChatRobotVO.class); } }else { - if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(5)) > 0) { +// if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(5)) > 0) { + if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(35)) > 0) { String messageFromResource = BusinessException.getMessageFromResource("balance.insufficient.for.paying"); chatRobot.setOutput(messageFromResource); // throw new BusinessException("Your balance is insufficient"); @@ -348,9 +348,11 @@ public class ChatRobotServiceImpl implements ChatRobotService { return BigDecimal.ONE; } else { Account account = accountMapper.selectById(userId); - BigDecimal totalCost = BigDecimal.valueOf(5).subtract(chatRobots.get(0).getTotalCost()); +// BigDecimal totalCost = BigDecimal.valueOf(5).subtract(chatRobots.get(0).getTotalCost()); + BigDecimal totalCost = BigDecimal.valueOf(35).subtract(chatRobots.get(0).getTotalCost()); if (account.getIsTrial() == 1) { - totalCost = BigDecimal.valueOf(0.1).subtract(chatRobots.get(0).getTotalCost()); +// totalCost = BigDecimal.valueOf(0.1).subtract(chatRobots.get(0).getTotalCost()); + totalCost = BigDecimal.valueOf(0.7).subtract(chatRobots.get(0).getTotalCost()); return totalCost.divide(BigDecimal.valueOf(0.1), 4, RoundingMode.HALF_UP); }else { return totalCost.divide(BigDecimal.valueOf(5), 4, RoundingMode.HALF_UP);