提交产品列表
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());
|
||||
|
||||
@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="fvValue" column="fv_value" />
|
||||
<result property="fvRegistrationFee" column="fv_registration_fee" />
|
||||
<result property="discountValue" column="discount_value" />
|
||||
<result property="roundMode" column="round_mode" />
|
||||
<result property="prId" column="pr_id" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
<result property="updatedAt" column="updated_at" />
|
||||
@@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<sql id="selectPrcPriceSetDetailVo">
|
||||
select psd_id, price_set_id, product_code, product_name, country_code, country_name,
|
||||
zd_id, wsd_id, weight_label, product_country_id, fv_value, fv_registration_fee,
|
||||
discount_value, pr_id, created_at, updated_at
|
||||
discount_value, round_mode, pr_id, created_at, updated_at
|
||||
from prc_price_set_detail
|
||||
</sql>
|
||||
|
||||
@@ -73,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="fvValue != null">fv_value,</if>
|
||||
<if test="fvRegistrationFee != null">fv_registration_fee,</if>
|
||||
<if test="discountValue != null">discount_value,</if>
|
||||
<if test="roundMode != null and roundMode != ''">round_mode,</if>
|
||||
<if test="prId != null">pr_id,</if>
|
||||
created_at
|
||||
) values (
|
||||
@@ -88,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="fvValue != null">#{fvValue},</if>
|
||||
<if test="fvRegistrationFee != null">#{fvRegistrationFee},</if>
|
||||
<if test="discountValue != null">#{discountValue},</if>
|
||||
<if test="roundMode != null and roundMode != ''">#{roundMode},</if>
|
||||
<if test="prId != null">#{prId},</if>
|
||||
sysdate()
|
||||
)
|
||||
@@ -107,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
fv_value = #{fvValue},
|
||||
fv_registration_fee = #{fvRegistrationFee},
|
||||
discount_value = #{discountValue},
|
||||
<if test="roundMode != null and roundMode != ''">round_mode = #{roundMode},</if>
|
||||
pr_id = #{prId},
|
||||
updated_at = sysdate()
|
||||
</set>
|
||||
|
||||
@@ -47,6 +47,7 @@ CREATE TABLE IF NOT EXISTS prc_price_set_detail (
|
||||
fv_value DECIMAL(10,4) DEFAULT NULL COMMENT '运费单价 RMB/KG',
|
||||
fv_registration_fee DECIMAL(10,2) DEFAULT NULL COMMENT '挂号费 RMB/票',
|
||||
discount_value DECIMAL(5,2) DEFAULT NULL COMMENT '明细折扣百分数,DISCOUNT 可覆盖默认',
|
||||
round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
pr_id INT(11) DEFAULT NULL COMMENT '关联价格规则id',
|
||||
created_at DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||
updated_at DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Add round_mode to price set detail
|
||||
-- dict: bms_round_mode (UP / DOWN / HALF_UP)
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE prc_price_set_detail
|
||||
ADD COLUMN round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT 'round mode (dict bms_round_mode)' AFTER discount_value;
|
||||
Reference in New Issue
Block a user