修改提交

This commit is contained in:
2026-09-03 21:33:23 +08:00
parent baabfdabba
commit bfb139c7c7
3 changed files with 7 additions and 9 deletions
@@ -72,7 +72,7 @@ public class CustomerDimensionWeightingService {
return rules.stream()
.filter(rule -> rule.contains(measured))
.findFirst()
.map(Rule::weighted)
.map(rule -> rule.weightedActualDimensions(lengthCm, widthCm, heightCm))
.orElseGet(() -> actualDimensions(lengthCm, widthCm, heightCm));
}
@@ -108,7 +108,8 @@ public class InboundMeasurementService {
request.items().stream().map(InboundMeasurementRequests.ItemRequest::chargeRuleId)
.filter(java.util.Objects::nonNull).distinct().forEach(ruleId -> {
var rule = fbaMasterDataService.rule(tenantId, ruleId);
if (!"ACTIVE".equals(rule.getStatus()) || !java.util.Objects.equals(rule.getCustomerId(), inbound.getCustomerId())) {
long inboundCustomerId = inbound.getCustomerId() == null ? tenantId : inbound.getCustomerId();
if (!"ACTIVE".equals(rule.getStatus()) || !java.util.Objects.equals(rule.getCustomerId(), inboundCustomerId)) {
throw new BizException(ResultCode.VALIDATION_FAILED, "测量明细绑定的计费规则不属于当前客户或已停用");
}
});
@@ -263,16 +263,13 @@ public class MeasurementBatchService {
}
private CustomerChargeRuleEntity requireCoefficientRule(long tenantId, Long customerId, Long ruleId) {
if (customerId == null || customerId <= 0) {
if (ruleId == null) return null;
throw new BizException(ResultCode.VALIDATION_FAILED, "入库单客户无效,不能应用计费系数");
}
Long effectiveCustomerId = customerId == null || customerId <= 0 ? tenantId : customerId;
CustomerChargeRuleEntity rule = ruleId == null
? pricingRepository.findDefaultRule(tenantId, customerId)
? pricingRepository.findDefaultRule(tenantId, effectiveCustomerId)
: pricingRepository.findRule(tenantId, ruleId);
if (rule == null || !"ACTIVE".equals(rule.getStatus())
|| !Boolean.TRUE.equals(rule.getDefaultRule()) || !customerId.equals(rule.getCustomerId())) {
throw new BizException(ResultCode.VALIDATION_FAILED, "计费规则不属于当前客户、未启用或未设置默认规则");
|| !effectiveCustomerId.equals(rule.getCustomerId())) {
throw new BizException(ResultCode.VALIDATION_FAILED, "计费规则不属于当前客户或已停用");
}
return rule;
}