增加红线价计费

This commit is contained in:
wuweihua
2026-10-09 17:45:49 +08:00
parent f1f6ddd368
commit e73b85ed78
2 changed files with 54 additions and 5 deletions
@@ -1417,7 +1417,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
return fees; return fees;
} }
/** 应收主表与订单计费一对一落库;销售价=套餐计费,产品价=产品目录价;红线价预留。 */ /** 应收主表与订单计费一对一落库;销售价=套餐计费,产品价=产品目录价,红线价=红线目录价(含 REDLINE 附加费)。 */
private PrcIncomeBill persistIncomeBill(PrcOrderBill bill, TmsPriceQuoteResult result) private PrcIncomeBill persistIncomeBill(PrcOrderBill bill, TmsPriceQuoteResult result)
{ {
if (bill == null || StringUtils.isEmpty(bill.getBillId())) if (bill == null || StringUtils.isEmpty(bill.getBillId()))
@@ -1434,8 +1434,9 @@ 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 catalog + redline from quote
row.setProductAmount(result == null ? null : result.getProductAmount()); row.setProductAmount(result == null ? null : result.getProductAmount());
row.setRedlineAmount(result == null ? null : result.getRedlineAmount());
row.setSalesAmount(sales); row.setSalesAmount(sales);
row.setIncomeTotal(sales); row.setIncomeTotal(sales);
row.setBelongSaler(bill.getBelongSaler()); row.setBelongSaler(bill.getBelongSaler());
@@ -1480,7 +1481,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
return fees; return fees;
} }
/** 应付主表与订单计费一对一落库;成本价/应付=产品目录价,同步写入 product_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()))
@@ -1497,9 +1498,10 @@ 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
BigDecimal product = result == null ? null : result.getProductAmount(); BigDecimal product = result == null ? null : result.getProductAmount();
row.setProductAmount(product); row.setProductAmount(product);
row.setRedlineAmount(result == null ? null : result.getRedlineAmount());
row.setCostAmount(pay); row.setCostAmount(pay);
row.setPayTotal(pay); row.setPayTotal(pay);
row.setBelongSaler(bill.getBelongSaler()); row.setBelongSaler(bill.getBelongSaler());
@@ -1563,6 +1565,12 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
r.setBizDate(bill.getBizDate()); r.setBizDate(bill.getBizDate());
r.setFeeDetails(toIncomeFeeLines(incomeFees)); r.setFeeDetails(toIncomeFeeLines(incomeFees));
r.setPayFeeDetails(toPayFeeLines(payFees)); r.setPayFeeDetails(toPayFeeLines(payFees));
PrcIncomeBill incomeBill = incomeBillMapper.selectByBillId(bill.getBillId());
if (incomeBill != null)
{
r.setProductAmount(incomeBill.getProductAmount());
r.setRedlineAmount(incomeBill.getRedlineAmount());
}
return r; return r;
} }
@@ -989,7 +989,27 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
} }
BigDecimal baseReg = base.getRegistrationFee() == null ? BigDecimal.ZERO : base.getRegistrationFee(); BigDecimal baseReg = base.getRegistrationFee() == null ? BigDecimal.ZERO : base.getRegistrationFee();
BigDecimal freight = base.getFreightPrice().multiply(weight).setScale(2, rm); BigDecimal freight = base.getFreightPrice().multiply(weight).setScale(2, rm);
r.setRedlineAmount(freight.add(baseReg).setScale(2, rm)); BigDecimal regScaled = baseReg.setScale(2, rm);
r.setRedlineAmount(freight.add(regScaled).setScale(2, rm));
// Stash freight/reg on existing payFeeDetails for income fee-line apportionment
if (r.getPayFeeDetails() != null)
{
for (TmsPriceQuoteFeeLine line : r.getPayFeeDetails())
{
if (line == null || line.getFeeType() == null)
{
continue;
}
if (FEE_BASIC.equals(line.getFeeType()))
{
line.setRedlineAmount(freight);
}
else if (FEE_REG.equals(line.getFeeType()))
{
line.setRedlineAmount(regScaled);
}
}
}
} }
private void applySurchargesAndFees(TmsPriceQuoteResult result) private void applySurchargesAndFees(TmsPriceQuoteResult result)
@@ -1006,11 +1026,15 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>(); List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>();
BigDecimal productFreight = productAmountOf(result.getPayFeeDetails(), FEE_BASIC); BigDecimal productFreight = productAmountOf(result.getPayFeeDetails(), FEE_BASIC);
BigDecimal productReg = productAmountOf(result.getPayFeeDetails(), FEE_REG); BigDecimal productReg = productAmountOf(result.getPayFeeDetails(), FEE_REG);
BigDecimal redlineFreight = redlineAmountOf(result.getPayFeeDetails(), FEE_BASIC);
BigDecimal redlineReg = redlineAmountOf(result.getPayFeeDetails(), FEE_REG);
TmsPriceQuoteFeeLine basicLine = feeLine(FEE_BASIC, feeNameOf(FEE_BASIC), 0L, freightAmount, currency, result.getRoundMode(), null); TmsPriceQuoteFeeLine basicLine = feeLine(FEE_BASIC, feeNameOf(FEE_BASIC), 0L, freightAmount, currency, result.getRoundMode(), null);
basicLine.setProductAmount(productFreight); basicLine.setProductAmount(productFreight);
basicLine.setRedlineAmount(redlineFreight);
lines.add(basicLine); lines.add(basicLine);
TmsPriceQuoteFeeLine regLine = feeLine(FEE_REG, feeNameOf(FEE_REG), 0L, registrationFee, currency, result.getRoundMode(), null); TmsPriceQuoteFeeLine regLine = feeLine(FEE_REG, feeNameOf(FEE_REG), 0L, registrationFee, currency, result.getRoundMode(), null);
regLine.setProductAmount(productReg); regLine.setProductAmount(productReg);
regLine.setRedlineAmount(redlineReg);
lines.add(regLine); lines.add(regLine);
BigDecimal surchargeTotal = BigDecimal.ZERO; BigDecimal surchargeTotal = BigDecimal.ZERO;
@@ -1477,6 +1501,23 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
return null; return null;
} }
/** Read redline catalog amount for a fee type from payFeeDetails. */
private static BigDecimal redlineAmountOf(List<TmsPriceQuoteFeeLine> payLines, String feeType)
{
if (payLines == null || feeType == null)
{
return null;
}
for (TmsPriceQuoteFeeLine line : payLines)
{
if (line != null && feeType.equals(line.getFeeType()))
{
return line.getRedlineAmount();
}
}
return null;
}
private static TmsPriceQuoteFeeLine feeLine(String feeType, String feeName, Long scId, BigDecimal amount, private static TmsPriceQuoteFeeLine feeLine(String feeType, String feeName, Long scId, BigDecimal amount,
String currency, String roundMode, String remark) String currency, String roundMode, String remark)
{ {