From 678cad7a35baf06162095e5fc7d8acb656fb2ae3 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Mon, 29 Jan 2024 11:40:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=84=E4=BB=B7=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProfitManagementController.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java b/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java index 6c1638f..364fb80 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.List; import java.util.Random; @@ -54,12 +55,14 @@ public class ProfitManagementController { @ApiOperation("退出时机弹窗/随机获取股票价格") @AnonymousAccess @GetMapping("/getRandomPrice") - public ResultEntity getRandomPrice(@ApiParam("getLineChart返回的Id") @RequestParam String id) { + public ResultEntity getRandomPrice(@ApiParam("getLineChart返回的Id") @RequestParam String id) { Random random = new Random(); double randomValue = 0.01 + random.nextDouble() * 19.99; // 生成0到20之间的随机数(不包括0) - return new ResultEntity<>(randomValue); + BigDecimal bigDecimal = BigDecimal.valueOf(randomValue).setScale(2, RoundingMode.HALF_UP); + return new ResultEntity<>(bigDecimal); } + @ApiOperation("退出时机弹窗/判断市值和基金收益对错,计算错误则返回正确答案") @AnonymousAccess @GetMapping("/getExitTimeRightMarketValueAndFundEarnings")