优化计费规则注释,新增三边规则处理逻辑
This commit is contained in:
+1
-1
@@ -3127,7 +3127,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务规则计费重量(VOL_8000 等)。
|
||||
* 业务规则计费重量(THREE_SIDE / VOL_8000)。
|
||||
* 如需禁用:注释掉 resolveWeightByRule 调用,始终返回 baseWeight。
|
||||
*/
|
||||
private BigDecimal applyBizRuleWeight(TmsPriceBillRequest request, BigDecimal baseWeight)
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface IBmsBizRuleService
|
||||
int deleteByIds(Long[] ruleIds);
|
||||
|
||||
/**
|
||||
* 将生效的重量规则(目前为 VOL_8000)应用到计费请求。
|
||||
* 将生效的重量规则(THREE_SIDE / VOL_8000)应用到计费请求。
|
||||
* @return 规则命中时返回覆盖后的计费重量;无规则适用时返回 null
|
||||
*/
|
||||
BigDecimal resolveWeightByRule(TmsPriceBillRequest request, BigDecimal systemWeight);
|
||||
|
||||
+52
-16
@@ -136,8 +136,12 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// VOL_8000 在本地入库 / 计费时应用。THREE_SIDE 仅作为配置
|
||||
// (上游已应用该产品规则)。
|
||||
// 先三边之和取重,未命中再走 VOL_8000
|
||||
BigDecimal threeSide = resolveThreeSideWeight(request, systemWeight);
|
||||
if (threeSide != null)
|
||||
{
|
||||
return threeSide;
|
||||
}
|
||||
BigDecimal vol8000 = resolveVol8000(request, systemWeight);
|
||||
if (vol8000 != null)
|
||||
{
|
||||
@@ -146,6 +150,47 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 三边之和取重:命中 THREE_SIDE 规则时,
|
||||
* L+W+H < 上限取本地收货重;>= 上限取已有计费重。
|
||||
*
|
||||
* @param existingChargeWeight 当前已有计费重(未被三边规则覆盖前)
|
||||
* @return 命中规则时返回计费重;未命中返回 null
|
||||
*/
|
||||
private BigDecimal resolveThreeSideWeight(TmsPriceBillRequest request, BigDecimal existingChargeWeight)
|
||||
{
|
||||
List<BmsBizRule> rules = bizRuleMapper.selectActiveByType(RULE_TYPE_THREE_SIDE);
|
||||
if (rules == null || rules.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (BmsBizRule rule : rules)
|
||||
{
|
||||
if (!matchThreeSideDims(rule, request, existingChargeWeight))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (rule.getSideSumMax() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal sum = sideSum(request);
|
||||
if (sum == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// 三边之和 < 上限(如 90):取本地收货重;无收货重则保留已有计费重
|
||||
if (sum.compareTo(rule.getSideSumMax()) < 0)
|
||||
{
|
||||
BigDecimal receiveWeight = firstPositive(request.getReceiveWeight());
|
||||
return receiveWeight != null ? receiveWeight : existingChargeWeight;
|
||||
}
|
||||
// 三边之和 >= 上限:保留已有计费重
|
||||
return existingChargeWeight;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* VOL_8000:chargeWeight = max(L*W*H/8000, receive_weight)。
|
||||
* 将体积重(/8000)与收货重比较。
|
||||
@@ -273,7 +318,10 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService
|
||||
return new ArrayList<String>(set);
|
||||
}
|
||||
|
||||
private boolean matchThreeSide(BmsBizRule rule, TmsPriceBillRequest request, BigDecimal systemWeight)
|
||||
/**
|
||||
* 三边规则维度匹配(不包含三边和阈值判断)。
|
||||
*/
|
||||
private boolean matchThreeSideDims(BmsBizRule rule, TmsPriceBillRequest request, BigDecimal systemWeight)
|
||||
{
|
||||
if (rule == null)
|
||||
{
|
||||
@@ -292,19 +340,7 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService
|
||||
return false;
|
||||
}
|
||||
BigDecimal checkWeight = firstPositive(request.getReceiveWeight(), systemWeight, request.getWeight());
|
||||
if (!inWeightRange(checkWeight, rule.getWeightMin(), rule.getWeightMax()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (rule.getSideSumMax() != null)
|
||||
{
|
||||
BigDecimal sum = sideSum(request);
|
||||
if (sum == null || sum.compareTo(rule.getSideSumMax()) >= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return inWeightRange(checkWeight, rule.getWeightMin(), rule.getWeightMax());
|
||||
}
|
||||
|
||||
private boolean dimMatch(String requestCode, String ruleCode, boolean tryProductMap)
|
||||
|
||||
Reference in New Issue
Block a user