提交产品列表
This commit is contained in:
@@ -30,6 +30,8 @@ public class PrcPriceSetDetail implements Serializable
|
||||
private BigDecimal fvValue;
|
||||
private BigDecimal fvRegistrationFee;
|
||||
private BigDecimal discountValue;
|
||||
/** 取值方式:UP / DOWN / HALF_UP(字典 bms_round_mode) */
|
||||
private String roundMode;
|
||||
private Integer prId;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createdAt;
|
||||
@@ -62,6 +64,8 @@ public class PrcPriceSetDetail implements Serializable
|
||||
public void setFvRegistrationFee(BigDecimal fvRegistrationFee) { this.fvRegistrationFee = fvRegistrationFee; }
|
||||
public BigDecimal getDiscountValue() { return discountValue; }
|
||||
public void setDiscountValue(BigDecimal discountValue) { this.discountValue = discountValue; }
|
||||
public String getRoundMode() { return roundMode; }
|
||||
public void setRoundMode(String roundMode) { this.roundMode = roundMode; }
|
||||
public Integer getPrId() { return prId; }
|
||||
public void setPrId(Integer prId) { this.prId = prId; }
|
||||
public Date getCreatedAt() { return createdAt; }
|
||||
|
||||
@@ -49,6 +49,8 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
/** freightAmount + registrationFee */
|
||||
private BigDecimal payableTotal;
|
||||
private String currency = "RMB";
|
||||
/** ????? UP / DOWN / HALF_UP */
|
||||
private String roundMode;
|
||||
|
||||
public String getMatchSource() { return matchSource; }
|
||||
public void setMatchSource(String matchSource) { this.matchSource = matchSource; }
|
||||
@@ -102,4 +104,6 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
public void setPayableTotal(BigDecimal payableTotal) { this.payableTotal = payableTotal; }
|
||||
public String getCurrency() { return currency; }
|
||||
public void setCurrency(String currency) { this.currency = currency; }
|
||||
public String getRoundMode() { return roundMode; }
|
||||
public void setRoundMode(String roundMode) { this.roundMode = roundMode; }
|
||||
}
|
||||
|
||||
+15
@@ -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());
|
||||
|
||||
+43
-8
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user