1
This commit is contained in:
@@ -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<String, Integer> 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<String, Integer> 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());
|
||||
|
||||
Reference in New Issue
Block a user