From 0ccc0ee99554c2c9d32b5c6e0d1d28b3f64e9dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E6=AC=A7=EF=BC=88=E6=9E=97=E5=B9=B3=E5=87=A1?= =?UTF-8?q?=EF=BC=89?= Date: Thu, 9 Oct 2025 17:36:53 +0800 Subject: [PATCH] 1 --- .../service/impl/InstructionServiceImpl.java | 76 +++++++++++++++++-- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java index a798dc8..c736a61 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/InstructionServiceImpl.java @@ -306,7 +306,12 @@ public class InstructionServiceImpl implements IInstructionService { priceText.append("型号:").append(model).append(" 数量:").append(count).append("\n"); } - // 输出金额计算(单台价格-返现) + priceText.append("\n"); + + // 输出金额计算(单台价格-返现+佣金=净价×数量=总价) + double grandTotal = 0.0; + StringBuilder calculationLines = new StringBuilder(); + for (Map.Entry entry : sortedEntries) { String model = entry.getKey(); double paymentAmount = globalPaymentAmounts.getOrDefault(model, 0.0); @@ -317,11 +322,70 @@ public class InstructionServiceImpl implements IInstructionService { double singlePayment = count > 0 ? paymentAmount / count : 0.0; double singleRebate = count > 0 ? rebateAmount / count : 0.0; - // 简单格式:单台价格-返现 - priceText.append(String.format("%.1f", singlePayment)) - .append("-") - .append(String.format("%.0f", singleRebate)) - .append("\n"); + // 从Redis获取佣金 + double commission = 0.0; + try { + com.ruoyi.jarvis.domain.ProductJdConfig config = productJdConfigService.selectProductJdConfigByModel(model); + if (config != null && config.getCommission() != null) { + commission = config.getCommission().doubleValue(); + } + } catch (Exception e) { + // 如果获取失败,佣金为0 + } + + // 计算净价(单台价格 - 返现 + 佣金) + double netPrice = singlePayment - singleRebate + commission; + // 计算总价 + double totalPrice = netPrice * count; + grandTotal += totalPrice; + + // 格式:单台价格-返现+佣金=净价×数量=总价 + if (count == 1) { + // 数量为1时,不显示×1 + calculationLines.append(String.format("%.1f-%.0f+%.0f=%.1f\n", + singlePayment, singleRebate, commission, netPrice)); + } else { + calculationLines.append(String.format("%.1f-%.0f+%.0f=%.1f×%d=%.1f\n", + singlePayment, singleRebate, commission, netPrice, count, totalPrice)); + } + } + + priceText.append(calculationLines); + + // 输出汇总(各型号总价相加) + if (sortedEntries.size() > 1) { + priceText.append("\n"); + // 构建汇总公式 + StringBuilder summaryFormula = new StringBuilder(); + for (int i = 0; i < sortedEntries.size(); i++) { + Map.Entry entry = sortedEntries.get(i); + String model = entry.getKey(); + double paymentAmount = globalPaymentAmounts.getOrDefault(model, 0.0); + double rebateAmount = globalRebateAmounts.getOrDefault(model, 0.0); + int count = entry.getValue(); + + double singlePayment = count > 0 ? paymentAmount / count : 0.0; + double singleRebate = count > 0 ? rebateAmount / count : 0.0; + + double commission = 0.0; + try { + com.ruoyi.jarvis.domain.ProductJdConfig config = productJdConfigService.selectProductJdConfigByModel(model); + if (config != null && config.getCommission() != null) { + commission = config.getCommission().doubleValue(); + } + } catch (Exception e) { + } + + double netPrice = singlePayment - singleRebate + commission; + double totalPrice = netPrice * count; + + if (i > 0) { + summaryFormula.append("+"); + } + summaryFormula.append(String.format("%.1f", totalPrice)); + } + summaryFormula.append(String.format("=%.1f", grandTotal)); + priceText.append(summaryFormula); } outputs.add(priceText.toString().trim());