@pisell/pisellos 0.10.56 → 0.10.57
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/modules/OpenData/index.js +2 -1
- package/dist/modules/Order/index.d.ts +2 -1
- 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.d.ts +1 -1
- package/dist/modules/Order/utils.js +9 -6
- package/dist/modules/Payment/index.d.ts +0 -5
- package/dist/modules/Payment/index.js +35 -85
- package/dist/modules/ProductList/index.js +18 -5
- package/dist/modules/ResourcePlanner/planner.js +10 -8
- package/dist/modules/Rules/index.js +16 -14
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/server/index.js +122 -69
- package/dist/server/modules/floor-plan/index.js +34 -3
- package/dist/server/modules/payment/index.d.ts +25 -6
- package/dist/server/modules/payment/index.js +660 -133
- package/dist/server/test.json +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +46 -4
- package/dist/shared/receipt/small-ticket.d.ts +11 -0
- package/dist/shared/receipt/small-ticket.js +430 -255
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/solution/BaseSales/index.d.ts +4 -2
- package/dist/solution/BaseSales/index.js +1328 -1214
- package/dist/solution/BaseSales/types.d.ts +5 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -1
- package/dist/solution/BookingTicket/index.js +120 -80
- package/dist/solution/OrderInvoicePreview/index.d.ts +10 -0
- package/dist/solution/OrderInvoicePreview/index.js +85 -14
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/Sales/index.d.ts +2 -0
- package/dist/solution/Sales/index.js +15 -1
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/UnifiedBookingSales/index.js +12 -13
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- package/lib/modules/OpenData/index.js +2 -1
- package/lib/modules/Order/index.d.ts +2 -1
- 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.d.ts +1 -1
- package/lib/modules/Order/utils.js +5 -3
- package/lib/modules/Payment/index.d.ts +0 -5
- package/lib/modules/Payment/index.js +3 -28
- package/lib/modules/ProductList/index.js +14 -1
- package/lib/modules/ResourcePlanner/planner.js +10 -8
- package/lib/modules/Rules/index.js +16 -14
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/server/index.js +72 -28
- package/lib/server/modules/floor-plan/index.js +29 -1
- package/lib/server/modules/payment/index.d.ts +25 -6
- package/lib/server/modules/payment/index.js +350 -78
- package/lib/server/test.json +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +42 -4
- package/lib/shared/receipt/small-ticket.d.ts +11 -0
- package/lib/shared/receipt/small-ticket.js +234 -30
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/solution/BaseSales/index.d.ts +4 -2
- package/lib/solution/BaseSales/index.js +79 -18
- package/lib/solution/BaseSales/types.d.ts +5 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -1
- package/lib/solution/BookingTicket/index.js +14 -2
- package/lib/solution/OrderInvoicePreview/index.d.ts +10 -0
- package/lib/solution/OrderInvoicePreview/index.js +61 -7
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/Sales/index.d.ts +2 -0
- package/lib/solution/Sales/index.js +10 -1
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/UnifiedBookingSales/index.js +5 -6
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/package.json +1 -1
|
@@ -132,7 +132,8 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
132
132
|
key: "shouldSkipInvoiceTemplateDocument",
|
|
133
133
|
value: function shouldSkipInvoiceTemplateDocument() {
|
|
134
134
|
var _this$otherParams;
|
|
135
|
-
|
|
135
|
+
var platform = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase();
|
|
136
|
+
return platform === 'pc' || platform === 'h5';
|
|
136
137
|
}
|
|
137
138
|
}, {
|
|
138
139
|
key: "fetchOpenData",
|
|
@@ -113,6 +113,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
113
113
|
}>;
|
|
114
114
|
applyDiscount(options?: {
|
|
115
115
|
reapplyBookingDiscountProductUids?: string[];
|
|
116
|
+
reapplyWeighedDiscountProductUids?: string[];
|
|
116
117
|
preferredEntitlementPassIds?: number[];
|
|
117
118
|
}): void;
|
|
118
119
|
/**
|
|
@@ -591,7 +592,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
591
592
|
generateIdempotencyToken(): string;
|
|
592
593
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
593
594
|
createOrder(params: CommitOrderParams['query']): {
|
|
594
|
-
type: "
|
|
595
|
+
type: "virtual" | "appointment_booking";
|
|
595
596
|
platform: string;
|
|
596
597
|
sales_channel: string;
|
|
597
598
|
order_sales_channel: string;
|
|
@@ -35,6 +35,7 @@ import { BaseModule } from "../BaseModule";
|
|
|
35
35
|
import { OrderHooks } from "./types";
|
|
36
36
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
37
37
|
import { isNormalProduct } from "../Product/utils";
|
|
38
|
+
import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "./utils/weighedProduct";
|
|
38
39
|
import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
|
|
39
40
|
import dayjs from 'dayjs';
|
|
40
41
|
import { getDiscountLifecycleReason } from "../Discount/availability";
|
|
@@ -44,7 +45,7 @@ import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentI
|
|
|
44
45
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
45
46
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY } from "../../solution/BaseSales/utils/cartPromotion";
|
|
46
47
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
47
|
-
import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
48
|
+
import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum, buildManualProductDiscountItem, findManualProductDiscountItem, mergeManualProductDiscountIntoList } from "./utils/manualProductDiscount";
|
|
48
49
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
49
50
|
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, repairDuplicateProductLineIdentities as repairDuplicateOrderProductLineIdentities, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
50
51
|
import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
|
|
@@ -686,9 +687,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
686
687
|
with_wallet_pass_holder: 1,
|
|
687
688
|
with_available_wallet_flag: 1,
|
|
688
689
|
with_available_wallet_pass_flag: 1,
|
|
689
|
-
with_virtual_currency: 1,
|
|
690
690
|
with_entitlement_pass: 1,
|
|
691
691
|
filter_order_wallet_pass_usage: 0,
|
|
692
|
+
with_virtual_currency: 1,
|
|
692
693
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
693
694
|
}, orderId ? {
|
|
694
695
|
order_id: orderId
|
|
@@ -1149,6 +1150,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1149
1150
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
1150
1151
|
}, {
|
|
1151
1152
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
1153
|
+
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids,
|
|
1152
1154
|
preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
|
|
1153
1155
|
});
|
|
1154
1156
|
if (result !== null && result !== void 0 && result.productList) {
|
|
@@ -5576,8 +5578,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5576
5578
|
}
|
|
5577
5579
|
}, {
|
|
5578
5580
|
key: "applyOrderProductUpdateToTempOrder",
|
|
5579
|
-
value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
5580
|
-
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$
|
|
5581
|
+
value: function applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
5582
|
+
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata2, _targetProduct$metada20, _tempOrder$products$p, _tempOrder$products$p2;
|
|
5581
5583
|
var product_id = params.product_id,
|
|
5582
5584
|
product_variant_id = params.product_variant_id,
|
|
5583
5585
|
updates = params.updates,
|
|
@@ -5643,7 +5645,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5643
5645
|
var previousLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(targetProduct), targetProduct.product_bundle);
|
|
5644
5646
|
var nextLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(nextProduct), nextProduct.product_bundle);
|
|
5645
5647
|
var callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
|
|
5646
|
-
var
|
|
5648
|
+
var callerChangesWeighing = getWeighedProductPriceFingerprint(targetProduct.product_sku) !== getWeighedProductPriceFingerprint(nextProduct.product_sku);
|
|
5649
|
+
var callerChangesLineConfiguration = callerChangesVariant || callerChangesWeighing || previousLineFingerprint !== nextLineFingerprint;
|
|
5647
5650
|
var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
5648
5651
|
var callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
5649
5652
|
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata8 = updates.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata9 = updates.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata10 = updates.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_discount_reason) !== undefined || callerChangesDiscountList;
|
|
@@ -5659,33 +5662,50 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5659
5662
|
};
|
|
5660
5663
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
5661
5664
|
}();
|
|
5665
|
+
var weighedSourcePrice = callerChangesWeighing ? resolveWeighedSourcePrice(nextProduct.product_sku) : undefined;
|
|
5666
|
+
var hasResolvedWeighedPrice = weighedSourcePrice !== undefined;
|
|
5667
|
+
if (hasResolvedWeighedPrice && !callerUpdatesSourcePrice) {
|
|
5668
|
+
var _ref84, _targetProduct$metada3, _targetProduct$metada4, _ref85, _targetProduct$metada5, _targetProduct$metada6;
|
|
5669
|
+
var nextMainOriginal = new Decimal(weighedSourcePrice).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
|
|
5670
|
+
var previousMainOriginal = new Decimal((_ref84 = (_targetProduct$metada3 = (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_original_price) !== null && _targetProduct$metada3 !== void 0 ? _targetProduct$metada3 : targetProduct.original_price) !== null && _ref84 !== void 0 ? _ref84 : 0);
|
|
5671
|
+
var previousMainSelling = new Decimal((_ref85 = (_targetProduct$metada5 = (_targetProduct$metada6 = targetProduct.metadata) === null || _targetProduct$metada6 === void 0 ? void 0 : _targetProduct$metada6.main_product_selling_price) !== null && _targetProduct$metada5 !== void 0 ? _targetProduct$metada5 : targetProduct.selling_price) !== null && _ref85 !== void 0 ? _ref85 : 0);
|
|
5672
|
+
// A manual final price remains fixed; other legacy discounts keep their amount
|
|
5673
|
+
// until Rules reapplies the currently selected wallet discount below.
|
|
5674
|
+
var nextMainSelling = isManualProductDiscountProduct(nextProduct) ? previousMainSelling : nextMainOriginal.minus(previousMainOriginal.minus(previousMainSelling));
|
|
5675
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata), {}, {
|
|
5676
|
+
source_product_price: weighedSourcePrice,
|
|
5677
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? nextProduct.metadata.main_product_original_price : nextMainOriginal.toFixed(2),
|
|
5678
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? nextProduct.metadata.main_product_selling_price : Decimal.max(0, nextMainSelling).toFixed(2),
|
|
5679
|
+
price_schema_version: 2
|
|
5680
|
+
});
|
|
5681
|
+
}
|
|
5662
5682
|
if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
5663
|
-
var _targetProduct$
|
|
5683
|
+
var _targetProduct$metada7, _targetProduct$metada8, _targetProduct$metada9, _targetProduct$metada10, _targetProduct$metada11;
|
|
5664
5684
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
5665
5685
|
nextProduct.original_price = targetProduct.original_price;
|
|
5666
5686
|
nextProduct.payment_price = targetProduct.payment_price;
|
|
5667
5687
|
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
5668
|
-
source_product_price: (_targetProduct$
|
|
5669
|
-
main_product_selling_price: (_targetProduct$
|
|
5670
|
-
main_product_original_price: (_targetProduct$
|
|
5671
|
-
price_schema_version: (_targetProduct$
|
|
5688
|
+
source_product_price: (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.source_product_price,
|
|
5689
|
+
main_product_selling_price: (_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.main_product_selling_price,
|
|
5690
|
+
main_product_original_price: (_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.main_product_original_price,
|
|
5691
|
+
price_schema_version: (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.price_schema_version) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : 2
|
|
5672
5692
|
});
|
|
5673
5693
|
nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
|
|
5674
5694
|
} else if (callerChangesLineConfiguration && callerUpdatesSourcePrice && (!callerUpdatesMainSellingPrice || !callerUpdatesMainOriginalPrice)) {
|
|
5675
|
-
var _targetProduct$
|
|
5695
|
+
var _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
5676
5696
|
// 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
|
|
5677
5697
|
// 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
|
|
5678
|
-
var
|
|
5679
|
-
var
|
|
5680
|
-
var preservedDiscount =
|
|
5681
|
-
var
|
|
5698
|
+
var _previousMainOriginal = new Decimal(Number((_targetProduct$metada12 = targetProduct.metadata) === null || _targetProduct$metada12 === void 0 ? void 0 : _targetProduct$metada12.main_product_original_price) || 0);
|
|
5699
|
+
var _previousMainSelling = new Decimal(Number((_targetProduct$metada13 = (_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.main_product_selling_price) !== null && _targetProduct$metada13 !== void 0 ? _targetProduct$metada13 : _previousMainOriginal.toNumber()));
|
|
5700
|
+
var preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
5701
|
+
var _nextMainOriginal = new Decimal(Number(updates.metadata.source_product_price) || 0).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
|
|
5682
5702
|
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
5683
5703
|
source_product_price: String(updates.metadata.source_product_price),
|
|
5684
|
-
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) :
|
|
5685
|
-
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) :
|
|
5704
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : _nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
5705
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : hasResolvedWeighedPrice && isManualProductDiscountProduct(nextProduct) ? _previousMainSelling.toFixed(2) : _nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
5686
5706
|
price_schema_version: 2
|
|
5687
5707
|
});
|
|
5688
|
-
} else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5708
|
+
} else if (callerChangesVariant && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5689
5709
|
// variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
|
|
5690
5710
|
// 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
|
|
5691
5711
|
// 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
|
|
@@ -5695,24 +5715,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5695
5715
|
delete nextProduct.metadata.main_product_selling_price;
|
|
5696
5716
|
delete nextProduct.metadata.main_product_original_price;
|
|
5697
5717
|
delete nextProduct.metadata.price_schema_version;
|
|
5698
|
-
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5699
|
-
var
|
|
5718
|
+
} else if (callerChangesLineConfiguration && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5719
|
+
var _ref86, _targetProduct$metada15, _targetProduct$metada16, _ref87, _targetProduct$metada17, _targetProduct$metada18, _targetProduct$metada19;
|
|
5700
5720
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
5701
5721
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
5702
5722
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
5703
5723
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
5704
|
-
var
|
|
5705
|
-
var
|
|
5706
|
-
var _preservedDiscount =
|
|
5707
|
-
var previousSource = ((_targetProduct$
|
|
5708
|
-
var
|
|
5724
|
+
var _previousMainOriginal2 = new Decimal(Number((_ref86 = (_targetProduct$metada15 = (_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.main_product_original_price) !== null && _targetProduct$metada15 !== void 0 ? _targetProduct$metada15 : targetProduct.original_price) !== null && _ref86 !== void 0 ? _ref86 : 0) || 0);
|
|
5725
|
+
var _previousMainSelling2 = new Decimal(Number((_ref87 = (_targetProduct$metada17 = (_targetProduct$metada18 = targetProduct.metadata) === null || _targetProduct$metada18 === void 0 ? void 0 : _targetProduct$metada18.main_product_selling_price) !== null && _targetProduct$metada17 !== void 0 ? _targetProduct$metada17 : targetProduct.selling_price) !== null && _ref87 !== void 0 ? _ref87 : _previousMainOriginal2.toNumber()) || 0);
|
|
5726
|
+
var _preservedDiscount = _previousMainOriginal2.minus(_previousMainSelling2);
|
|
5727
|
+
var previousSource = ((_targetProduct$metada19 = targetProduct.metadata) === null || _targetProduct$metada19 === void 0 ? void 0 : _targetProduct$metada19.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal2.minus(previousOptionSum);
|
|
5728
|
+
var _nextMainOriginal2 = previousSource.plus(nextOptionSum);
|
|
5709
5729
|
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
5710
5730
|
source_product_price: previousSource.toDecimalPlaces(2).toFixed(2),
|
|
5711
|
-
main_product_original_price:
|
|
5712
|
-
main_product_selling_price:
|
|
5731
|
+
main_product_original_price: _nextMainOriginal2.toDecimalPlaces(2).toFixed(2),
|
|
5732
|
+
main_product_selling_price: _nextMainOriginal2.minus(_preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
5713
5733
|
price_schema_version: 2
|
|
5714
5734
|
});
|
|
5715
|
-
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5735
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta && !hasResolvedWeighedPrice) {
|
|
5716
5736
|
var _existedMeta = nextProduct.metadata || {};
|
|
5717
5737
|
nextProduct.metadata = _objectSpread({}, _existedMeta);
|
|
5718
5738
|
delete nextProduct.metadata.source_product_price;
|
|
@@ -5720,11 +5740,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5720
5740
|
delete nextProduct.metadata.main_product_original_price;
|
|
5721
5741
|
delete nextProduct.metadata.price_schema_version;
|
|
5722
5742
|
}
|
|
5743
|
+
if (callerChangesLineConfiguration && resolveWeighedSourcePrice(nextProduct.product_sku) !== undefined && nextProduct.metadata.main_product_original_price != null && nextProduct.metadata.main_product_selling_price != null && isManualProductDiscountProduct(nextProduct)) {
|
|
5744
|
+
var _nextProduct$metadata;
|
|
5745
|
+
var originalPrice = composeLinePrice({
|
|
5746
|
+
mainPrice: nextProduct.metadata.main_product_original_price,
|
|
5747
|
+
bundle: withOriginalBundleOptionPrices(nextProduct.product_bundle),
|
|
5748
|
+
useOriginalBundle: true
|
|
5749
|
+
});
|
|
5750
|
+
var sellingPrice = composeLinePrice({
|
|
5751
|
+
mainPrice: nextProduct.metadata.main_product_selling_price,
|
|
5752
|
+
bundle: nextProduct.product_bundle
|
|
5753
|
+
});
|
|
5754
|
+
var previousManualDiscount = findManualProductDiscountItem(nextProduct.discount_list);
|
|
5755
|
+
nextProduct.original_price = originalPrice;
|
|
5756
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata), {}, {
|
|
5757
|
+
origin: _objectSpread(_objectSpread({}, nextProduct.metadata.origin), {}, {
|
|
5758
|
+
_extend: _objectSpread(_objectSpread({}, (_nextProduct$metadata = nextProduct.metadata.origin) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata._extend), {}, {
|
|
5759
|
+
origin_total: Number(originalPrice)
|
|
5760
|
+
})
|
|
5761
|
+
})
|
|
5762
|
+
});
|
|
5763
|
+
nextProduct.discount_list = mergeManualProductDiscountIntoList(nextProduct.discount_list, buildManualProductDiscountItem({
|
|
5764
|
+
originTotal: Number(originalPrice),
|
|
5765
|
+
sellingTotal: Number(sellingPrice),
|
|
5766
|
+
quantity: nextProduct.num,
|
|
5767
|
+
message: previousManualDiscount === null || previousManualDiscount === void 0 ? void 0 : previousManualDiscount.discount.message,
|
|
5768
|
+
discountway: previousManualDiscount === null || previousManualDiscount === void 0 ? void 0 : previousManualDiscount.discount.discountway,
|
|
5769
|
+
discount_per: previousManualDiscount === null || previousManualDiscount === void 0 ? void 0 : previousManualDiscount.discount.discount_per
|
|
5770
|
+
}));
|
|
5771
|
+
}
|
|
5723
5772
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
5724
5773
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
5725
5774
|
var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
|
|
5726
5775
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
5727
|
-
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$
|
|
5776
|
+
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata2 = nextProduct.metadata) === null || _nextProduct$metadata2 === void 0 ? void 0 : _nextProduct$metadata2.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada20 = targetProduct.metadata) === null || _targetProduct$metada20 === void 0 ? void 0 : _targetProduct$metada20.booking_uid);
|
|
5728
5777
|
if (!booking && preservedBookingUid) {
|
|
5729
5778
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
5730
5779
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
@@ -5732,8 +5781,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5732
5781
|
});
|
|
5733
5782
|
}
|
|
5734
5783
|
if (booking) {
|
|
5735
|
-
var _normalizedProduct$me, _targetProduct$
|
|
5736
|
-
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$
|
|
5784
|
+
var _normalizedProduct$me, _targetProduct$metada21;
|
|
5785
|
+
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada21 = targetProduct.metadata) === null || _targetProduct$metada21 === void 0 ? void 0 : _targetProduct$metada21.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
5737
5786
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
5738
5787
|
unique_identification_number: productUid
|
|
5739
5788
|
});
|
|
@@ -5753,6 +5802,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5753
5802
|
});
|
|
5754
5803
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
5755
5804
|
}
|
|
5805
|
+
if (callerChangesWeighing && !isManualProductDiscountProduct(normalizedProduct)) {
|
|
5806
|
+
var _normalizedProduct$me2;
|
|
5807
|
+
var uid = (_normalizedProduct$me2 = normalizedProduct.metadata) === null || _normalizedProduct$me2 === void 0 ? void 0 : _normalizedProduct$me2.unique_identification_number;
|
|
5808
|
+
if (uid) reapplyWeighedDiscountProductUids === null || reapplyWeighedDiscountProductUids === void 0 || reapplyWeighedDiscountProductUids.push(String(uid));
|
|
5809
|
+
}
|
|
5756
5810
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5757
5811
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5758
5812
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
@@ -5762,7 +5816,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5762
5816
|
key: "updateOrderProduct",
|
|
5763
5817
|
value: function () {
|
|
5764
5818
|
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
5765
|
-
var tempOrder, updatedProductUid, promotionPayload;
|
|
5819
|
+
var tempOrder, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
|
|
5766
5820
|
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
5767
5821
|
while (1) switch (_context27.prev = _context27.next) {
|
|
5768
5822
|
case 0:
|
|
@@ -5770,27 +5824,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5770
5824
|
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
5771
5825
|
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5772
5826
|
}
|
|
5773
|
-
|
|
5774
|
-
|
|
5827
|
+
reapplyWeighedDiscountProductUids = [];
|
|
5828
|
+
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5829
|
+
_context27.next = 6;
|
|
5775
5830
|
return this.evaluatePromotion();
|
|
5776
|
-
case
|
|
5831
|
+
case 6:
|
|
5777
5832
|
promotionPayload = _context27.sent;
|
|
5778
5833
|
this.applyDiscount({
|
|
5834
|
+
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5779
5835
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
5780
5836
|
});
|
|
5781
5837
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5782
|
-
_context27.next =
|
|
5838
|
+
_context27.next = 11;
|
|
5783
5839
|
return this.recalculateSummary({
|
|
5784
5840
|
createIfMissing: true
|
|
5785
5841
|
});
|
|
5786
|
-
case
|
|
5842
|
+
case 11:
|
|
5787
5843
|
this.persistTempOrder();
|
|
5788
5844
|
this.emitPromotionApplied(promotionPayload);
|
|
5789
5845
|
this.logInfo('updateOrderProduct success', {
|
|
5790
5846
|
params: params
|
|
5791
5847
|
});
|
|
5792
5848
|
return _context27.abrupt("return", tempOrder.products);
|
|
5793
|
-
case
|
|
5849
|
+
case 15:
|
|
5794
5850
|
case "end":
|
|
5795
5851
|
return _context27.stop();
|
|
5796
5852
|
}
|
|
@@ -5806,7 +5862,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5806
5862
|
value: function () {
|
|
5807
5863
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5808
5864
|
var _this37 = this;
|
|
5809
|
-
var tempOrder, reapplyBookingDiscountProductUids;
|
|
5865
|
+
var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
5810
5866
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5811
5867
|
while (1) switch (_context28.prev = _context28.next) {
|
|
5812
5868
|
case 0:
|
|
@@ -5822,24 +5878,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5822
5878
|
})) {
|
|
5823
5879
|
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5824
5880
|
}
|
|
5881
|
+
reapplyWeighedDiscountProductUids = [];
|
|
5825
5882
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5826
|
-
var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5883
|
+
var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5827
5884
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5828
5885
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5829
5886
|
acc.push(String(updatedProductUid));
|
|
5830
5887
|
}
|
|
5831
5888
|
return acc;
|
|
5832
5889
|
}, []);
|
|
5833
|
-
_context28.next =
|
|
5890
|
+
_context28.next = 8;
|
|
5834
5891
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
5892
|
+
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5835
5893
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
5836
5894
|
});
|
|
5837
|
-
case
|
|
5895
|
+
case 8:
|
|
5838
5896
|
this.logInfo('updateOrderProduct success', {
|
|
5839
5897
|
paramsList: paramsList
|
|
5840
5898
|
});
|
|
5841
5899
|
return _context28.abrupt("return", tempOrder.products);
|
|
5842
|
-
case
|
|
5900
|
+
case 10:
|
|
5843
5901
|
case "end":
|
|
5844
5902
|
return _context28.stop();
|
|
5845
5903
|
}
|
|
@@ -5854,7 +5912,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5854
5912
|
key: "updateOrderProductQuantity",
|
|
5855
5913
|
value: function () {
|
|
5856
5914
|
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
5857
|
-
var _targetProduct$
|
|
5915
|
+
var _targetProduct$metada22;
|
|
5858
5916
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5859
5917
|
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5860
5918
|
while (1) switch (_context29.prev = _context29.next) {
|
|
@@ -5897,7 +5955,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5897
5955
|
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
5898
5956
|
num: getSafeProductNum(num),
|
|
5899
5957
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
5900
|
-
unique_identification_number: ((_targetProduct$
|
|
5958
|
+
unique_identification_number: ((_targetProduct$metada22 = targetProduct.metadata) === null || _targetProduct$metada22 === void 0 ? void 0 : _targetProduct$metada22.unique_identification_number) || unique_identification_number
|
|
5901
5959
|
})
|
|
5902
5960
|
})));
|
|
5903
5961
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
@@ -6021,7 +6079,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6021
6079
|
case 3:
|
|
6022
6080
|
promotionPayload = _context30.sent;
|
|
6023
6081
|
this.applyDiscount({
|
|
6024
|
-
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
6082
|
+
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
6083
|
+
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
|
|
6025
6084
|
});
|
|
6026
6085
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6027
6086
|
_context30.next = 8;
|
|
@@ -6333,23 +6392,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6333
6392
|
}, {
|
|
6334
6393
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
6335
6394
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
6336
|
-
var _params$cacheId, _this$otherParams5,
|
|
6395
|
+
var _params$cacheId, _this$otherParams5, _ref88, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
6337
6396
|
var tempOrder = this.ensureTempOrder();
|
|
6338
6397
|
this.persistTempOrder();
|
|
6339
6398
|
var payload = buildSubmitPayload({
|
|
6340
6399
|
tempOrder: tempOrder,
|
|
6341
6400
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
6342
6401
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
6343
|
-
businessCode: (
|
|
6402
|
+
businessCode: (_ref88 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref88 !== void 0 ? _ref88 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
6344
6403
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6345
6404
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
6346
6405
|
summary: this.store.summary || createEmptySummary(),
|
|
6347
6406
|
enhance: function enhance(nextPayload) {
|
|
6348
|
-
var
|
|
6407
|
+
var _ref89, _tempOrder$order_numb, _ref90, _tempOrder$shop_order2, _ref91, _tempOrder$shop_full_;
|
|
6349
6408
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
6350
|
-
order_number: (
|
|
6351
|
-
shop_order_number: (
|
|
6352
|
-
shop_full_order_number: (
|
|
6409
|
+
order_number: (_ref89 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref89 !== void 0 ? _ref89 : null,
|
|
6410
|
+
shop_order_number: (_ref90 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref90 !== void 0 ? _ref90 : null,
|
|
6411
|
+
shop_full_order_number: (_ref91 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref91 !== void 0 ? _ref91 : null,
|
|
6353
6412
|
small_ticket_data_flag: 1
|
|
6354
6413
|
});
|
|
6355
6414
|
}
|
|
@@ -6513,7 +6572,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6513
6572
|
key: "runSubmitTempOrder",
|
|
6514
6573
|
value: function () {
|
|
6515
6574
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6516
|
-
var _params$cacheId3, _this$otherParams12,
|
|
6575
|
+
var _params$cacheId3, _this$otherParams12, _ref92, _ref93, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6517
6576
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6518
6577
|
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6519
6578
|
while (1) switch (_context40.prev = _context40.next) {
|
|
@@ -6580,7 +6639,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6580
6639
|
tempOrder: tempOrder,
|
|
6581
6640
|
cacheId: effectiveCacheId,
|
|
6582
6641
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
6583
|
-
businessCode: (
|
|
6642
|
+
businessCode: (_ref92 = (_ref93 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref93 !== void 0 ? _ref93 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref92 !== void 0 ? _ref92 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
6584
6643
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6585
6644
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
6586
6645
|
summary: latestSummary,
|
|
@@ -7698,7 +7757,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7698
7757
|
_step24;
|
|
7699
7758
|
try {
|
|
7700
7759
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
7701
|
-
var _product$metadata14,
|
|
7760
|
+
var _product$metadata14, _ref94, _ref95, _existed$origin, _rawProduct$metadata;
|
|
7702
7761
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
7703
7762
|
index = _step24$value[0],
|
|
7704
7763
|
product = _step24$value[1];
|
|
@@ -7706,7 +7765,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7706
7765
|
if (!uid) continue;
|
|
7707
7766
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
7708
7767
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
7709
|
-
var origin = (
|
|
7768
|
+
var origin = (_ref94 = (_ref95 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref95 !== void 0 ? _ref95 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref94 !== void 0 ? _ref94 : rawProduct;
|
|
7710
7769
|
var originSnapshot = cloneDeep(origin);
|
|
7711
7770
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
7712
7771
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -7835,10 +7894,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7835
7894
|
}, {
|
|
7836
7895
|
key: "normalizeHydratedProductOptionItem",
|
|
7837
7896
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
7838
|
-
var
|
|
7839
|
-
var rawNum = (
|
|
7897
|
+
var _ref96, _optionItem$num, _ref97, _optionItem$add_price;
|
|
7898
|
+
var rawNum = (_ref96 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref96 !== void 0 ? _ref96 : 1;
|
|
7840
7899
|
var parsedNum = Number(rawNum);
|
|
7841
|
-
var rawPrice = (
|
|
7900
|
+
var rawPrice = (_ref97 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref97 !== void 0 ? _ref97 : 0;
|
|
7842
7901
|
var parsedPrice = Number(rawPrice);
|
|
7843
7902
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
7844
7903
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
2
|
+
export declare function getWeighedProductPriceFingerprint(sku?: Record<string, any>): string;
|
|
3
|
+
/**
|
|
4
|
+
* A weighed line's source is the amount for its net weight, never its catalog unit price.
|
|
5
|
+
* Persisted SKU measurements and the full catalog snapshot take priority over runtime
|
|
6
|
+
* _extend.weighing, which can survive repricing with an obsolete total_amount.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveWeighedSourcePrice(sku?: Record<string, any>, weighing?: Record<string, any>): string | undefined;
|
|
9
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
10
|
+
export declare function withOriginalBundleOptionPrices(bundles?: Array<Record<string, any>>): {
|
|
11
|
+
option: any;
|
|
12
|
+
}[] | undefined;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import Decimal from 'decimal.js';
|
|
8
|
+
var UNIT_GRAMS = {
|
|
9
|
+
kg: '1000',
|
|
10
|
+
KILOGRAMS: '1000',
|
|
11
|
+
g: '1',
|
|
12
|
+
GRAMS: '1',
|
|
13
|
+
lb: '453.59237',
|
|
14
|
+
POUNDS: '453.59237',
|
|
15
|
+
oz: '28.349523125',
|
|
16
|
+
OUNCES: '28.349523125'
|
|
17
|
+
};
|
|
18
|
+
function nonNegative(value) {
|
|
19
|
+
if (value === null || value === undefined || value === '') return undefined;
|
|
20
|
+
try {
|
|
21
|
+
var result = new Decimal(value);
|
|
22
|
+
return result.isFinite() && result.gte(0) ? result : undefined;
|
|
23
|
+
} catch (_unused) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function numericKey(value) {
|
|
28
|
+
var _nonNegative;
|
|
29
|
+
return (_nonNegative = nonNegative(value)) === null || _nonNegative === void 0 ? void 0 : _nonNegative.toString();
|
|
30
|
+
}
|
|
31
|
+
function unitKey(value) {
|
|
32
|
+
return UNIT_GRAMS[String(value)] || (value == null ? undefined : String(value));
|
|
33
|
+
}
|
|
34
|
+
function snapshotKey(snapshot) {
|
|
35
|
+
var _snapshot$unit_value;
|
|
36
|
+
return [numericKey(snapshot === null || snapshot === void 0 ? void 0 : snapshot.price), unitKey(snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit), numericKey((_snapshot$unit_value = snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit_value) !== null && _snapshot$unit_value !== void 0 ? _snapshot$unit_value : 1)];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
40
|
+
export function getWeighedProductPriceFingerprint(sku) {
|
|
41
|
+
var _sku$unit_weight;
|
|
42
|
+
if (Number(sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) !== 1) return 'unweighed';
|
|
43
|
+
return JSON.stringify([1, numericKey(sku === null || sku === void 0 ? void 0 : sku.net_weight), unitKey(sku === null || sku === void 0 ? void 0 : sku.unit), numericKey(sku === null || sku === void 0 ? void 0 : sku.unit_price), numericKey((_sku$unit_weight = sku === null || sku === void 0 ? void 0 : sku.unit_weight) !== null && _sku$unit_weight !== void 0 ? _sku$unit_weight : 1), snapshotKey(sku === null || sku === void 0 ? void 0 : 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
|
+
export function resolveWeighedSourcePrice(sku, weighing) {
|
|
52
|
+
var _snapshot$unit_value2, _weighing$unit_weight, _sku$unit_weight2, _measurement$unit_wei;
|
|
53
|
+
if ((sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) != null && Number(sku.open_sold_weight) !== 1) return undefined;
|
|
54
|
+
if (Number(sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) !== 1 && !weighing) return undefined;
|
|
55
|
+
var hasSkuMeasurement = (sku === null || sku === void 0 ? void 0 : sku.net_weight) !== undefined && (sku === null || sku === void 0 ? void 0 : sku.net_weight) !== null;
|
|
56
|
+
var measurement = hasSkuMeasurement ? sku : weighing;
|
|
57
|
+
var netWeight = nonNegative(measurement === null || measurement === void 0 ? void 0 : measurement.net_weight);
|
|
58
|
+
if (netWeight === undefined) return undefined;
|
|
59
|
+
var snapshot = hasSkuMeasurement ? sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot : weighing === null || weighing === void 0 ? void 0 : weighing.scalePriceProduct;
|
|
60
|
+
var snapshotPrice = nonNegative(snapshot === null || snapshot === void 0 ? void 0 : snapshot.price);
|
|
61
|
+
var snapshotUnits = nonNegative((_snapshot$unit_value2 = snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit_value) !== null && _snapshot$unit_value2 !== void 0 ? _snapshot$unit_value2 : 1);
|
|
62
|
+
var sourceGrams = UNIT_GRAMS[String(snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit)];
|
|
63
|
+
var targetGrams = UNIT_GRAMS[String(measurement === null || measurement === void 0 ? void 0 : measurement.unit)];
|
|
64
|
+
if (snapshotPrice && snapshotUnits !== null && snapshotUnits !== void 0 && snapshotUnits.gt(0) && sourceGrams && targetGrams) {
|
|
65
|
+
return snapshotPrice.mul(netWeight).mul(targetGrams).div(sourceGrams).div(snapshotUnits).toFixed(2);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Legacy callers may only retain the native scale's amount. Do not let an old
|
|
69
|
+
// amount overwrite a changed SKU measurement, unit price, or pricing snapshot.
|
|
70
|
+
var runtimeAmount = nonNegative(weighing === null || weighing === void 0 ? void 0 : weighing.total_amount);
|
|
71
|
+
var runtimeMatchesSku = !hasSkuMeasurement || numericKey(weighing === null || weighing === void 0 ? void 0 : weighing.net_weight) === numericKey(sku === null || sku === void 0 ? void 0 : sku.net_weight) && unitKey(weighing === null || weighing === void 0 ? void 0 : weighing.unit) === unitKey(sku === null || sku === void 0 ? void 0 : sku.unit) && numericKey(weighing === null || weighing === void 0 ? void 0 : weighing.unit_price) === numericKey(sku === null || sku === void 0 ? void 0 : sku.unit_price) && numericKey((_weighing$unit_weight = weighing === null || weighing === void 0 ? void 0 : weighing.unit_weight) !== null && _weighing$unit_weight !== void 0 ? _weighing$unit_weight : 1) === numericKey((_sku$unit_weight2 = sku === null || sku === void 0 ? void 0 : sku.unit_weight) !== null && _sku$unit_weight2 !== void 0 ? _sku$unit_weight2 : 1) && JSON.stringify(snapshotKey(weighing === null || weighing === void 0 ? void 0 : weighing.scalePriceProduct)) === JSON.stringify(snapshotKey(sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot));
|
|
72
|
+
if (runtimeAmount && runtimeMatchesSku) return runtimeAmount.toFixed(2);
|
|
73
|
+
|
|
74
|
+
// Older persisted orders have only a rounded per-scale-unit price.
|
|
75
|
+
var unitPrice = nonNegative(measurement === null || measurement === void 0 ? void 0 : measurement.unit_price);
|
|
76
|
+
var unitWeight = nonNegative((_measurement$unit_wei = measurement === null || measurement === void 0 ? void 0 : measurement.unit_weight) !== null && _measurement$unit_wei !== void 0 ? _measurement$unit_wei : 1);
|
|
77
|
+
if (!unitPrice || !(unitWeight !== null && unitWeight !== void 0 && unitWeight.gt(0))) return undefined;
|
|
78
|
+
return netWeight.div(unitWeight).mul(unitPrice).toFixed(2);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
82
|
+
export function withOriginalBundleOptionPrices(bundles) {
|
|
83
|
+
return bundles === null || bundles === void 0 ? void 0 : bundles.map(function (bundle) {
|
|
84
|
+
var _bundle$option;
|
|
85
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
86
|
+
option: (_bundle$option = bundle.option) === null || _bundle$option === void 0 ? void 0 : _bundle$option.map(function (option) {
|
|
87
|
+
var _ref, _option$original_pric;
|
|
88
|
+
return _objectSpread(_objectSpread({}, option), {}, {
|
|
89
|
+
add_price: (_ref = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref !== void 0 ? _ref : option.price
|
|
90
|
+
});
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
|
-
import type { CartItem } from
|
|
2
|
+
import type { CartItem } from "../Cart";
|
|
3
3
|
import type { OrderProductDiscountItem, OrderMetaList, OrderProduct, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder, PointCardSnapshotItem, VirtualCurrencySnapshotItem } from './types';
|
|
4
4
|
import type { RulesParamsHooks } from '../Rules/types';
|
|
5
5
|
import type { MapOrderPaymentsOptions, OrderPaymentData, OrderPaymentSource } from './types';
|