From 844f622d3e976758fe25532e482c513e93d80eee Mon Sep 17 00:00:00 2001 From: zhuyiyi <649091362@qq.com> Date: Fri, 13 Jun 2025 10:22:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9uv=E5=86=B7=E8=BD=AC=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lingtao/net/service/ProductService.java | 18 ++++++++++-------- .../java/lingtao/net/util/PriceUtils.java | 19 ++++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/lingtao/net/service/ProductService.java b/src/main/java/lingtao/net/service/ProductService.java index 9b9003c..af2df09 100644 --- a/src/main/java/lingtao/net/service/ProductService.java +++ b/src/main/java/lingtao/net/service/ProductService.java @@ -2392,29 +2392,30 @@ public class ProductService { } if (length == paperLength || length == paperWidth) { - }else{ + } else { length = BigDecimal.valueOf(length).add(BigDecimal.valueOf(0.6)).doubleValue(); } if (width == paperLength || width == paperWidth) { - }else{ + } else { width = BigDecimal.valueOf(width).add(BigDecimal.valueOf(0.6)).doubleValue(); } //一张大纸能放几个 - double num = Math.min(Math.floor(paperLength / length) * Math.floor(paperWidth / width), Math.floor(paperLength / width) * Math.floor(paperWidth / length)); + double num = Math.max(Math.min(Math.floor(paperLength / length) * Math.floor(paperWidth / width), Math.floor(paperLength / width) * Math.floor(paperWidth / length)), 1); if (craft_list.contains("烫画")) { num = Math.max(Math.ceil(paperLength / length) * Math.ceil(paperWidth / width), Math.ceil(paperLength / width) * Math.ceil(paperWidth / length)); } double baseCount = Math.max(Math.ceil(dto.getCount() * dto.getNumber() / num), 1); + double countNum = Math.max(Math.ceil(dto.getCount() / num), 1); int coNumber = dto.getCo_number(); if (coNumber <= 0) { coNumber = 1; } - double price = new PriceUtils().CalculatePrice(craft_list, baseCount, coNumber); + double price = new PriceUtils().CalculatePrice(craft_list, baseCount, coNumber, countNum); Product pro = new Product(); pro.setCount(dto.getCount()); @@ -2428,7 +2429,8 @@ public class ProductService { break; } baseCount = Math.max(Math.ceil(quantitySteps[i] * dto.getNumber() / num), 1); - double currentPrice = new PriceUtils().CalculatePrice(craft_list, baseCount, coNumber); + countNum = Math.max(Math.ceil(dto.getCount() / num), 1); + double currentPrice = new PriceUtils().CalculatePrice(craft_list, baseCount, coNumber, countNum); pro = new Product(); @@ -2437,9 +2439,9 @@ public class ProductService { priceList.add(pro); } - for (Product product : priceList) { - product.setPrice(Math.ceil(product.getPrice() + (number - 1) * 0.5)); - } +// for (Product product : priceList) { +// product.setPrice(Math.ceil(product.getPrice() + (number - 1) * 0.5)); +// } return priceList; } diff --git a/src/main/java/lingtao/net/util/PriceUtils.java b/src/main/java/lingtao/net/util/PriceUtils.java index 65b095d..8e8efe2 100644 --- a/src/main/java/lingtao/net/util/PriceUtils.java +++ b/src/main/java/lingtao/net/util/PriceUtils.java @@ -3440,20 +3440,25 @@ public class PriceUtils { return price; } - public double CalculatePrice(List craft_list, double count, int coNumber) { + public double CalculatePrice(List craft_list, double count, int coNumber, double countNum) { if (craft_list.contains("烫画")) { return (int) count * 120; } double price = 0; if (craft_list.contains("冷转印")) { - if (count <= 5) { - price = 260; - } else if (count < 100) { - price = 14 * count + 200; + if (countNum == 1) { + price = 260 * Math.ceil(count / countNum) + (coNumber - 1) * 100; + } else { - price = 12 * count; + if (count <= 5) { + price = 260; + } else if (count < 100) { + price = 14 * count + 200; + } else { + price = 12 * count; + } + price = price + (coNumber - 1) * 100; } - price = price + (coNumber - 1) * 100; } return price;