提交产品列表

This commit is contained in:
wuweihua
2026-09-07 18:09:59 +08:00
parent 3994bd7998
commit 9e98cd791e
14 changed files with 528 additions and 39 deletions
@@ -248,9 +248,11 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
nd.setZdId(d.getZdId());
nd.setWsdId(d.getWsdId());
nd.setWeightLabel(d.getWeightLabel());
nd.setProductCountryId(d.getProductCountryId());
nd.setFvValue(d.getFvValue());
nd.setFvRegistrationFee(d.getFvRegistrationFee());
nd.setDiscountValue(d.getDiscountValue());
nd.setRoundMode(d.getRoundMode());
nd.setPrId(d.getPrId());
details.add(nd);
}
@@ -628,6 +630,19 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
}
fillProductCountryId(detail);
}
if (StringUtils.isEmpty(detail.getRoundMode()))
{
detail.setRoundMode("HALF_UP");
}
else
{
String mode = detail.getRoundMode().trim().toUpperCase();
if (!"UP".equals(mode) && !"DOWN".equals(mode) && !"HALF_UP".equals(mode))
{
throw new ServiceException("取值方式仅支持 UP / DOWN / HALF_UP");
}
detail.setRoundMode(mode);
}
if (StringUtils.isNotEmpty(detail.getCountryCode()))
{
detail.setCountryCode(detail.getCountryCode().toUpperCase());
@@ -119,7 +119,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
if (detailCount == 0)
{
TmsPriceQuoteResult r = buildFromRates(SRC_DEFAULT, base.getFreightPrice(), null, null,
base.getRegistrationFee(), base, productCode, productName, weight);
base.getRegistrationFee(), base, productCode, productName, weight, null);
fillPackage(r, bind, set);
r.setMatchMessage("FIXED package has no details; use bms_product_country default");
r.setCustomerId(bind.getCustomerId());
@@ -139,7 +139,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
return null;
}
TmsPriceQuoteResult r = buildFromRates(SRC_FIXED, detail.getFvValue(), null, null,
detail.getFvRegistrationFee(), base, productCode, productName, weight);
detail.getFvRegistrationFee(), base, productCode, productName, weight, detail.getRoundMode());
fillPackage(r, bind, set);
if (StringUtils.isNotEmpty(detail.getProductName()))
{
@@ -163,6 +163,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
{
int detailCount = detailMapper.countByPriceSetId(set.getPriceSetId());
BigDecimal discount = set.getDefaultDiscount();
String roundMode = null;
if (detailCount > 0)
{
PrcPriceSetDetail detail = detailMapper.selectDiscountMatch(set.getPriceSetId(), productCode);
@@ -174,6 +175,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
{
discount = detail.getDiscountValue();
}
roundMode = detail.getRoundMode();
}
if (discount == null
|| discount.compareTo(BigDecimal.ONE) < 0
@@ -186,10 +188,11 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
throw new ServiceException("FREIGHT_VALUE_MISSING: product default freight rate is null");
}
BigDecimal baseRate = base.getFreightPrice();
RoundingMode rm = resolveRoundingMode(roundMode);
BigDecimal rate = baseRate.multiply(discount)
.divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
.divide(new BigDecimal("100"), 4, rm);
TmsPriceQuoteResult r = buildFromRates(SRC_DISCOUNT, rate, baseRate, discount,
base.getRegistrationFee(), base, productCode, productName, weight);
base.getRegistrationFee(), base, productCode, productName, weight, roundMode);
fillPackage(r, bind, set);
r.setMatchMessage("hit customer DISCOUNT package; freight = default * discount%");
r.setCustomerId(bind.getCustomerId());
@@ -204,7 +207,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
throw new ServiceException("FREIGHT_VALUE_MISSING: product default freight or registration is null");
}
TmsPriceQuoteResult r = buildFromRates(SRC_DEFAULT, base.getFreightPrice(), null, null,
base.getRegistrationFee(), base, productCode, productName, weight);
base.getRegistrationFee(), base, productCode, productName, weight, null);
r.setCustomerId(customerId);
r.setMatchMessage(message);
return r;
@@ -212,7 +215,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
private TmsPriceQuoteResult buildFromRates(String source, BigDecimal freightRate,
BigDecimal baseFreightRate, BigDecimal discountPercent, BigDecimal registrationFee,
BmsProductCountry base, String productCode, String productName, BigDecimal weight)
BmsProductCountry base, String productCode, String productName, BigDecimal weight,
String roundMode)
{
if (freightRate == null)
{
@@ -222,8 +226,10 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
{
registrationFee = BigDecimal.ZERO;
}
BigDecimal freightAmount = freightRate.multiply(weight).setScale(2, RoundingMode.HALF_UP);
BigDecimal payable = freightAmount.add(registrationFee).setScale(2, RoundingMode.HALF_UP);
RoundingMode rm = resolveRoundingMode(roundMode);
String mode = normalizeRoundMode(roundMode);
BigDecimal freightAmount = freightRate.multiply(weight).setScale(2, rm);
BigDecimal payable = freightAmount.add(registrationFee).setScale(2, rm);
TmsPriceQuoteResult r = new TmsPriceQuoteResult();
r.setMatchSource(source);
@@ -244,9 +250,38 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
r.setFreightAmount(freightAmount);
r.setPayableTotal(payable);
r.setCurrency("RMB");
r.setRoundMode(mode);
return r;
}
private static String normalizeRoundMode(String roundMode)
{
if (StringUtils.isEmpty(roundMode))
{
return "HALF_UP";
}
String mode = roundMode.trim().toUpperCase();
if ("UP".equals(mode) || "DOWN".equals(mode) || "HALF_UP".equals(mode))
{
return mode;
}
return "HALF_UP";
}
private static RoundingMode resolveRoundingMode(String roundMode)
{
String mode = normalizeRoundMode(roundMode);
if ("UP".equals(mode))
{
return RoundingMode.UP;
}
if ("DOWN".equals(mode))
{
return RoundingMode.DOWN;
}
return RoundingMode.HALF_UP;
}
private void fillPackage(TmsPriceQuoteResult r, PrcCustomerPriceSet bind, PrcPriceSet set)
{
r.setPriceSetId(set.getPriceSetId());