修改应付总额显示

This commit is contained in:
wuweihua
2026-10-10 15:51:15 +08:00
parent b071d76c96
commit 830f219e52
3 changed files with 27 additions and 37 deletions
@@ -1086,12 +1086,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
bill.setFreightAmount(result.getFreightAmount()); bill.setFreightAmount(result.getFreightAmount());
bill.setSurchargeAmount(result.getSurchargeAmount()); bill.setSurchargeAmount(result.getSurchargeAmount());
bill.setIncomeTotal(result.getPayableTotal()); bill.setIncomeTotal(result.getPayableTotal());
BigDecimal payTotal = result.getPayTotal(); // 应付总额与产品目录价解耦:试算未产出 pay_total 时留空,不再用 product_amount 兜底
if (payTotal == null) bill.setPayTotal(result.getPayTotal());
{
payTotal = result.getProductAmount();
}
bill.setPayTotal(payTotal == null ? BigDecimal.ZERO : payTotal);
bill.setCurrency(result.getCurrency()); bill.setCurrency(result.getCurrency());
bill.setRoundMode(result.getRoundMode()); bill.setRoundMode(result.getRoundMode());
// Credit soft-fail before persist so insert/update stores arrears flag in one write. // Credit soft-fail before persist so insert/update stores arrears flag in one write.
@@ -1481,14 +1477,13 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
return fees; return fees;
} }
/** 应付主表与订单计费一对一落库;成本价/应付=产品目录价,同步写入 product_amount;红线价同步写入 redline_amount。 */ /** 应付主表与订单计费一对一落库;product_amount 取产品目录价、redline_amount 取红线价;应付/成本价留空待接入真实成本源。 */
private PrcPayBill persistPayBill(PrcOrderBill bill, TmsPriceQuoteResult result) private PrcPayBill persistPayBill(PrcOrderBill bill, TmsPriceQuoteResult result)
{ {
if (bill == null || StringUtils.isEmpty(bill.getBillId())) if (bill == null || StringUtils.isEmpty(bill.getBillId()))
{ {
return null; return null;
} }
BigDecimal pay = nz(bill.getPayTotal());
PrcPayBill existed = payBillMapper.selectByBillId(bill.getBillId()); PrcPayBill existed = payBillMapper.selectByBillId(bill.getBillId());
PrcPayBill row = existed == null ? new PrcPayBill() : existed; PrcPayBill row = existed == null ? new PrcPayBill() : existed;
if (existed == null) if (existed == null)
@@ -1498,12 +1493,11 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
row.setCreateBy(bill.getCreateBy()); row.setCreateBy(bill.getCreateBy());
} }
row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency()); row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency());
// product/cost = catalog; redline from quote // product = catalog; redline from quote; cost/pay 不再等于产品目录价
BigDecimal product = result == null ? null : result.getProductAmount(); row.setProductAmount(result == null ? null : result.getProductAmount());
row.setProductAmount(product);
row.setRedlineAmount(result == null ? null : result.getRedlineAmount()); row.setRedlineAmount(result == null ? null : result.getRedlineAmount());
row.setCostAmount(pay); row.setCostAmount(result == null ? null : result.getCostAmount());
row.setPayTotal(pay); row.setPayTotal(result == null ? null : result.getPayTotal());
row.setBelongSaler(bill.getBelongSaler()); row.setBelongSaler(bill.getBelongSaler());
row.setBelongSalerCode(bill.getBelongSalerCode()); row.setBelongSalerCode(bill.getBelongSalerCode());
row.setSettlementMan(bill.getSettlementMan()); row.setSettlementMan(bill.getSettlementMan());
@@ -940,9 +940,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
} }
/** /**
* Product catalog amount (product_amount) and payable cost (pay_total / payFeeDetails). * Product catalog amount (product_amount) and its fee lines.
* Formula: product_country.freight_price * weight + registration_fee. * Formula: product_country.freight_price * weight + registration_fee.
* Cost currently equals product catalog amount (no separate cost table yet). * 应付(cost_amount / pay_total)与产品目录价解耦,此处不再赋值,留空待接入真实成本数据源。
*/ */
private void fillProductAmountAndPay(TmsPriceQuoteResult r, BmsProductCountry base, private void fillProductAmountAndPay(TmsPriceQuoteResult r, BmsProductCountry base,
BigDecimal weight, RoundingMode rm, String roundMode) BigDecimal weight, RoundingMode rm, String roundMode)
@@ -955,8 +955,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
BigDecimal productFreight = base.getFreightPrice().multiply(weight).setScale(2, rm); BigDecimal productFreight = base.getFreightPrice().multiply(weight).setScale(2, rm);
BigDecimal productAmount = productFreight.add(baseReg).setScale(2, rm); BigDecimal productAmount = productFreight.add(baseReg).setScale(2, rm);
r.setProductAmount(productAmount); r.setProductAmount(productAmount);
r.setCostAmount(productAmount); // 应付(cost_amount / pay_total)不再用产品目录价兜底,留待后续接入真实成本数据源
r.setPayTotal(productAmount); r.setCostAmount(null);
r.setPayTotal(null);
String currency = normalizeCurrency(r.getCurrency()); String currency = normalizeCurrency(r.getCurrency());
List<TmsPriceQuoteFeeLine> payLines = new ArrayList<TmsPriceQuoteFeeLine>(); List<TmsPriceQuoteFeeLine> payLines = new ArrayList<TmsPriceQuoteFeeLine>();
TmsPriceQuoteFeeLine payFreight = feeLine(FEE_BASIC, feeNameOf(FEE_BASIC), 0L, productFreight, currency, roundMode, null); TmsPriceQuoteFeeLine payFreight = feeLine(FEE_BASIC, feeNameOf(FEE_BASIC), 0L, productFreight, currency, roundMode, null);
@@ -1077,14 +1078,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
{ {
result.setProductAmount(nvl(result.getProductAmount()).add(productExtra).setScale(2, rm)); result.setProductAmount(nvl(result.getProductAmount()).add(productExtra).setScale(2, rm));
} }
if (result.getCostAmount() != null || productExtra.compareTo(BigDecimal.ZERO) > 0) // cost_amount / pay_total 不再随产品目录价变化(含附加费),保持留空
{
result.setCostAmount(nvl(result.getCostAmount()).add(productExtra).setScale(2, rm));
}
if (result.getPayTotal() != null || productExtra.compareTo(BigDecimal.ZERO) > 0)
{
result.setPayTotal(nvl(result.getPayTotal()).add(productExtra).setScale(2, rm));
}
if (result.getRedlineAmount() != null || redlineExtra.compareTo(BigDecimal.ZERO) > 0) if (result.getRedlineAmount() != null || redlineExtra.compareTo(BigDecimal.ZERO) > 0)
{ {
result.setRedlineAmount(nvl(result.getRedlineAmount()).add(redlineExtra).setScale(2, rm)); result.setRedlineAmount(nvl(result.getRedlineAmount()).add(redlineExtra).setScale(2, rm));
@@ -1265,8 +1259,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
quote.setPayableTotal(result.getPayableTotal()); quote.setPayableTotal(result.getPayableTotal());
quote.setProductAmount(result.getProductAmount()); quote.setProductAmount(result.getProductAmount());
quote.setRedlineAmount(result.getRedlineAmount()); quote.setRedlineAmount(result.getRedlineAmount());
quote.setCostAmount(result.getCostAmount() != null ? result.getCostAmount() : result.getProductAmount()); quote.setCostAmount(result.getCostAmount());
quote.setPayTotal(result.getPayTotal() != null ? result.getPayTotal() : result.getProductAmount()); quote.setPayTotal(result.getPayTotal());
quote.setCurrency(result.getCurrency()); quote.setCurrency(result.getCurrency());
quote.setRoundMode(result.getRoundMode()); quote.setRoundMode(result.getRoundMode());
try try
@@ -1329,8 +1323,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
{ {
quoteFeeMapper.insertBatch(fees); quoteFeeMapper.insertBatch(fees);
} }
BigDecimal cost = result.getCostAmount() != null ? result.getCostAmount() : result.getProductAmount(); BigDecimal cost = result.getCostAmount();
BigDecimal pay = result.getPayTotal() != null ? result.getPayTotal() : cost; BigDecimal pay = result.getPayTotal();
quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal(), quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal(),
result.getProductAmount(), cost, pay); result.getProductAmount(), cost, pay);
} }
@@ -1395,8 +1389,10 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
r.setPayableTotal(quote.getPayableTotal()); r.setPayableTotal(quote.getPayableTotal());
r.setProductAmount(quote.getProductAmount()); r.setProductAmount(quote.getProductAmount());
r.setRedlineAmount(quote.getRedlineAmount()); r.setRedlineAmount(quote.getRedlineAmount());
r.setCostAmount(quote.getCostAmount()); // 历史缓存里的 cost_amount / pay_total 可能是早期按产品目录价写入的值,直接丢弃不回填。
r.setPayTotal(quote.getPayTotal()); // TODO 接入真实成本数据源后,改回回填 quote.getCostAmount() / quote.getPayTotal()。
r.setCostAmount(null);
r.setPayTotal(null);
r.setIncomeTotal(quote.getPayableTotal()); r.setIncomeTotal(quote.getPayableTotal());
r.setCurrency(normalizeCurrency(quote.getCurrency())); r.setCurrency(normalizeCurrency(quote.getCurrency()));
r.setRoundMode(quote.getRoundMode()); r.setRoundMode(quote.getRoundMode());
+6 -6
View File
@@ -117,13 +117,13 @@
<el-descriptions-item label="附加费">{{ formatMoney(result.surchargeAmount) }}</el-descriptions-item> <el-descriptions-item label="附加费">{{ formatMoney(result.surchargeAmount) }}</el-descriptions-item>
<el-descriptions-item label="产品价">{{ formatMoney(result.productAmount) }}</el-descriptions-item> <el-descriptions-item label="产品价">{{ formatMoney(result.productAmount) }}</el-descriptions-item>
<el-descriptions-item label="成本价"> <el-descriptions-item label="成本价">
<span class="cost">{{ formatMoney(result.costAmount != null ? result.costAmount : result.payTotal) }}</span> <span class="cost">{{ formatMoney(result.costAmount) }}</span>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="应收总额"> <el-descriptions-item label="应收总额">
<span class="payable">{{ formatMoney(result.payableTotal) }}</span> <span class="payable">{{ formatMoney(result.payableTotal) }}</span>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="应付总额"> <el-descriptions-item label="应付总额">
<span class="cost">{{ formatMoney(result.payTotal != null ? result.payTotal : result.costAmount) }}</span> <span class="cost">{{ formatMoney(result.payTotal) }}</span>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="试算来源"> <el-descriptions-item label="试算来源">
<el-tag v-if="result.fromCache" size="small" type="success">命中历史试算</el-tag> <el-tag v-if="result.fromCache" size="small" type="success">命中历史试算</el-tag>
@@ -161,7 +161,7 @@
<template #default="{ row }">{{ row.remark || '-' }}</template> <template #default="{ row }">{{ row.remark || '-' }}</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="formula-tip">销售试算:运费金额 = 套餐运费单价 × 计费重量;应收总额 = 运费金额 + 挂号费 + 附加费。产品价/成本价 = 目录运费单价 × 计费重量 + 目录挂号费。相同试算参数直接返回已落库明细。</div> <div class="formula-tip">销售试算:运费金额 = 套餐运费单价 × 计费重量;应收总额 = 运费金额 + 挂号费 + 附加费。产品价 = 目录运费单价 × 计费重量 + 目录挂号费 + 目录附加费。成本价/应付总额待接入真实成本数据源,暂不计算。相同试算参数直接返回已落库明细。</div>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
@@ -189,7 +189,7 @@
<el-tag size="small" :type="sourceTagType(row.matchSource)">{{ sourceLabel(row.matchSource) }}</el-tag> <el-tag size="small" :type="sourceTagType(row.matchSource)">{{ sourceLabel(row.matchSource) }}</el-tag>
</template> </template>
<template #col-costAmount="{ row }"> <template #col-costAmount="{ row }">
<span class="cost">{{ formatMoney(row.costAmount != null ? row.costAmount : row.payTotal) }}</span> <span class="cost">{{ formatMoney(row.costAmount) }}</span>
</template> </template>
<template #col-payableTotal="{ row }"> <template #col-payableTotal="{ row }">
<span class="payable">{{ formatMoney(row.payableTotal) }}</span> <span class="payable">{{ formatMoney(row.payableTotal) }}</span>
@@ -222,13 +222,13 @@
<el-descriptions-item label="附加费">{{ formatMoney(viewResult.surchargeAmount) }}</el-descriptions-item> <el-descriptions-item label="附加费">{{ formatMoney(viewResult.surchargeAmount) }}</el-descriptions-item>
<el-descriptions-item label="产品价">{{ formatMoney(viewResult.productAmount) }}</el-descriptions-item> <el-descriptions-item label="产品价">{{ formatMoney(viewResult.productAmount) }}</el-descriptions-item>
<el-descriptions-item label="成本价"> <el-descriptions-item label="成本价">
<span class="cost">{{ formatMoney(viewResult.costAmount != null ? viewResult.costAmount : viewResult.payTotal) }}</span> <span class="cost">{{ formatMoney(viewResult.costAmount) }}</span>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="应收总额"> <el-descriptions-item label="应收总额">
<span class="payable">{{ formatMoney(viewResult.payableTotal) }}</span> <span class="payable">{{ formatMoney(viewResult.payableTotal) }}</span>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="应付总额"> <el-descriptions-item label="应付总额">
<span class="cost">{{ formatMoney(viewResult.payTotal != null ? viewResult.payTotal : viewResult.costAmount) }}</span> <span class="cost">{{ formatMoney(viewResult.payTotal) }}</span>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="命中说明" :span="2">{{ viewResult.matchMessage || '-' }}</el-descriptions-item> <el-descriptions-item label="命中说明" :span="2">{{ viewResult.matchMessage || '-' }}</el-descriptions-item>
</el-descriptions> </el-descriptions>