1
0

fix: 修复大数字显示

This commit is contained in:
2025-09-15 15:20:05 +08:00
parent d3538ddce0
commit b569d62a25
2 changed files with 11 additions and 12 deletions

View File

@@ -9,6 +9,7 @@ import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport;
import java.time.LocalDate;
import java.util.Map;
import java.util.function.Function;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author lanyuanxiaoyao
* @version 20250829
*/
@Slf4j
@RestController
@RequestMapping("stock")
public class StockController extends SimpleControllerSupport<Stock, Void, StockController.DetailItem, StockController.DetailItem> {

View File

@@ -16,19 +16,16 @@ public class NumberHelper {
if (ObjectUtil.isNull(value)) {
return FINANCE_NULL_DOUBLE;
}
var builder = new StringBuilder();
if (value > 100000000) {
builder.append(value.longValue() / 100000000).append("亿");
value = value % 100000000;
var result = FINANCE_NULL_DOUBLE;
var absValue = Double.valueOf(Math.abs(value));
if (absValue > 100000000) {
result = NumberUtil.decimalFormat("#.##亿", absValue / 100000000);
} else if (value > 10000) {
result = NumberUtil.decimalFormat("#.##万", absValue / 10000);
} else {
result = NumberUtil.decimalFormat("#.##", absValue);
}
if (value > 10000) {
builder.append(value.longValue() / 10000).append("");
value = value % 10000;
}
if (value > 0) {
builder.append(NumberUtil.decimalFormat("#.##", value));
}
return builder.toString();
return value < 0 ? "-" + result : result;
}
public static String formatPercentageDouble(Double value) {