diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java index 0d755e8e..d51e6360 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java @@ -235,7 +235,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService BigDecimal calcWeight = resolveBillCalcWeight(request, existed, systemWeight); request.setWeight(calcWeight); TmsPriceQuoteResult result = tmsPriceQuoteService.calculate(request); - persistBill(request, systemWeight, bizDate, result); + // 规则命中时覆盖落库 weight;有 charge_weight 覆盖时保留原系统 weight + BigDecimal persistWeight = resolvePersistSystemWeight(request, existed, systemWeight, calcWeight); + persistBill(request, persistWeight, bizDate, result); return result; } catch (RuntimeException e) @@ -2065,8 +2067,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService { bill.setCountryName(result.getCountryName()); } - // weight=上游计费重(DIMENSIONAL_WEIGHT_FACTOR);charge_weight=客户确认重/人工修改 -bill.setWeight(weight); + // weight:默认上游系统重;业务规则命中时写入规则计费重;charge_weight=客户确认重/人工修改 + bill.setWeight(weight); bill.setBizDate(bizDate); bill.setTmsId(request.getTmsId() == null ? null : Long.valueOf(request.getTmsId())); bill.setPriceSetId(result.getPriceSetId()); @@ -3116,6 +3118,25 @@ bill.setWeight(weight); return applyBizRuleWeight(request, systemWeight); } + /** + * 落库 weight:无 charge_weight 覆盖时写入计费用重(含规则命中结果); + * 有客户确认重/人工改重时保留原系统 weight。 + */ + private BigDecimal resolvePersistSystemWeight(TmsPriceBillRequest request, PrcOrderBill existed, + BigDecimal systemWeight, BigDecimal calcWeight) + { + BigDecimal preferred = positiveOrNull(request == null ? null : request.getChargeWeight()); + if (preferred == null && !isUpstreamSyncRequest(request) && hasChargeWeightOverride(existed)) + { + preferred = existed.getChargeWeight(); + } + if (preferred != null) + { + return systemWeight; + } + return calcWeight != null ? calcWeight : systemWeight; + } + /** * 上游同步/软失败:weight=上游计费重;charge_weight=客户确认重(无值则 null)。 */ @@ -3133,7 +3154,7 @@ bill.setWeight(weight); } /** - * 业务规则计费重量(THREE_SIDE / VOL_8000)。 + * 业务规则计费重量(THREE_SIDE / USE_RECEIVE_WEIGHT / VOL_8000)。 * 如需禁用:注释掉 resolveWeightByRule 调用,始终返回 baseWeight。 */ private BigDecimal applyBizRuleWeight(TmsPriceBillRequest request, BigDecimal baseWeight) diff --git a/bms-back/bms-system/src/main/java/com/bms/system/service/IBmsBizRuleService.java b/bms-back/bms-system/src/main/java/com/bms/system/service/IBmsBizRuleService.java index 1353209d..33ee7905 100644 --- a/bms-back/bms-system/src/main/java/com/bms/system/service/IBmsBizRuleService.java +++ b/bms-back/bms-system/src/main/java/com/bms/system/service/IBmsBizRuleService.java @@ -21,7 +21,7 @@ public interface IBmsBizRuleService int deleteByIds(Long[] ruleIds); /** - * 将生效的重量规则(THREE_SIDE / VOL_8000)应用到计费请求。 + * 将生效的重量规则(THREE_SIDE / USE_RECEIVE_WEIGHT / VOL_8000)应用到计费请求。 * @return 规则命中时返回覆盖后的计费重量;无规则适用时返回 null */ BigDecimal resolveWeightByRule(TmsPriceBillRequest request, BigDecimal systemWeight); diff --git a/bms-back/bms-system/src/main/java/com/bms/system/service/impl/BmsBizRuleServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/system/service/impl/BmsBizRuleServiceImpl.java index 8fad44a9..fa011a64 100644 --- a/bms-back/bms-system/src/main/java/com/bms/system/service/impl/BmsBizRuleServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/system/service/impl/BmsBizRuleServiceImpl.java @@ -27,6 +27,8 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService public static final String RULE_TYPE_THREE_SIDE = "THREE_SIDE"; /** 计费重量 = max(L*W*H/8000, weightSource)。 */ public static final String RULE_TYPE_VOL_8000 = "VOL_8000"; + /** 命中后按取值字段取重(默认实重/收货重)。 */ + public static final String RULE_TYPE_USE_RECEIVE_WEIGHT = "USE_RECEIVE_WEIGHT"; public static final String WEIGHT_SOURCE_RECEIVE = "RECEIVE_WEIGHT"; public static final String WEIGHT_SOURCE_CHARGE = "CHARGE_WEIGHT"; public static final String WEIGHT_SOURCE_VOLUME = "VOLUME_WEIGHT"; @@ -137,11 +139,17 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService return null; } // 先三边之和取重,未命中再走 VOL_8000 + // 优先:三边 > 取实重(收货重) > VOL_8000 BigDecimal threeSide = resolveThreeSideWeight(request, systemWeight); if (threeSide != null) { return threeSide; } + BigDecimal useReceive = resolveUseReceiveWeight(request, systemWeight); + if (useReceive != null) + { + return useReceive; + } BigDecimal vol8000 = resolveVol8000(request, systemWeight); if (vol8000 != null) { @@ -223,6 +231,34 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService return null; } + /** + * 取实重(收货重):按产品/国家/客户/重量段命中后, + * 按取值字段取重(默认 RECEIVE_WEIGHT:实重优先,次收货重)。 + */ + private BigDecimal resolveUseReceiveWeight(TmsPriceBillRequest request, BigDecimal systemWeight) + { + List rules = bizRuleMapper.selectActiveByType(RULE_TYPE_USE_RECEIVE_WEIGHT); + if (rules == null || rules.isEmpty()) + { + return null; + } + for (BmsBizRule rule : rules) + { + if (!matchVol8000(rule, request, systemWeight)) + { + continue; + } + String source = StringUtils.isEmpty(rule.getWeightSource()) + ? WEIGHT_SOURCE_RECEIVE : rule.getWeightSource(); + BigDecimal picked = pickWeight(source, request, systemWeight); + if (picked != null) + { + return picked.setScale(3, RoundingMode.HALF_UP); + } + } + return null; + } + private boolean matchVol8000(BmsBizRule rule, TmsPriceBillRequest request, BigDecimal systemWeight) { if (rule == null) @@ -571,7 +607,9 @@ public class BmsBizRuleServiceImpl implements IBmsBizRuleService { throw new ServiceException("规则类型不能为空"); } - if (RULE_TYPE_VOL_8000.equalsIgnoreCase(row.getRuleType()) && StringUtils.isEmpty(row.getWeightSource())) + if ((RULE_TYPE_VOL_8000.equalsIgnoreCase(row.getRuleType()) + || RULE_TYPE_USE_RECEIVE_WEIGHT.equalsIgnoreCase(row.getRuleType())) + && StringUtils.isEmpty(row.getWeightSource())) { row.setWeightSource(WEIGHT_SOURCE_RECEIVE); } diff --git a/bms-back/sql/data/biz_rule_use_receive_weight.sql b/bms-back/sql/data/biz_rule_use_receive_weight.sql new file mode 100644 index 00000000..f8d6b231 --- /dev/null +++ b/bms-back/sql/data/biz_rule_use_receive_weight.sql @@ -0,0 +1,7 @@ +-- USE_RECEIVE_WEIGHT: hit by product/country/customer/weight range, use receive/actual weight +SET NAMES utf8mb4; + +INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark) +SELECT 3, N'取实重(收货重)', 'USE_RECEIVE_WEIGHT', 'bms_biz_rule_type', '', 'warning', 'N', '0', 'admin', sysdate(), + N'命中后按取值字段取重;实重优先 actual_weight,次收货重 receive_weight' +FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data WHERE dict_type = 'bms_biz_rule_type' AND dict_value = 'USE_RECEIVE_WEIGHT'); diff --git a/bms-front/src/views/data/rule/config/index.vue b/bms-front/src/views/data/rule/config/index.vue index 7ec74903..30e967f7 100644 --- a/bms-front/src/views/data/rule/config/index.vue +++ b/bms-front/src/views/data/rule/config/index.vue @@ -112,6 +112,14 @@ style="margin-bottom: 12px" title="计费重 = max(长×宽×高(cm)/8000, 收货重);无尺寸时不覆盖" /> + 正常 diff --git a/bms-front/src/views/price/label/components/LabelVersionProductDrawer.vue b/bms-front/src/views/price/label/components/LabelVersionProductDrawer.vue index f8f28f75..8b65e05f 100644 --- a/bms-front/src/views/price/label/components/LabelVersionProductDrawer.vue +++ b/bms-front/src/views/price/label/components/LabelVersionProductDrawer.vue @@ -33,8 +33,9 @@ - + @@ -112,6 +113,23 @@ 保存 + + +
+ + +
+ +
@@ -119,9 +137,11 @@ import { listLabelProducts, listLabelProductChannels, - replaceLabelProductChannels + replaceLabelProductChannels, + getLabelProduct } from '@/api/price/label' import { listChannelOptions } from '@/api/masterdata/serviceChannel' +import LabelConfigDetail from './LabelConfigDetail.vue' const props = defineProps({ visible: { type: Boolean, default: false }, @@ -145,6 +165,14 @@ const addVisible = ref(false) const addLoading = ref(false) const addSaving = ref(false) const addChannelIds = ref([]) +const detailVisible = ref(false) +const detailLoading = ref(false) +const detailProduct = ref(null) + +const detailTitle = computed(() => { + if (!detailProduct.value) return '产品明细' + return detailProduct.value.productName || detailProduct.value.sheetName || '产品明细' +}) const phSearch = '产品名称 / 绑定渠道' const colId = '产品编号' @@ -261,6 +289,26 @@ async function loadBoundChannels() { } } +async function openDetail(row) { + if (!row?.productId) return + detailVisible.value = true + detailLoading.value = true + detailProduct.value = null + try { + const res = await getLabelProduct(row.productId, row.versionId || row.termId) + detailProduct.value = res.data || row + } catch (e) { + detailProduct.value = row + } finally { + detailLoading.value = false + } +} + +function onDetailClosed() { + detailProduct.value = null + detailLoading.value = false +} + async function openBindList(row) { if (!row?.productId) return bindProductId.value = row.productId