⚡ 固定金额与里程类计费跳过数量单位匹配
按车辆、固定金额、按公里/吨公里等计费要素不再要求货物数量单位一致。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+29
-3
@@ -1113,21 +1113,47 @@ public class ReceivablePayableDetailServiceImpl
|
|||||||
* 费用生成规则命中:
|
* 费用生成规则命中:
|
||||||
* 1. 货物需满足匹配规则(始发/目的/货类/货名)
|
* 1. 货物需满足匹配规则(始发/目的/货类/货名)
|
||||||
* 2. 普通计费要素还要求货物数量单位与计费单位一致
|
* 2. 普通计费要素还要求货物数量单位与计费单位一致
|
||||||
* 3. 按里程、按吨·公里按运单里程(×重量)另行计算,不校验数量单位
|
* 3. 按里程/按公里、按吨·公里/按吨公里、按车辆、固定金额不依赖货物数量单位,不校验数量单位
|
||||||
*/
|
*/
|
||||||
private boolean matchesBillingRule(Map<?, ?> raw, Map<String, Object> rule, Waybill feeWaybill) {
|
private boolean matchesBillingRule(Map<?, ?> raw, Map<String, Object> rule, Waybill feeWaybill) {
|
||||||
if (!matchesRule(raw, feeWaybill)) {
|
if (!matchesRule(raw, feeWaybill)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String element = stringValue(rule, "billingElement", "");
|
String element = stringValue(rule, "billingElement", "");
|
||||||
if (isMileageBasedElement(element)) {
|
if (skipsQuantityUnitMatch(element)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return matchesBillingUnit(rule, feeWaybill);
|
return matchesBillingUnit(rule, feeWaybill);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMileageBasedElement(String element) {
|
private boolean isMileageBasedElement(String element) {
|
||||||
return "按里程".equals(element) || "按吨·公里".equals(element);
|
String normalized = normalizeBillingElement(element);
|
||||||
|
return "按里程".equals(normalized)
|
||||||
|
|| "按公里".equals(normalized)
|
||||||
|
|| "按吨公里".equals(normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不计货物数量单位的计费要素:里程类按运单里程计算;按车辆/固定金额按整单(量=1)计费。
|
||||||
|
*/
|
||||||
|
private boolean skipsQuantityUnitMatch(String element) {
|
||||||
|
String normalized = normalizeBillingElement(element);
|
||||||
|
return isMileageBasedElement(normalized)
|
||||||
|
|| "按车辆".equals(normalized)
|
||||||
|
|| "固定金额(整单一口价)".equals(normalized)
|
||||||
|
|| "固定金额".equals(normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 统一计费要素文案,兼容「按公里 / 按吨公里 / 按吨·公里」等写法 */
|
||||||
|
private String normalizeBillingElement(String element) {
|
||||||
|
if (element == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return element.trim()
|
||||||
|
.replace("·", "")
|
||||||
|
.replace(".", "")
|
||||||
|
.replace(".", "")
|
||||||
|
.replace(" ", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchesBillingUnit(Map<String, Object> rule, Waybill feeWaybill) {
|
private boolean matchesBillingUnit(Map<String, Object> rule, Waybill feeWaybill) {
|
||||||
|
|||||||
Reference in New Issue
Block a user