@pisell/pisellos 2.2.307 → 2.2.309
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +118 -59
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.js +6 -4
- package/dist/modules/ResourcePlanner/planner.js +10 -8
- package/dist/modules/Rules/index.js +4 -2
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/UnifiedBookingSales/index.js +3 -4
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +71 -11
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.js +3 -2
- package/lib/modules/ResourcePlanner/planner.js +10 -8
- package/lib/modules/Rules/index.js +4 -2
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/UnifiedBookingSales/index.js +3 -4
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getWeighedProductPriceFingerprint = getWeighedProductPriceFingerprint;
|
|
7
|
+
exports.resolveWeighedSourcePrice = resolveWeighedSourcePrice;
|
|
8
|
+
exports.withOriginalBundleOptionPrices = withOriginalBundleOptionPrices;
|
|
9
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const UNIT_GRAMS = {
|
|
12
|
+
kg: '1000',
|
|
13
|
+
KILOGRAMS: '1000',
|
|
14
|
+
g: '1',
|
|
15
|
+
GRAMS: '1',
|
|
16
|
+
lb: '453.59237',
|
|
17
|
+
POUNDS: '453.59237',
|
|
18
|
+
oz: '28.349523125',
|
|
19
|
+
OUNCES: '28.349523125'
|
|
20
|
+
};
|
|
21
|
+
function nonNegative(value) {
|
|
22
|
+
if (value === null || value === undefined || value === '') return undefined;
|
|
23
|
+
try {
|
|
24
|
+
const result = new _decimal.default(value);
|
|
25
|
+
return result.isFinite() && result.gte(0) ? result : undefined;
|
|
26
|
+
} catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function numericKey(value) {
|
|
31
|
+
return nonNegative(value)?.toString();
|
|
32
|
+
}
|
|
33
|
+
function unitKey(value) {
|
|
34
|
+
return UNIT_GRAMS[String(value)] || (value == null ? undefined : String(value));
|
|
35
|
+
}
|
|
36
|
+
function snapshotKey(snapshot) {
|
|
37
|
+
return [numericKey(snapshot?.price), unitKey(snapshot?.unit), numericKey(snapshot?.unit_value ?? 1)];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
41
|
+
function getWeighedProductPriceFingerprint(sku) {
|
|
42
|
+
if (Number(sku?.open_sold_weight) !== 1) return 'unweighed';
|
|
43
|
+
return JSON.stringify([1, numericKey(sku?.net_weight), unitKey(sku?.unit), numericKey(sku?.unit_price), numericKey(sku?.unit_weight ?? 1), snapshotKey(sku?.unit_data_snapshot)]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A weighed line's source is the amount for its net weight, never its catalog unit price.
|
|
48
|
+
* Persisted SKU measurements and the full catalog snapshot take priority over runtime
|
|
49
|
+
* _extend.weighing, which can survive repricing with an obsolete total_amount.
|
|
50
|
+
*/
|
|
51
|
+
function resolveWeighedSourcePrice(sku, weighing) {
|
|
52
|
+
if (sku?.open_sold_weight != null && Number(sku.open_sold_weight) !== 1) return undefined;
|
|
53
|
+
if (Number(sku?.open_sold_weight) !== 1 && !weighing) return undefined;
|
|
54
|
+
const hasSkuMeasurement = sku?.net_weight !== undefined && sku?.net_weight !== null;
|
|
55
|
+
const measurement = hasSkuMeasurement ? sku : weighing;
|
|
56
|
+
const netWeight = nonNegative(measurement?.net_weight);
|
|
57
|
+
if (netWeight === undefined) return undefined;
|
|
58
|
+
const snapshot = hasSkuMeasurement ? sku?.unit_data_snapshot : weighing?.scalePriceProduct;
|
|
59
|
+
const snapshotPrice = nonNegative(snapshot?.price);
|
|
60
|
+
const snapshotUnits = nonNegative(snapshot?.unit_value ?? 1);
|
|
61
|
+
const sourceGrams = UNIT_GRAMS[String(snapshot?.unit)];
|
|
62
|
+
const targetGrams = UNIT_GRAMS[String(measurement?.unit)];
|
|
63
|
+
if (snapshotPrice && snapshotUnits?.gt(0) && sourceGrams && targetGrams) {
|
|
64
|
+
return snapshotPrice.mul(netWeight).mul(targetGrams).div(sourceGrams).div(snapshotUnits).toFixed(2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Legacy callers may only retain the native scale's amount. Do not let an old
|
|
68
|
+
// amount overwrite a changed SKU measurement, unit price, or pricing snapshot.
|
|
69
|
+
const runtimeAmount = nonNegative(weighing?.total_amount);
|
|
70
|
+
const runtimeMatchesSku = !hasSkuMeasurement || numericKey(weighing?.net_weight) === numericKey(sku?.net_weight) && unitKey(weighing?.unit) === unitKey(sku?.unit) && numericKey(weighing?.unit_price) === numericKey(sku?.unit_price) && numericKey(weighing?.unit_weight ?? 1) === numericKey(sku?.unit_weight ?? 1) && JSON.stringify(snapshotKey(weighing?.scalePriceProduct)) === JSON.stringify(snapshotKey(sku?.unit_data_snapshot));
|
|
71
|
+
if (runtimeAmount && runtimeMatchesSku) return runtimeAmount.toFixed(2);
|
|
72
|
+
|
|
73
|
+
// Older persisted orders have only a rounded per-scale-unit price.
|
|
74
|
+
const unitPrice = nonNegative(measurement?.unit_price);
|
|
75
|
+
const unitWeight = nonNegative(measurement?.unit_weight ?? 1);
|
|
76
|
+
if (!unitPrice || !unitWeight?.gt(0)) return undefined;
|
|
77
|
+
return netWeight.div(unitWeight).mul(unitPrice).toFixed(2);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
81
|
+
function withOriginalBundleOptionPrices(bundles) {
|
|
82
|
+
return bundles?.map(bundle => ({
|
|
83
|
+
...bundle,
|
|
84
|
+
option: bundle.option?.map(option => ({
|
|
85
|
+
...option,
|
|
86
|
+
add_price: option.original_price ?? option.add_price ?? option.price
|
|
87
|
+
}))
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
@@ -126,11 +126,12 @@ Object.defineProperty(exports, "syncManualProductDiscountProductNum", {
|
|
|
126
126
|
});
|
|
127
127
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
128
128
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
129
|
+
var _weighedProduct = require("./utils/weighedProduct");
|
|
130
|
+
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
129
131
|
var _utils = require("../Holder/utils");
|
|
130
132
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
131
133
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
132
134
|
var _salesNotes = require("./salesNotes");
|
|
133
|
-
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
134
135
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
135
136
|
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
136
137
|
function isPlainObject(value) {
|
|
@@ -773,7 +774,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
773
774
|
});
|
|
774
775
|
const composedOriginalPrice = composeLinePrice({
|
|
775
776
|
mainPrice: nextMainOriginalPrice,
|
|
776
|
-
bundle: nextBundle,
|
|
777
|
+
bundle: Number(product.product_sku?.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadataAny) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(nextBundle) : nextBundle,
|
|
777
778
|
useOriginalBundle: true
|
|
778
779
|
});
|
|
779
780
|
const finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
@@ -412,7 +412,7 @@ function normalizeOccupancy(occupancy, coverage, timezoneName, fixedOffsetMinute
|
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
414
|
function normalizeRequirementGroup(product, requirementGroup) {
|
|
415
|
-
const resourceType = 'single';
|
|
415
|
+
const resourceType = requirementGroup.resourceType === 'multiple' || requirementGroup.resourceType === 'capacity' ? requirementGroup.resourceType : 'single';
|
|
416
416
|
const required = requirementGroup.required !== false;
|
|
417
417
|
const min = required ? 1 : 0;
|
|
418
418
|
return {
|
|
@@ -457,7 +457,7 @@ function normalizeProducts(products) {
|
|
|
457
457
|
function normalizeResources(resources) {
|
|
458
458
|
return resources.map(resource => ({
|
|
459
459
|
...resource,
|
|
460
|
-
resourceType: 'single',
|
|
460
|
+
resourceType: resource.resourceType === 'multiple' || resource.resourceType === 'capacity' ? resource.resourceType : 'single',
|
|
461
461
|
capacity: Math.max(1, Number(resource.capacity || 1) || 1),
|
|
462
462
|
windows: (resource.windows || []).map(window => ({
|
|
463
463
|
...window
|
|
@@ -573,7 +573,8 @@ function buildCells(projection) {
|
|
|
573
573
|
occupancy
|
|
574
574
|
}) => occupancy) : [];
|
|
575
575
|
const usedCapacity = segmentOccupancies.reduce((sum, occupancy) => sum + Math.max(1, Number(occupancy.pax || 1) || 1), 0);
|
|
576
|
-
|
|
576
|
+
// 预约模式来自商品资源组;v2 资源记录可能不包含 type。
|
|
577
|
+
const remainingCapacity = requirementGroup.resourceType === 'single' && segmentOccupancies.length > 0 ? 0 : Math.max(0, resource.capacity - usedCapacity);
|
|
577
578
|
const requiredCapacity = resolveRequiredCapacity(requirementGroup, product);
|
|
578
579
|
const reasonCodes = Array.from(new Set(segmentOccupancies.flatMap(occupancy => {
|
|
579
580
|
const source = occupancy.source || 'remote';
|
|
@@ -607,7 +608,7 @@ function buildCells(projection) {
|
|
|
607
608
|
requirementFormId: requirementGroup.formId,
|
|
608
609
|
resourceId: resource.id,
|
|
609
610
|
resourceName: resource.name,
|
|
610
|
-
resourceType:
|
|
611
|
+
resourceType: requirementGroup.resourceType,
|
|
611
612
|
startAt: formatDateTime(start, timezoneName, fixedOffsetMinutes),
|
|
612
613
|
endAt: formatDateTime(end, timezoneName, fixedOffsetMinutes),
|
|
613
614
|
date: formatDate(start, timezoneName),
|
|
@@ -615,7 +616,7 @@ function buildCells(projection) {
|
|
|
615
616
|
endTime: formatTime(end, timezoneName),
|
|
616
617
|
timezone: projection.meta.timezone,
|
|
617
618
|
status,
|
|
618
|
-
//
|
|
619
|
+
// capacity 表示人数;single 被占用时不再贡献可用容量。
|
|
619
620
|
remainingCapacity,
|
|
620
621
|
maxCapacity: resource.capacity,
|
|
621
622
|
reasonCodes: Array.from(new Set(reasonCodes)),
|
|
@@ -1500,7 +1501,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1500
1501
|
resourceName: resource.name,
|
|
1501
1502
|
resourceFormId: resource.formId,
|
|
1502
1503
|
policyId: resource.raw?.policy_id,
|
|
1503
|
-
resourceType:
|
|
1504
|
+
resourceType: requirementGroup.resourceType,
|
|
1504
1505
|
status: isPast ? 'past' : 'unavailable',
|
|
1505
1506
|
maxPartySize: 0,
|
|
1506
1507
|
reasonCodes: isPast ? ['past'] : [...(isExcludedScheduleDate ? ['schedule_excluded_date'] : []), 'outside_resource_window']
|
|
@@ -1524,7 +1525,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1524
1525
|
resourceName: resource.name,
|
|
1525
1526
|
resourceFormId: resource.formId,
|
|
1526
1527
|
policyId: resource.raw?.policy_id,
|
|
1527
|
-
resourceType:
|
|
1528
|
+
resourceType: requirementGroup.resourceType,
|
|
1528
1529
|
status,
|
|
1529
1530
|
remainingCapacity,
|
|
1530
1531
|
maxCapacity,
|
|
@@ -2008,7 +2009,8 @@ function validateAvailabilitySelection(projection, params, runtimeOptions = {})
|
|
|
2008
2009
|
const remainingCapacity = matchedCell?.remainingCapacity;
|
|
2009
2010
|
if (option && (option.status === 'available' || option.status === 'limited') && remainingCapacity !== undefined) {
|
|
2010
2011
|
const capacityPerBooking = normalizedPartySize ?? 1;
|
|
2011
|
-
const
|
|
2012
|
+
const capacityQuantity = Math.max(0, Math.floor(remainingCapacity / capacityPerBooking));
|
|
2013
|
+
const availableQuantity = matchedGroup.resourceType === 'single' ? Math.min(1, capacityQuantity) : capacityQuantity;
|
|
2012
2014
|
if (normalizedBookingCount > availableQuantity) {
|
|
2013
2015
|
conflicts.push({
|
|
2014
2016
|
code: 'resource_capacity_exceeded',
|
|
@@ -211,7 +211,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
211
211
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
212
212
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
213
213
|
const isEditModeAddNewProduct = productList.find(n => n.booking_id) && productList.find(n => !n.booking_id);
|
|
214
|
-
const
|
|
214
|
+
const reapplyWeighedDiscountProductUids = new Set((options?.reapplyWeighedDiscountProductUids || []).map(String));
|
|
215
|
+
const reapplyBookingDiscountProductUids = new Set([...(options?.reapplyBookingDiscountProductUids || []), ...reapplyWeighedDiscountProductUids].filter(uid => uid !== undefined && uid !== null && uid !== '').map(String));
|
|
215
216
|
const getOriginProductUid = originProduct => {
|
|
216
217
|
const uid = originProduct?.metadata?.unique_identification_number ?? originProduct?.unique_identification_number;
|
|
217
218
|
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
@@ -915,7 +916,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
915
916
|
});
|
|
916
917
|
|
|
917
918
|
// 已持久化且已有钱包券/折扣卡的商品行跳过,保留后端历史折扣结果。
|
|
918
|
-
|
|
919
|
+
const isReweighedProduct = reapplyWeighedDiscountProductUids.has(getOriginProductUid(originProduct) || '');
|
|
920
|
+
if (isPersistedProduct && hasExistingWalletDiscount && !isReweighedProduct) {
|
|
919
921
|
if (flatItem.type === 'main') {
|
|
920
922
|
processedProductsMap.set(product._id, [originProduct]);
|
|
921
923
|
}
|
|
@@ -31,6 +31,8 @@ export interface RulesCalcDiscountOptions {
|
|
|
31
31
|
scan?: boolean;
|
|
32
32
|
/** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
|
|
33
33
|
reapplyBookingDiscountProductUids?: string[];
|
|
34
|
+
/** Reweighed order lines only: reapply selected wallet discounts against their new amount. */
|
|
35
|
+
reapplyWeighedDiscountProductUids?: string[];
|
|
34
36
|
}
|
|
35
37
|
export interface RulesModuleAPI {
|
|
36
38
|
setRulesList: (rulesList: Rules[]) => Promise<void>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformBaseProductToOrderProduct = transformBaseProductToOrderProduct;
|
|
7
|
+
var _weighedProduct = require("../../../modules/Order/utils/weighedProduct");
|
|
7
8
|
var _utils = require("../../../modules/Order/utils");
|
|
8
9
|
var _manualProductDiscount = require("../../../modules/Order/utils/manualProductDiscount");
|
|
9
10
|
function toNumber(value, fallback = 0) {
|
|
@@ -65,11 +66,11 @@ function appendDataVariantIds(base, ...values) {
|
|
|
65
66
|
}
|
|
66
67
|
return Array.isArray(base) || result.length ? result : undefined;
|
|
67
68
|
}
|
|
68
|
-
function normalizeOptionItems(optionItems) {
|
|
69
|
+
function normalizeOptionItems(optionItems, useOriginalPrice = false) {
|
|
69
70
|
if (!Array.isArray(optionItems)) return [];
|
|
70
71
|
return optionItems.map(optionItem => {
|
|
71
72
|
const optionGroupItemId = toNumber(optionItem?.option_group_item_id ?? optionItem?.id);
|
|
72
|
-
const price = optionItem?.price ?? optionItem?.add_price ?? 0;
|
|
73
|
+
const price = (useOriginalPrice ? optionItem?.original_price : undefined) ?? optionItem?.price ?? optionItem?.add_price ?? 0;
|
|
73
74
|
return {
|
|
74
75
|
...optionItem,
|
|
75
76
|
option_group_item_id: optionGroupItemId,
|
|
@@ -80,10 +81,12 @@ function normalizeOptionItems(optionItems) {
|
|
|
80
81
|
};
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
84
|
+
function normalizeBundleItems(bundleItems, preferPriceField = false, preferBundleSellingPrice = false) {
|
|
84
85
|
if (!Array.isArray(bundleItems)) return [];
|
|
85
86
|
return bundleItems.map(bundleItem => {
|
|
86
|
-
|
|
87
|
+
// Weighed manual prices distribute the bundle base and nested options separately.
|
|
88
|
+
// Its explicit selling amount already includes those options.
|
|
89
|
+
const unitSelling = preferPriceField && !preferBundleSellingPrice ? bundleItem.price ?? bundleItem.bundle_selling_price ?? bundleItem.custom_price ?? bundleItem.product_price ?? '0' : bundleItem.bundle_selling_price ?? bundleItem.price ?? bundleItem.custom_price ?? bundleItem.product_price ?? '0';
|
|
87
90
|
const unitStr = toPriceString(unitSelling, '0.00');
|
|
88
91
|
const num = toSafePositiveInt(bundleItem?.num ?? bundleItem?.quantity, 1);
|
|
89
92
|
const magnitudeSource = {
|
|
@@ -147,19 +150,25 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
147
150
|
const productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant?.production_code : origin?.production_code ?? sourceProduct?.production_code);
|
|
148
151
|
const hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
149
152
|
// 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
|
|
150
|
-
//
|
|
153
|
+
// 称重商品使用改价前净重金额;其它商品从商品/variant 快照读取目录价。
|
|
154
|
+
// 售价仍由 line_total - bundle 推导。
|
|
151
155
|
const catalogSourcePrice = matchedVariant?.price ?? matchedVariant?.base_price ?? origin?.price ?? origin?.base_price ?? sourceProduct?.price ?? sourceProduct?.selling_price ?? sourceProduct?.base_price;
|
|
152
|
-
const
|
|
156
|
+
const weighedSourcePrice = (0, _weighedProduct.resolveWeighedSourcePrice)(payload.product_sku ?? origin.product_sku, payload._extend?.weighing ?? origin._extend?.weighing);
|
|
157
|
+
const sourceProductPrice = toPriceString(weighedSourcePrice ?? (hasPriceOverride ? catalogSourcePrice ?? payload.price ?? payload.selling_price : payload.price ?? payload.selling_price ?? catalogSourcePrice), '0.00');
|
|
153
158
|
const explicitLineTotal = payload.line_total ?? payload.total ?? payload._extend?.total;
|
|
154
159
|
const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
155
160
|
const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
156
|
-
const productOptionItem = (0, _utils.normalizeProductSkuOptions)(normalizeOptionItems(payload.product_sku?.option ?? payload.option ?? payload.options ?? payload.product_option_item));
|
|
157
|
-
const productBundle = normalizeBundleItems(payload.bundle ?? payload.product_bundle, hasPriceOverride);
|
|
161
|
+
const productOptionItem = (0, _utils.normalizeProductSkuOptions)(normalizeOptionItems(payload.product_sku?.option ?? payload.option ?? payload.options ?? payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
|
|
162
|
+
const productBundle = normalizeBundleItems(payload.bundle ?? payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
|
|
158
163
|
// `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
|
|
159
164
|
// 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
|
|
160
165
|
const uniqueIdentificationNumber = payload.unique_identification_number;
|
|
161
166
|
const resolvedQuantity = toSafePositiveInt(payload.quantity ?? payload.num, 1);
|
|
162
|
-
const originTotal = (0,
|
|
167
|
+
const originTotal = weighedSourcePrice !== undefined ? Number((0, _utils.composeLinePrice)({
|
|
168
|
+
mainPrice: Number(weighedSourcePrice) + (0, _utils.sumOptionUnitPrice)(productOptionItem).toNumber(),
|
|
169
|
+
bundle: hasPriceOverride ? (0, _weighedProduct.withOriginalBundleOptionPrices)(productBundle) : productBundle,
|
|
170
|
+
useOriginalBundle: true
|
|
171
|
+
})) : (0, _manualProductDiscount.resolveManualDiscountOriginTotal)({
|
|
163
172
|
originTotal: payload.origin_total,
|
|
164
173
|
extendOriginTotal: payload._extend?.origin_total,
|
|
165
174
|
originExtendOriginTotal: origin?._extend?.origin_total,
|
|
@@ -260,6 +269,12 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
260
269
|
product_cover: firstNonBlank(matchedVariant?.cover, sourceProduct?.cover),
|
|
261
270
|
_origin: {
|
|
262
271
|
...(sourceProduct || {}),
|
|
272
|
+
...(weighedSourcePrice !== undefined && hasPriceOverride ? {
|
|
273
|
+
_extend: {
|
|
274
|
+
...sourceProduct?._extend,
|
|
275
|
+
origin_total: originTotal
|
|
276
|
+
}
|
|
277
|
+
} : {}),
|
|
263
278
|
callbackData: payload
|
|
264
279
|
}
|
|
265
280
|
};
|
|
@@ -8,6 +8,7 @@ exports.createEmptySummary = createEmptySummary;
|
|
|
8
8
|
exports.getSafeProductNum = getSafeProductNum;
|
|
9
9
|
exports.isSkuOnlyDeleteIdentity = isSkuOnlyDeleteIdentity;
|
|
10
10
|
exports.normalizeOrderProduct = normalizeOrderProduct;
|
|
11
|
+
var _weighedProduct = require("../../modules/Order/utils/weighedProduct");
|
|
11
12
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
12
13
|
var _utils = require("../../modules/Order/utils");
|
|
13
14
|
var _manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
|
|
@@ -237,7 +238,7 @@ function normalizeOrderProduct(product) {
|
|
|
237
238
|
});
|
|
238
239
|
const composedOriginalPrice = (0, _utils.composeLinePrice)({
|
|
239
240
|
mainPrice: mainOriginalStr,
|
|
240
|
-
bundle: normalizedBundle,
|
|
241
|
+
bundle: Number(productSku.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadata) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(normalizedBundle) : normalizedBundle,
|
|
241
242
|
useOriginalBundle: true
|
|
242
243
|
});
|
|
243
244
|
const finalOriginalPrice = (0, _utils.resolveManualOverrideLineOriginalPrice)({
|
|
@@ -34,6 +34,7 @@ exports.toNonNegativeInt = toNonNegativeInt;
|
|
|
34
34
|
exports.toNonNegativeNumber = toNonNegativeNumber;
|
|
35
35
|
exports.toPositiveString = toPositiveString;
|
|
36
36
|
exports.toPriceString = toPriceString;
|
|
37
|
+
var _weighedProduct = require("../../modules/Order/utils/weighedProduct");
|
|
37
38
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
38
39
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
39
40
|
var _utils = require("../../modules/Order/utils");
|
|
@@ -612,7 +613,7 @@ function normalizeOrderProduct(product) {
|
|
|
612
613
|
});
|
|
613
614
|
const composedOriginalPrice = (0, _utils.composeLinePrice)({
|
|
614
615
|
mainPrice: mainOriginalStr,
|
|
615
|
-
bundle: normalizedBundle,
|
|
616
|
+
bundle: Number(productSku.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadata) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(normalizedBundle) : normalizedBundle,
|
|
616
617
|
useOriginalBundle: true
|
|
617
618
|
});
|
|
618
619
|
const finalOriginalPrice = (0, _utils.resolveManualOverrideLineOriginalPrice)({
|
|
@@ -283,10 +283,9 @@ function assertAvailabilityCatalogProductIds(productIds, context) {
|
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function normalizeResourceType(
|
|
287
|
-
//
|
|
288
|
-
|
|
289
|
-
return 'single';
|
|
286
|
+
function normalizeResourceType(value) {
|
|
287
|
+
// 预约是否独占与每组选择几个资源是两个独立配置。
|
|
288
|
+
return value === 'multiple' || value === 'capacity' ? value : 'single';
|
|
290
289
|
}
|
|
291
290
|
function resolveProductKind(product) {
|
|
292
291
|
if (product.duration || product.service_duration) return 'duration';
|