Merge remote-tracking branch 'origin/dev/dev' into dev/dev

This commit is contained in:
shahaibo
2024-07-09 09:46:54 +08:00

View File

@@ -151,11 +151,9 @@ public class ChatRobotServiceImpl implements ChatRobotService {
log.info("chatRobot请求python 参数:####{}", param); log.info("chatRobot请求python 参数:####{}", param);
RequestBody body = RequestBody.create(mediaType, param); RequestBody body = RequestBody.create(mediaType, param);
Request request = new Request.Builder() 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_stream_test")
.url(accessPythonIp + ":" + accessPythonPort + "/api/chat_robot") .url(accessPythonIp + ":" + accessPythonPort + "/api/chat_robot")
// .url(fastApiPythonAddress + "/api/chat_robot")
// .url(accessPythonIp + ":10200/aifda/api/v1.0/generate")
.method("POST", body) .method("POST", body)
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")
.build(); .build();
@@ -268,15 +266,17 @@ public class ChatRobotServiceImpl implements ChatRobotService {
BigDecimal totalCostUsed = chatRobots.get(0).getTotalCost(); BigDecimal totalCostUsed = chatRobots.get(0).getTotalCost();
Account account = accountMapper.selectById(userId); Account account = accountMapper.selectById(userId);
ChatRobot chatRobot = new ChatRobot(); ChatRobot chatRobot = new ChatRobot();
if (account.getIsTrial() == 1) { if (account.getIsTrial() == 3) {
if (totalCostUsed.add(totalCost).compareTo(BigDecimal.valueOf(0.1)) > 0) { // 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"); String messageFromResource = BusinessException.getMessageFromResource("balance.insufficient.for.trial");
chatRobot.setOutput(messageFromResource); chatRobot.setOutput(messageFromResource);
// throw new BusinessException("Your balance is insufficient"); // throw new BusinessException("Your balance is insufficient");
return CopyUtil.copyObject(chatRobot, ChatRobotVO.class); return CopyUtil.copyObject(chatRobot, ChatRobotVO.class);
} }
}else { }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"); String messageFromResource = BusinessException.getMessageFromResource("balance.insufficient.for.paying");
chatRobot.setOutput(messageFromResource); chatRobot.setOutput(messageFromResource);
// throw new BusinessException("Your balance is insufficient"); // throw new BusinessException("Your balance is insufficient");
@@ -348,9 +348,11 @@ public class ChatRobotServiceImpl implements ChatRobotService {
return BigDecimal.ONE; return BigDecimal.ONE;
} else { } else {
Account account = accountMapper.selectById(userId); 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) { 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); return totalCost.divide(BigDecimal.valueOf(0.1), 4, RoundingMode.HALF_UP);
}else { }else {
return totalCost.divide(BigDecimal.valueOf(5), 4, RoundingMode.HALF_UP); return totalCost.divide(BigDecimal.valueOf(5), 4, RoundingMode.HALF_UP);