修改应付总额显示

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.setSurchargeAmount(result.getSurchargeAmount());
bill.setIncomeTotal(result.getPayableTotal());
BigDecimal payTotal = result.getPayTotal();
if (payTotal == null)
{
payTotal = result.getProductAmount();
}
bill.setPayTotal(payTotal == null ? BigDecimal.ZERO : payTotal);
// 应付总额与产品目录价解耦:试算未产出 pay_total 时留空,不再用 product_amount 兜底
bill.setPayTotal(result.getPayTotal());
bill.setCurrency(result.getCurrency());
bill.setRoundMode(result.getRoundMode());
// 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;
}
/** 应付主表与订单计费一对一落库;成本价/应付=产品目录价,同步写入 product_amount;红线价同步写入 redline_amount。 */
/** 应付主表与订单计费一对一落库;product_amount 取产品目录价、redline_amount 取红线价;应付/成本价留空待接入真实成本源。 */
private PrcPayBill persistPayBill(PrcOrderBill bill, TmsPriceQuoteResult result)
{
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
{
return null;
}
BigDecimal pay = nz(bill.getPayTotal());
PrcPayBill existed = payBillMapper.selectByBillId(bill.getBillId());
PrcPayBill row = existed == null ? new PrcPayBill() : existed;
if (existed == null)
@@ -1498,12 +1493,11 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
row.setCreateBy(bill.getCreateBy());
}
row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency());
// product/cost = catalog; redline from quote
BigDecimal product = result == null ? null : result.getProductAmount();
row.setProductAmount(product);
// product = catalog; redline from quote; cost/pay 不再等于产品目录价
row.setProductAmount(result == null ? null : result.getProductAmount());
row.setRedlineAmount(result == null ? null : result.getRedlineAmount());
row.setCostAmount(pay);
row.setPayTotal(pay);
row.setCostAmount(result == null ? null : result.getCostAmount());
row.setPayTotal(result == null ? null : result.getPayTotal());
row.setBelongSaler(bill.getBelongSaler());
row.setBelongSalerCode(bill.getBelongSalerCode());
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.
* Cost currently equals product catalog amount (no separate cost table yet).
* 应付(cost_amount / pay_total)与产品目录价解耦,此处不再赋值,留空待接入真实成本数据源。
*/
private void fillProductAmountAndPay(TmsPriceQuoteResult r, BmsProductCountry base,
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 productAmount = productFreight.add(baseReg).setScale(2, rm);
r.setProductAmount(productAmount);
r.setCostAmount(productAmount);
r.setPayTotal(productAmount);
// 应付(cost_amount / pay_total)不再用产品目录价兜底,留待后续接入真实成本数据源
r.setCostAmount(null);
r.setPayTotal(null);
String currency = normalizeCurrency(r.getCurrency());
List<TmsPriceQuoteFeeLine> payLines = new ArrayList<TmsPriceQuoteFeeLine>();
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));
}
if (result.getCostAmount() != null || productExtra.compareTo(BigDecimal.ZERO) > 0)
{
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));
}
// cost_amount / pay_total 不再随产品目录价变化(含附加费),保持留空
if (result.getRedlineAmount() != null || redlineExtra.compareTo(BigDecimal.ZERO) > 0)
{
result.setRedlineAmount(nvl(result.getRedlineAmount()).add(redlineExtra).setScale(2, rm));
@@ -1265,8 +1259,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
quote.setPayableTotal(result.getPayableTotal());
quote.setProductAmount(result.getProductAmount());
quote.setRedlineAmount(result.getRedlineAmount());
quote.setCostAmount(result.getCostAmount() != null ? result.getCostAmount() : result.getProductAmount());
quote.setPayTotal(result.getPayTotal() != null ? result.getPayTotal() : result.getProductAmount());
quote.setCostAmount(result.getCostAmount());
quote.setPayTotal(result.getPayTotal());
quote.setCurrency(result.getCurrency());
quote.setRoundMode(result.getRoundMode());
try
@@ -1329,8 +1323,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
{
quoteFeeMapper.insertBatch(fees);
}
BigDecimal cost = result.getCostAmount() != null ? result.getCostAmount() : result.getProductAmount();
BigDecimal pay = result.getPayTotal() != null ? result.getPayTotal() : cost;
BigDecimal cost = result.getCostAmount();
BigDecimal pay = result.getPayTotal();
quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal(),
result.getProductAmount(), cost, pay);
}
@@ -1395,8 +1389,10 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
r.setPayableTotal(quote.getPayableTotal());
r.setProductAmount(quote.getProductAmount());
r.setRedlineAmount(quote.getRedlineAmount());
r.setCostAmount(quote.getCostAmount());
r.setPayTotal(quote.getPayTotal());
// 历史缓存里的 cost_amount / pay_total 可能是早期按产品目录价写入的值,直接丢弃不回填。
// TODO 接入真实成本数据源后,改回回填 quote.getCostAmount() / quote.getPayTotal()。
r.setCostAmount(null);
r.setPayTotal(null);
r.setIncomeTotal(quote.getPayableTotal());
r.setCurrency(normalizeCurrency(quote.getCurrency()));
r.setRoundMode(quote.getRoundMode());