@pisell/pisellos 0.10.88 → 0.10.91
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/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +185 -129
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +19 -3
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +51 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +19 -3
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -93,6 +93,19 @@ class PickupTimingController {
|
|
|
93
93
|
if (runtime.scheduleRequest === request) runtime.scheduleRequest = undefined;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
/** Preserve an existing POS choice without adding it to the shared settings cache. */
|
|
98
|
+
getEffectiveConfig(config) {
|
|
99
|
+
if (!this.host.isPos()) return config;
|
|
100
|
+
const serviceType = this.host.getOrder().getTempOrder()?.metadata?.shop_service_data?.service_type;
|
|
101
|
+
if (serviceType !== 'dine_in' && serviceType !== 'takeaway' || config.handoverModes.includes(serviceType)) {
|
|
102
|
+
return config;
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
...config,
|
|
106
|
+
handoverModes: [...config.handoverModes, serviceType]
|
|
107
|
+
};
|
|
108
|
+
}
|
|
96
109
|
async snapshot(includeSchedule, tolerateScheduleError = false) {
|
|
97
110
|
const runtime = this.getRuntime();
|
|
98
111
|
const config = await this.loadConfig(runtime);
|
|
@@ -116,7 +129,11 @@ class PickupTimingController {
|
|
|
116
129
|
error
|
|
117
130
|
};
|
|
118
131
|
this.latest = result;
|
|
119
|
-
|
|
132
|
+
// Read the live order after async loading; cached snapshots retain only configured modes.
|
|
133
|
+
return {
|
|
134
|
+
...result,
|
|
135
|
+
config: this.getEffectiveConfig(config)
|
|
136
|
+
};
|
|
120
137
|
}
|
|
121
138
|
async getAvailability(params = {}) {
|
|
122
139
|
// `force` remains accepted for older callers; refresh recomputes time using the runtime catalog.
|
|
@@ -150,7 +167,7 @@ class PickupTimingController {
|
|
|
150
167
|
const order = this.host.getOrder();
|
|
151
168
|
const tempOrder = order.getTempOrder();
|
|
152
169
|
const booking = order.getPickupTimingBooking();
|
|
153
|
-
const config = this.latest?.scope === this.host.getScope() ? this.latest.config : undefined;
|
|
170
|
+
const config = this.latest?.scope === this.host.getScope() ? this.getEffectiveConfig(this.latest.config) : undefined;
|
|
154
171
|
const storedServiceType = String(tempOrder?.metadata?.shop_service_data?.service_type || '');
|
|
155
172
|
const serviceType = config?.handoverModes.length ? config.handoverModes.includes(storedServiceType) ? storedServiceType : config.handoverModes[0] : storedServiceType;
|
|
156
173
|
const details = serviceType === 'pick_up' ? booking?.metadata.fulfillment_timing : undefined;
|
|
@@ -202,7 +219,11 @@ class PickupTimingController {
|
|
|
202
219
|
return this.getSelection();
|
|
203
220
|
}
|
|
204
221
|
if (selection.serviceType !== 'pick_up') {
|
|
205
|
-
|
|
222
|
+
if (this.host.setServiceType) {
|
|
223
|
+
await this.host.setServiceType(selection.serviceType);
|
|
224
|
+
} else {
|
|
225
|
+
order.updateTempOrderServiceType(selection.serviceType);
|
|
226
|
+
}
|
|
206
227
|
return this.getSelection();
|
|
207
228
|
}
|
|
208
229
|
const slot = selection.mode === 'asap' ? (0, _FulfillmentTiming.getAsapPickupTiming)({
|
|
@@ -13,6 +13,7 @@ import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
|
13
13
|
export declare const BaseSalesHookNames: {
|
|
14
14
|
readonly onInited: "onInited";
|
|
15
15
|
readonly onDestroy: "onDestroy";
|
|
16
|
+
readonly onOrderSessionChanged: "onOrderSessionChanged";
|
|
16
17
|
readonly onRetryInit: "onRetryInit";
|
|
17
18
|
readonly onRefresh: "onRefresh";
|
|
18
19
|
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
@@ -348,6 +349,9 @@ export interface BaseSalesProductBookingPriceResult {
|
|
|
348
349
|
unit_price: string;
|
|
349
350
|
total_price: string;
|
|
350
351
|
quantity: number;
|
|
352
|
+
pricing_method?: {
|
|
353
|
+
type: 'fixed_price' | 'duration_based';
|
|
354
|
+
};
|
|
351
355
|
duration?: BaseSalesQuotationDurationConfig;
|
|
352
356
|
quotation_shelf_id: number;
|
|
353
357
|
segments: BaseSalesProductBookingPriceSegment[];
|
|
@@ -12,6 +12,7 @@ exports.createBaseSalesHook = createBaseSalesHook;
|
|
|
12
12
|
const BaseSalesHookNames = exports.BaseSalesHookNames = {
|
|
13
13
|
onInited: 'onInited',
|
|
14
14
|
onDestroy: 'onDestroy',
|
|
15
|
+
onOrderSessionChanged: 'onOrderSessionChanged',
|
|
15
16
|
onRetryInit: 'onRetryInit',
|
|
16
17
|
onRefresh: 'onRefresh',
|
|
17
18
|
onCartValidationChanged: 'onCartValidationChanged',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesQuotationDurationConfig } from '../types';
|
|
2
|
+
export interface PosDurationPricingPlan {
|
|
3
|
+
duration: BaseSalesQuotationDurationConfig;
|
|
4
|
+
segments: Array<{
|
|
5
|
+
start: string;
|
|
6
|
+
end: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export declare function durationPricingUnavailable(message: string): Error & {
|
|
10
|
+
code: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function hasDurationBasedPricing(product: Record<string, any> | null | undefined): boolean;
|
|
13
|
+
/** Days/Flexible retain their existing quotation behavior. */
|
|
14
|
+
export declare function usesPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
|
|
15
|
+
/** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
|
|
16
|
+
export declare function hasAppliedPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
|
|
17
|
+
export declare function buildPosDurationPricingPlan(params: BaseSalesCalculateProductBookingPriceParams, product: Record<string, any>): PosDurationPricingPlan;
|
|
18
|
+
/** Never use a previously accumulated order price as one unit's fallback. */
|
|
19
|
+
export declare function resolveDurationPricingProduct(product: Record<string, any>, selected: Record<string, any>): Record<string, any>;
|
|
20
|
+
export declare function combinePosDurationPrices(plan: PosDurationPricingPlan, prices: BaseSalesProductBookingPriceResult[]): BaseSalesProductBookingPriceResult;
|
|
21
|
+
export declare function forEachPriceQueryGroup<T>(groups: T[], resolve: (group: T) => Promise<void>, concurrency: number): Promise<void>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildPosDurationPricingPlan = buildPosDurationPricingPlan;
|
|
7
|
+
exports.combinePosDurationPrices = combinePosDurationPrices;
|
|
8
|
+
exports.durationPricingUnavailable = durationPricingUnavailable;
|
|
9
|
+
exports.forEachPriceQueryGroup = forEachPriceQueryGroup;
|
|
10
|
+
exports.hasAppliedPosDurationPricing = hasAppliedPosDurationPricing;
|
|
11
|
+
exports.hasDurationBasedPricing = hasDurationBasedPricing;
|
|
12
|
+
exports.resolveDurationPricingProduct = resolveDurationPricingProduct;
|
|
13
|
+
exports.usesPosDurationPricing = usesPosDurationPricing;
|
|
14
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
15
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
function durationPricingUnavailable(message) {
|
|
18
|
+
return Object.assign(new Error(message), {
|
|
19
|
+
code: 'DURATION_PRICING_UNAVAILABLE'
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function hasDurationBasedPricing(product) {
|
|
23
|
+
return product?.pricing_method?.type === 'duration_based';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Days/Flexible retain their existing quotation behavior. */
|
|
27
|
+
function usesPosDurationPricing(product) {
|
|
28
|
+
const type = String(product?.duration?.type || '').trim().toLowerCase();
|
|
29
|
+
return hasDurationBasedPricing(product) && !['day', 'days', 'flexible'].includes(type);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
|
|
33
|
+
function hasAppliedPosDurationPricing(product) {
|
|
34
|
+
return usesPosDurationPricing(product?._extend?.bookingPriceQuote) || usesPosDurationPricing(product?._extend?.bookingPrice?.quote) || usesPosDurationPricing(product?.metadata);
|
|
35
|
+
}
|
|
36
|
+
function bookingDateTime(date, time) {
|
|
37
|
+
const dateText = typeof date === 'string' ? date.trim() : '';
|
|
38
|
+
const timeText = typeof time === 'string' ? time.trim() : '';
|
|
39
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateText) || !/^\d{2}:\d{2}(?::\d{2})?$/.test(timeText)) {
|
|
40
|
+
throw durationPricingUnavailable('A valid booking start and end are required for duration pricing.');
|
|
41
|
+
}
|
|
42
|
+
const text = `${dateText} ${timeText.length === 5 ? `${timeText}:00` : timeText}`;
|
|
43
|
+
const value = (0, _dayjs.default)(text);
|
|
44
|
+
if (!value.isValid() || value.format('YYYY-MM-DD HH:mm:ss') !== text) {
|
|
45
|
+
throw durationPricingUnavailable('The booking time is invalid for duration pricing.');
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
function buildPosDurationPricingPlan(params, product) {
|
|
50
|
+
const type = String(product.duration?.type || '').trim().toLowerCase();
|
|
51
|
+
const value = Number(product.duration?.value);
|
|
52
|
+
const minutes = ['hour', 'hours'].includes(type) ? value * 60 : value;
|
|
53
|
+
if (!['minute', 'minutes', 'hour', 'hours'].includes(type) || !Number.isFinite(minutes) || minutes <= 0) {
|
|
54
|
+
throw durationPricingUnavailable('A positive fixed billing duration is required.');
|
|
55
|
+
}
|
|
56
|
+
const start = bookingDateTime(params.booking?.start_date, params.booking?.start_time);
|
|
57
|
+
const end = bookingDateTime(params.booking?.end_date, params.booking?.end_time);
|
|
58
|
+
const count = end.diff(start) / (minutes * 60_000);
|
|
59
|
+
if (!Number.isInteger(count) || count < 1 || count > 10_000) {
|
|
60
|
+
throw durationPricingUnavailable('The booking duration must be a whole multiple of its billing duration.');
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
duration: {
|
|
64
|
+
type: 'minutes',
|
|
65
|
+
value: minutes
|
|
66
|
+
},
|
|
67
|
+
segments: Array.from({
|
|
68
|
+
length: count
|
|
69
|
+
}, (_, index) => ({
|
|
70
|
+
start: start.add(index * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss'),
|
|
71
|
+
end: start.add((index + 1) * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss')
|
|
72
|
+
}))
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Never use a previously accumulated order price as one unit's fallback. */
|
|
77
|
+
function resolveDurationPricingProduct(product, selected) {
|
|
78
|
+
const variantId = Number(selected.product_variant_id ?? selected.variant_id ?? 0);
|
|
79
|
+
const authoritativeVariantId = Number(product.product_variant_id ?? product.variant_id ?? 0);
|
|
80
|
+
const variant = variantId > 0 && Array.isArray(product.variant) ? product.variant.find(item => Number(item?.id) === variantId) : undefined;
|
|
81
|
+
if (variantId > 0 && !variant && authoritativeVariantId !== variantId) {
|
|
82
|
+
throw durationPricingUnavailable('The selected SKU is missing from the authoritative price response.');
|
|
83
|
+
}
|
|
84
|
+
const appliedFields = product._dataVariant?.appliedFields;
|
|
85
|
+
const hasAppliedPrice = Array.isArray(appliedFields) && ['price', 'selling_price', 'original_price', 'base_price'].some(field => appliedFields.includes(field));
|
|
86
|
+
const priceSource = variantId > 0 && authoritativeVariantId !== variantId && !hasAppliedPrice ? variant : product;
|
|
87
|
+
const price = priceSource?.price ?? priceSource?.selling_price ?? priceSource?.base_price ?? priceSource?.original_price;
|
|
88
|
+
if (!(typeof price === 'number' || typeof price === 'string' && price.trim() !== '') || !Number.isFinite(Number(price)) || Number(price) < 0) {
|
|
89
|
+
throw durationPricingUnavailable('An authoritative price is required for every billing unit.');
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
...product,
|
|
93
|
+
price
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function combinePosDurationPrices(plan, prices) {
|
|
97
|
+
if (prices.length !== plan.segments.length || prices.length === 0) {
|
|
98
|
+
throw durationPricingUnavailable('The duration price is incomplete.');
|
|
99
|
+
}
|
|
100
|
+
const unitPrice = prices.reduce((sum, price) => sum.plus(price.unit_price), new _decimal.default(0));
|
|
101
|
+
return {
|
|
102
|
+
...prices[0],
|
|
103
|
+
pricing_method: {
|
|
104
|
+
type: 'duration_based'
|
|
105
|
+
},
|
|
106
|
+
duration: plan.duration,
|
|
107
|
+
unit_price: unitPrice.toFixed(2),
|
|
108
|
+
total_price: unitPrice.times(prices[0].quantity).toFixed(2),
|
|
109
|
+
quotation_shelf_id: prices.find(price => price.quotation_shelf_id)?.quotation_shelf_id || 0,
|
|
110
|
+
segments: prices.map((price, index) => ({
|
|
111
|
+
...price.segments[0],
|
|
112
|
+
start_datetime: plan.segments[index].start,
|
|
113
|
+
end_datetime: plan.segments[index].end,
|
|
114
|
+
time_point: plan.segments[index].start,
|
|
115
|
+
unit_price: price.unit_price,
|
|
116
|
+
total_price: price.unit_price,
|
|
117
|
+
quantity: 1
|
|
118
|
+
})),
|
|
119
|
+
// Options are composed by the caller; bundle pricing belongs to the first unit only.
|
|
120
|
+
product_bundle: prices[0].product_bundle
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async function forEachPriceQueryGroup(groups, resolve, concurrency) {
|
|
124
|
+
let next = 0;
|
|
125
|
+
await Promise.all(Array.from({
|
|
126
|
+
length: Math.min(groups.length, concurrency)
|
|
127
|
+
}, async () => {
|
|
128
|
+
while (next < groups.length) {
|
|
129
|
+
const group = groups[next++];
|
|
130
|
+
await resolve(group);
|
|
131
|
+
}
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
@@ -55,6 +55,8 @@ export interface TransformBaseProductToOrderProductParams {
|
|
|
55
55
|
fallbackProductId?: number | string | null;
|
|
56
56
|
sourceProduct?: ProductData | Record<string, any> | null;
|
|
57
57
|
sourceItem?: ProductData | Record<string, any> | null;
|
|
58
|
+
/** Validated booking quote's pre-discount main price, excluding options/bundles. */
|
|
59
|
+
quotedSourceProductPrice?: number | string;
|
|
58
60
|
}
|
|
59
61
|
export type BaseProductOrderProductInput = Partial<OrderProduct> & OrderProductIdentity & {
|
|
60
62
|
_origin?: Record<string, any>;
|
|
@@ -156,7 +156,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
156
156
|
// 售价仍由 line_total - bundle 推导。
|
|
157
157
|
const catalogSourcePrice = matchedVariant?.price ?? matchedVariant?.base_price ?? origin?.price ?? origin?.base_price ?? sourceProduct?.price ?? sourceProduct?.selling_price ?? sourceProduct?.base_price;
|
|
158
158
|
const weighedSourcePrice = (0, _weighedProduct.resolveWeighedSourcePrice)(payload.product_sku ?? origin.product_sku, payload._extend?.weighing ?? origin._extend?.weighing);
|
|
159
|
-
const sourceProductPrice = toPriceString(weighedSourcePrice ?? (hasPriceOverride ? catalogSourcePrice ?? payload.price ?? payload.selling_price : payload.price ?? payload.selling_price ?? catalogSourcePrice), '0.00');
|
|
159
|
+
const sourceProductPrice = toPriceString(params.quotedSourceProductPrice ?? weighedSourcePrice ?? (hasPriceOverride ? catalogSourcePrice ?? payload.price ?? payload.selling_price : payload.price ?? payload.selling_price ?? catalogSourcePrice), '0.00');
|
|
160
160
|
const explicitLineTotal = payload.line_total ?? payload.total ?? payload._extend?.total;
|
|
161
161
|
const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
162
162
|
const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
@@ -20,9 +20,20 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
20
20
|
private shopStore;
|
|
21
21
|
private store;
|
|
22
22
|
private otherParams;
|
|
23
|
+
private scheduleRuntimeParams;
|
|
23
24
|
private cacheId;
|
|
24
25
|
private otherData;
|
|
25
26
|
private platform;
|
|
27
|
+
private productDetailGeneration;
|
|
28
|
+
private sessionAvailabilityRequestVersion;
|
|
29
|
+
private lifecycleGeneration;
|
|
30
|
+
private disposed;
|
|
31
|
+
private resourcePreparation?;
|
|
32
|
+
private staleSelection;
|
|
33
|
+
private resourceSelectionKey;
|
|
34
|
+
/** Semantic selection token for async UI transitions. */
|
|
35
|
+
getBookingSelectionKey(): string;
|
|
36
|
+
private refreshCurrentProductSchedule;
|
|
26
37
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
27
38
|
initStep(stepList: (keyof BookingByStepState)[]): void;
|
|
28
39
|
getCurrentStep(): {
|
|
@@ -108,7 +119,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
108
119
|
* }
|
|
109
120
|
* @memberof BookingByStepImpl
|
|
110
121
|
*/
|
|
111
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: LoadScheduleAvailableDateParams): Promise<ITime[]>;
|
|
122
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, assertCurrent, }: LoadScheduleAvailableDateParams): Promise<ITime[]>;
|
|
112
123
|
addAccount(account: Account | IHolder, extra?: {
|
|
113
124
|
type: 'account' | 'holder';
|
|
114
125
|
customerId: number;
|
|
@@ -152,7 +163,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
152
163
|
startDate?: string;
|
|
153
164
|
endDate?: string;
|
|
154
165
|
type?: 'month' | 'day';
|
|
166
|
+
assertCurrent?: () => void;
|
|
155
167
|
}): Promise<ITime[]>;
|
|
168
|
+
/** Prepare the exact cart/date selection before synchronous resource checks. */
|
|
169
|
+
prepareResourcesForCurrentSelection(): Promise<void>;
|
|
156
170
|
/**
|
|
157
171
|
* 获取购物车汇总信息
|
|
158
172
|
*/
|
|
@@ -210,6 +224,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
210
224
|
* product: ProductData;
|
|
211
225
|
* date?: { startTime: string; endTime: string } | null;
|
|
212
226
|
* account?: Account | null;
|
|
227
|
+
* isLegacyOrder?: boolean;
|
|
213
228
|
* })} {
|
|
214
229
|
* product,
|
|
215
230
|
* date,
|
|
@@ -218,13 +233,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
218
233
|
* @return {*}
|
|
219
234
|
* @memberof BookingByStepImpl
|
|
220
235
|
*/
|
|
221
|
-
addProductToCart({ product, date, account, }: {
|
|
236
|
+
addProductToCart({ product, date, account, isLegacyOrder, }: {
|
|
222
237
|
product: ProductData;
|
|
223
238
|
date?: {
|
|
224
239
|
startTime: string;
|
|
225
240
|
endTime: string;
|
|
226
241
|
} | null;
|
|
227
242
|
account?: Account | null;
|
|
243
|
+
isLegacyOrder?: boolean;
|
|
228
244
|
}): {
|
|
229
245
|
success: boolean;
|
|
230
246
|
errorCode?: string;
|
|
@@ -326,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
342
|
date: string;
|
|
327
343
|
status: string;
|
|
328
344
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
330
346
|
}[]>;
|
|
331
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
348
|
private getScheduleDataByIds;
|