@pisell/pisellos 2.3.129 → 2.3.131
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/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/OpenData/types.d.ts +8 -0
- package/dist/modules/Order/index.d.ts +11 -2
- package/dist/modules/Order/index.js +370 -253
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +13 -1
- package/dist/modules/Order/utils.js +16 -6
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/request.d.ts +7 -0
- package/dist/server/utils/small-ticket.d.ts +1 -85
- package/dist/server/utils/small-ticket.js +2 -2542
- package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/dist/shared/payment/loadPaymentMethods.js +66 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +142 -0
- package/dist/shared/receipt/small-ticket.d.ts +85 -0
- package/dist/shared/receipt/small-ticket.js +2576 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/index.d.ts +28 -15
- package/dist/solution/BaseSales/index.js +1346 -1101
- package/dist/solution/BaseSales/pickupTiming.d.ts +43 -0
- package/dist/solution/BaseSales/pickupTiming.js +589 -0
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.js +41 -13
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts +56 -0
- package/dist/solution/OrderInvoicePreview/index.js +269 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +24 -4
- package/dist/solution/UnifiedBookingSales/index.js +953 -709
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +21 -1
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/OpenData/types.d.ts +8 -0
- package/lib/modules/Order/index.d.ts +11 -2
- package/lib/modules/Order/index.js +101 -14
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +13 -1
- package/lib/modules/Order/utils.js +12 -4
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/plugins/request.d.ts +7 -0
- package/lib/server/utils/small-ticket.d.ts +1 -85
- package/lib/server/utils/small-ticket.js +9 -2305
- package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/lib/shared/payment/loadPaymentMethods.js +40 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +86 -0
- package/lib/shared/receipt/small-ticket.d.ts +85 -0
- package/lib/shared/receipt/small-ticket.js +2342 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/index.d.ts +28 -15
- package/lib/solution/BaseSales/index.js +161 -25
- package/lib/solution/BaseSales/pickupTiming.d.ts +43 -0
- package/lib/solution/BaseSales/pickupTiming.js +269 -0
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.js +37 -4
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/OrderInvoicePreview/index.d.ts +56 -0
- package/lib/solution/OrderInvoicePreview/index.js +192 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +24 -4
- package/lib/solution/UnifiedBookingSales/index.js +184 -46
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ScheduleItem } from '../Schedule/types';
|
|
2
|
+
export type PickupTimingMode = 'asap_only' | 'scheduled_only' | 'asap_and_scheduled';
|
|
3
|
+
export interface PickupTimingConfig {
|
|
4
|
+
handoverModes: string[];
|
|
5
|
+
timingMode: PickupTimingMode;
|
|
6
|
+
scheduleIds: number[];
|
|
7
|
+
/** Empty or absent means no additional store-hours restriction. */
|
|
8
|
+
operatingHoursScheduleIds?: number[];
|
|
9
|
+
slotIntervalMinutes: number;
|
|
10
|
+
preparationTimeMinutes: number;
|
|
11
|
+
advanceDays: number;
|
|
12
|
+
fulfillmentRefMode?: string;
|
|
13
|
+
manualInputType?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PickupTimingSelection {
|
|
16
|
+
serviceType: string;
|
|
17
|
+
mode: 'asap' | 'scheduled';
|
|
18
|
+
date?: string;
|
|
19
|
+
time?: string;
|
|
20
|
+
/** The absolute instant disambiguates a repeated local minute during DST. */
|
|
21
|
+
instant?: string;
|
|
22
|
+
source?: 'schedule' | 'pos_manual' | 'asap';
|
|
23
|
+
}
|
|
24
|
+
export interface PickupTimingSlot {
|
|
25
|
+
id: string;
|
|
26
|
+
date: string;
|
|
27
|
+
time: string;
|
|
28
|
+
instant: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PickupTimingAvailability {
|
|
31
|
+
/** Config remains available when Schedule or store timezone cannot be loaded. */
|
|
32
|
+
error?: string;
|
|
33
|
+
config: PickupTimingConfig;
|
|
34
|
+
timezone: string;
|
|
35
|
+
now: string;
|
|
36
|
+
today: string;
|
|
37
|
+
maxDate: string;
|
|
38
|
+
date: string;
|
|
39
|
+
dates: Array<{
|
|
40
|
+
date: string;
|
|
41
|
+
status: 'available' | 'unavailable';
|
|
42
|
+
}>;
|
|
43
|
+
slots: PickupTimingSlot[];
|
|
44
|
+
/** Earliest legal candidate across all permitted dates, for POS prefill. */
|
|
45
|
+
firstSlot?: PickupTimingSlot;
|
|
46
|
+
}
|
|
47
|
+
export interface PickupTimingClockInput {
|
|
48
|
+
config: PickupTimingConfig;
|
|
49
|
+
timezone: string;
|
|
50
|
+
now: Date | string | number;
|
|
51
|
+
}
|
|
52
|
+
export interface PickupTimingComputeInput extends PickupTimingClockInput {
|
|
53
|
+
schedules: ScheduleItem[];
|
|
54
|
+
date?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface PickupTimingValidationResult {
|
|
57
|
+
valid: boolean;
|
|
58
|
+
code?: string;
|
|
59
|
+
message?: string;
|
|
60
|
+
slot?: PickupTimingSlot;
|
|
61
|
+
}
|
|
62
|
+
export interface PickupTimingBookingTimes {
|
|
63
|
+
start_date: string;
|
|
64
|
+
start_time: string;
|
|
65
|
+
end_date: string;
|
|
66
|
+
end_time: string;
|
|
67
|
+
}
|
|
@@ -69,6 +69,8 @@ export interface OpenDataConfig {
|
|
|
69
69
|
'reservation.time_slice'?: number | string;
|
|
70
70
|
'sale.allow_item_notes'?: boolean;
|
|
71
71
|
'sale.allow_order_notes'?: boolean;
|
|
72
|
+
/** False submits an order without starting or confirming payment. */
|
|
73
|
+
'sale.require_payment_on_submit'?: boolean | null;
|
|
72
74
|
'sale.enable_item_rules'?: boolean;
|
|
73
75
|
'sale.enable_short_number'?: boolean;
|
|
74
76
|
'sale.short_number_daily_reset'?: boolean;
|
|
@@ -77,6 +79,12 @@ export interface OpenDataConfig {
|
|
|
77
79
|
'sale.sale_number_prefix'?: string | null;
|
|
78
80
|
'sale.enabled_item_rules'?: number[];
|
|
79
81
|
'fulfillment.enable_pickup'?: boolean;
|
|
82
|
+
'fulfillment.handover_mode'?: string[];
|
|
83
|
+
'fulfillment.pickup.timing_mode'?: 'asap_only' | 'scheduled_only' | 'asap_and_scheduled';
|
|
84
|
+
'fulfillment.pickup.schedule'?: number[];
|
|
85
|
+
'fulfillment.pickup.advance_days'?: number;
|
|
86
|
+
'fulfillment.pickup.slot_interval_minutes'?: number;
|
|
87
|
+
'fulfillment.pickup.preparation_time_minutes'?: number;
|
|
80
88
|
'fulfillment.overdue_reminder'?: boolean;
|
|
81
89
|
'fulfillment.manual_input_type'?: string;
|
|
82
90
|
'fulfillment.enable_auto_complete'?: boolean;
|
|
@@ -3,7 +3,8 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
|
-
import
|
|
6
|
+
import { type PickupTimingBooking, type PickupTimingBookingInput } from './pickupTiming';
|
|
7
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
7
8
|
import type { ICustomer } from '../AccountList/types';
|
|
8
9
|
import type { Discount } from '../Discount/types';
|
|
9
10
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -66,6 +67,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
66
67
|
* orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
|
|
67
68
|
*/
|
|
68
69
|
updateOtherParams(params: Record<string, any>): void;
|
|
70
|
+
/** Internal intent boundary shared with asynchronous scanner/detail flows. */
|
|
71
|
+
createCartIntentCommitGuard(action: OrderCartIntentCommitContext['action'], tempOrder?: OrderTempOrder | null): () => void;
|
|
69
72
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
70
73
|
isOnlineStorePlatform(): boolean;
|
|
71
74
|
/**
|
|
@@ -354,6 +357,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
354
357
|
private updateTempOrderShopServiceData;
|
|
355
358
|
updateTempOrderPickupReferenceMode(mode: PickupReferenceMode): ShopServiceData;
|
|
356
359
|
updateTempOrderServiceType(serviceType: ShopServiceType): ShopServiceData;
|
|
360
|
+
getPickupTimingBooking(): PickupTimingBooking | null;
|
|
361
|
+
setPickupTimingBooking(input: PickupTimingBookingInput): PickupTimingBooking;
|
|
362
|
+
clearPickupTimingBooking(): void;
|
|
357
363
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
358
364
|
private buildTempOrderCustomer;
|
|
359
365
|
private isCustomerBoundDiscount;
|
|
@@ -498,6 +504,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
498
504
|
private hasSameEntitlementMergePriceConfig;
|
|
499
505
|
private getBundleRuntimeIdentity;
|
|
500
506
|
private preservePersistedBundlePriceFields;
|
|
507
|
+
private isRestrictedCartProductUpdate;
|
|
501
508
|
private applyOrderProductUpdateToTempOrder;
|
|
502
509
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
|
|
503
510
|
updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<OrderProduct[]>;
|
|
@@ -585,7 +592,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
585
592
|
generateIdempotencyToken(): string;
|
|
586
593
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
587
594
|
createOrder(params: CommitOrderParams['query']): {
|
|
588
|
-
type: "
|
|
595
|
+
type: "virtual" | "appointment_booking";
|
|
589
596
|
platform: string;
|
|
590
597
|
sales_channel: string;
|
|
591
598
|
order_sales_channel: string;
|
|
@@ -664,3 +671,5 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
664
671
|
getVouchers(): any[];
|
|
665
672
|
}
|
|
666
673
|
export type { AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, VirtualCurrencySnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
674
|
+
export { isFulfillmentTimingBooking } from './pickupTiming';
|
|
675
|
+
export type { PickupTimingBooking, PickupTimingBookingInput, PickupTimingBookingMetadata, PickupTimingSelectionMode, PickupTimingSource, } from './pickupTiming';
|
|
@@ -4,11 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.OrderModule = void 0;
|
|
7
|
+
Object.defineProperty(exports, "isFulfillmentTimingBooking", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _pickupTiming.isFulfillmentTimingBooking;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _loadSalesOrderSnapshot = require("../../shared/sales/loadSalesOrderSnapshot");
|
|
7
14
|
var _BaseModule = require("../BaseModule");
|
|
8
15
|
var _types = require("./types");
|
|
9
16
|
var _utils = require("./utils");
|
|
10
17
|
var _utils2 = require("../Product/utils");
|
|
11
18
|
var _weighedProduct = require("./utils/weighedProduct");
|
|
19
|
+
var _pickupTiming = require("./pickupTiming");
|
|
12
20
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
13
21
|
var _availability = require("../Discount/availability");
|
|
14
22
|
var _osPrivatePayload = require("../../utils/os-private-payload");
|
|
@@ -433,6 +441,29 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
433
441
|
this.otherParams = otherParams;
|
|
434
442
|
}
|
|
435
443
|
|
|
444
|
+
/** Internal intent boundary shared with asynchronous scanner/detail flows. */
|
|
445
|
+
createCartIntentCommitGuard(action, tempOrder = this.store.tempOrder) {
|
|
446
|
+
const hook = this.orderHooks?.beforeCartIntentCommit;
|
|
447
|
+
if (!hook) return () => {};
|
|
448
|
+
const getScope = this.orderHooks?.getCartIntentScope;
|
|
449
|
+
const scope = getScope?.();
|
|
450
|
+
const otherParams = this.otherParams;
|
|
451
|
+
let committed = false;
|
|
452
|
+
return () => {
|
|
453
|
+
if (this.store.tempOrder !== tempOrder || this.otherParams !== otherParams || this.orderHooks?.beforeCartIntentCommit !== hook || this.orderHooks?.getCartIntentScope !== getScope || getScope?.() !== scope) {
|
|
454
|
+
throw new Error('[Order] Cart intent belongs to a previous order or business');
|
|
455
|
+
}
|
|
456
|
+
// Derived gifts, discounts and persistence belong to the accepted intent,
|
|
457
|
+
// but an asynchronous continuation must never target a different cart.
|
|
458
|
+
if (committed) return;
|
|
459
|
+
hook({
|
|
460
|
+
action,
|
|
461
|
+
tempOrder
|
|
462
|
+
});
|
|
463
|
+
committed = true;
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
436
467
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
437
468
|
isOnlineStorePlatform() {
|
|
438
469
|
const platform = String(this.otherParams?.platform || '').trim().toLowerCase();
|
|
@@ -661,6 +692,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
661
692
|
});
|
|
662
693
|
}
|
|
663
694
|
async scanCode(code, customerId) {
|
|
695
|
+
const beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
|
|
664
696
|
if (this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
665
697
|
return {
|
|
666
698
|
type: 'clientCalc',
|
|
@@ -708,6 +740,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
708
740
|
}));
|
|
709
741
|
const currentSelected = this.getDiscountList().filter(n => n.isSelected);
|
|
710
742
|
if (currentSelected.length && currentSelected.some(n => withScanList.some(m => m.id === n.id))) {
|
|
743
|
+
beforeCommit();
|
|
711
744
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
712
745
|
return {
|
|
713
746
|
type: 'clientCalc',
|
|
@@ -741,6 +774,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
741
774
|
const normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
742
775
|
let resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
743
776
|
if (isAvailable && normalizedNewDiscountList) {
|
|
777
|
+
beforeCommit();
|
|
744
778
|
await this.store.discount?.setDiscountList(normalizedNewDiscountList);
|
|
745
779
|
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
746
780
|
this.applyDiscount({
|
|
@@ -749,6 +783,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
749
783
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
750
784
|
resolvedDiscountList = this.getDiscountList();
|
|
751
785
|
} else if (shouldRetainForLater) {
|
|
786
|
+
beforeCommit();
|
|
752
787
|
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
753
788
|
const retainedDiscounts = new Map(this.getDiscountList().map(discount => [String(discount.id), discount]));
|
|
754
789
|
evaluatedScannedDiscounts.forEach(discount => {
|
|
@@ -2275,6 +2310,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2275
2310
|
const bookingByBookingUid = new Map();
|
|
2276
2311
|
bookings.forEach(booking => {
|
|
2277
2312
|
if (!booking || typeof booking !== 'object') return;
|
|
2313
|
+
if ((0, _pickupTiming.isFulfillmentTimingBooking)(booking)) return;
|
|
2278
2314
|
const productUid = booking.product_uid || booking.metadata?.product_uid;
|
|
2279
2315
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
2280
2316
|
bookingByProductUid.set(String(productUid), booking);
|
|
@@ -2325,6 +2361,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2325
2361
|
let baseHolder = null;
|
|
2326
2362
|
const seen = new Set();
|
|
2327
2363
|
for (const booking of tempOrder.bookings || []) {
|
|
2364
|
+
if ((0, _pickupTiming.isFulfillmentTimingBooking)(booking)) continue;
|
|
2328
2365
|
const holder = booking?.holder && typeof booking.holder === 'object' ? booking.holder : null;
|
|
2329
2366
|
if (!baseHolder && holder) {
|
|
2330
2367
|
baseHolder = holder;
|
|
@@ -2365,7 +2402,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2365
2402
|
* this.syncTempOrderHolderFromBookings(tempOrder);
|
|
2366
2403
|
*/
|
|
2367
2404
|
syncTempOrderHolderFromBookings(tempOrder) {
|
|
2368
|
-
const bookings = tempOrder.bookings || [];
|
|
2405
|
+
const bookings = (tempOrder.bookings || []).filter(booking => !(0, _pickupTiming.isFulfillmentTimingBooking)(booking));
|
|
2369
2406
|
const hasHolderSource = bookings.some(booking => {
|
|
2370
2407
|
return booking?.holder !== undefined || booking?.metadata?.holder_id !== undefined;
|
|
2371
2408
|
});
|
|
@@ -2390,6 +2427,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2390
2427
|
const bookingUid = product?.booking_uid || product?.metadata?.booking_uid;
|
|
2391
2428
|
if (!productUid && !bookingUid) return;
|
|
2392
2429
|
tempOrder.bookings = (tempOrder.bookings || []).filter(booking => {
|
|
2430
|
+
if ((0, _pickupTiming.isFulfillmentTimingBooking)(booking)) return true;
|
|
2393
2431
|
const currentBookingUid = this.getBookingUniqueIdentificationNumber(booking);
|
|
2394
2432
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2395
2433
|
if (productUid && String(booking?.product_uid || '') === String(productUid)) return false;
|
|
@@ -2803,10 +2841,33 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2803
2841
|
});
|
|
2804
2842
|
}
|
|
2805
2843
|
updateTempOrderServiceType(serviceType) {
|
|
2844
|
+
if (serviceType !== 'pick_up') {
|
|
2845
|
+
const tempOrder = this.ensureTempOrder();
|
|
2846
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(booking => !(0, _pickupTiming.isFulfillmentTimingBooking)(booking));
|
|
2847
|
+
}
|
|
2806
2848
|
return this.updateTempOrderShopServiceData({
|
|
2807
2849
|
service_type: serviceType
|
|
2808
2850
|
});
|
|
2809
2851
|
}
|
|
2852
|
+
getPickupTimingBooking() {
|
|
2853
|
+
return (this.store.tempOrder?.bookings || []).find(_pickupTiming.isFulfillmentTimingBooking) || null;
|
|
2854
|
+
}
|
|
2855
|
+
setPickupTimingBooking(input) {
|
|
2856
|
+
const tempOrder = this.ensureTempOrder();
|
|
2857
|
+
const bookings = tempOrder.bookings || [];
|
|
2858
|
+
const firstIndex = bookings.findIndex(_pickupTiming.isFulfillmentTimingBooking);
|
|
2859
|
+
const nextBooking = (0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]);
|
|
2860
|
+
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
2861
|
+
tempOrder.bookings = firstIndex === -1 ? [...bookings, nextBooking] : bookings.flatMap((booking, index) => index === firstIndex ? [nextBooking] : (0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? [] : [booking]);
|
|
2862
|
+
this.notifyTempOrderChanged();
|
|
2863
|
+
return nextBooking;
|
|
2864
|
+
}
|
|
2865
|
+
clearPickupTimingBooking() {
|
|
2866
|
+
const tempOrder = this.store.tempOrder;
|
|
2867
|
+
if (!tempOrder?.bookings?.some(_pickupTiming.isFulfillmentTimingBooking)) return;
|
|
2868
|
+
tempOrder.bookings = tempOrder.bookings.filter(booking => !(0, _pickupTiming.isFulfillmentTimingBooking)(booking));
|
|
2869
|
+
this.notifyTempOrderChanged();
|
|
2870
|
+
}
|
|
2810
2871
|
updateTempOrderContactsInfo(contactsInfo) {
|
|
2811
2872
|
const tempOrder = this.ensureTempOrder();
|
|
2812
2873
|
tempOrder.contacts_info = contactsInfo && typeof contactsInfo === 'object' && !Array.isArray(contactsInfo) ? contactsInfo : null;
|
|
@@ -3429,7 +3490,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3429
3490
|
booking
|
|
3430
3491
|
}) : null;
|
|
3431
3492
|
const productToAdd = linked?.product || product;
|
|
3432
|
-
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
3433
3493
|
const disableMerge = options?.disableMerge === true;
|
|
3434
3494
|
const incomingFingerprint = disableMerge ? '' : (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(productToAdd), productToAdd.product_bundle);
|
|
3435
3495
|
const normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled((0, _utils.mergeOrderProductDisplayFields)(productToAdd, (0, _utils3.normalizeOrderProduct)(productToAdd)));
|
|
@@ -3491,6 +3551,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3491
3551
|
const matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3492
3552
|
const existedFingerprint = matchedProduct ? (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3493
3553
|
const commitProductLine = shouldMerge => {
|
|
3554
|
+
options?.beforeCommit?.();
|
|
3555
|
+
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
3494
3556
|
let committedProduct;
|
|
3495
3557
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3496
3558
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
@@ -3643,6 +3705,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3643
3705
|
*/
|
|
3644
3706
|
async addProductToOrder(product, booking, options) {
|
|
3645
3707
|
const tempOrder = this.ensureTempOrder();
|
|
3708
|
+
const beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
3646
3709
|
const salesNoteDrafts = (options?.salesNotes || []).map(draft => ({
|
|
3647
3710
|
note_type: String(draft.note_type || '').trim(),
|
|
3648
3711
|
text: {
|
|
@@ -3713,7 +3776,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3713
3776
|
}
|
|
3714
3777
|
const committedProduct = await this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
3715
3778
|
insertAtIndex,
|
|
3716
|
-
disableMerge: options?.disableMerge
|
|
3779
|
+
disableMerge: options?.disableMerge,
|
|
3780
|
+
beforeCommit
|
|
3717
3781
|
});
|
|
3718
3782
|
attachSalesNoteDrafts(committedProduct);
|
|
3719
3783
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
@@ -3721,14 +3785,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3721
3785
|
} else {
|
|
3722
3786
|
const committedProduct = await this.appendProductLineToTempOrder(tempOrder, product, (0, _lodashEs.cloneDeep)(booking), {
|
|
3723
3787
|
insertAtIndex,
|
|
3724
|
-
disableMerge: options?.disableMerge
|
|
3788
|
+
disableMerge: options?.disableMerge,
|
|
3789
|
+
beforeCommit
|
|
3725
3790
|
});
|
|
3726
3791
|
attachSalesNoteDrafts(committedProduct);
|
|
3727
3792
|
}
|
|
3728
3793
|
} else {
|
|
3729
3794
|
const committedProduct = await this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
3730
3795
|
insertAtIndex,
|
|
3731
|
-
disableMerge: options?.disableMerge
|
|
3796
|
+
disableMerge: options?.disableMerge,
|
|
3797
|
+
beforeCommit
|
|
3732
3798
|
});
|
|
3733
3799
|
attachSalesNoteDrafts(committedProduct);
|
|
3734
3800
|
}
|
|
@@ -3756,6 +3822,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3756
3822
|
async addProductsToOrder(items, options) {
|
|
3757
3823
|
const tempOrder = this.ensureTempOrder();
|
|
3758
3824
|
if (!Array.isArray(items) || items.length === 0) return tempOrder.products;
|
|
3825
|
+
const beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
3759
3826
|
for (const item of items || []) {
|
|
3760
3827
|
const {
|
|
3761
3828
|
product,
|
|
@@ -3768,13 +3835,17 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3768
3835
|
if (splitCount > 1) {
|
|
3769
3836
|
for (let i = 0; i < splitCount; i += 1) {
|
|
3770
3837
|
const splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
3771
|
-
const appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking
|
|
3838
|
+
const appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
3839
|
+
beforeCommit
|
|
3840
|
+
});
|
|
3772
3841
|
if (appendResult) await appendResult;
|
|
3773
3842
|
}
|
|
3774
3843
|
continue;
|
|
3775
3844
|
}
|
|
3776
3845
|
}
|
|
3777
|
-
const appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking
|
|
3846
|
+
const appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
3847
|
+
beforeCommit
|
|
3848
|
+
});
|
|
3778
3849
|
if (appendResult) await appendResult;
|
|
3779
3850
|
}
|
|
3780
3851
|
await this.finalizeProductOrderMutation(tempOrder, options);
|
|
@@ -3859,6 +3930,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3859
3930
|
};
|
|
3860
3931
|
});
|
|
3861
3932
|
}
|
|
3933
|
+
isRestrictedCartProductUpdate(tempOrder, params) {
|
|
3934
|
+
if (!this.orderHooks?.beforeCartIntentCommit) return false;
|
|
3935
|
+
if (params.booking || Object.keys(params.updates || {}).some(key => key !== 'num')) {
|
|
3936
|
+
return true;
|
|
3937
|
+
}
|
|
3938
|
+
if (params.updates?.num === undefined) return false;
|
|
3939
|
+
const uid = params.unique_identification_number;
|
|
3940
|
+
const product = uid !== undefined ? tempOrder.products.find(item => String(item.metadata?.unique_identification_number || item.unique_identification_number || '') === String(uid)) : tempOrder.products[(0, _utils3.getProductIdentityIndex)(tempOrder.products, params)];
|
|
3941
|
+
return !product || (0, _utils3.getSafeProductNum)(params.updates.num) > product.num;
|
|
3942
|
+
}
|
|
3862
3943
|
applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
3863
3944
|
const {
|
|
3864
3945
|
product_id,
|
|
@@ -4110,6 +4191,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4110
4191
|
}
|
|
4111
4192
|
async updateOrderProduct(params) {
|
|
4112
4193
|
const tempOrder = this.ensureTempOrder();
|
|
4194
|
+
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
4195
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
4196
|
+
}
|
|
4113
4197
|
const reapplyWeighedDiscountProductUids = [];
|
|
4114
4198
|
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
4115
4199
|
const promotionPayload = await this.evaluatePromotion();
|
|
@@ -4133,6 +4217,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4133
4217
|
if (!paramsList.length) {
|
|
4134
4218
|
return tempOrder.products;
|
|
4135
4219
|
}
|
|
4220
|
+
if (paramsList.some(params => this.isRestrictedCartProductUpdate(tempOrder, params))) {
|
|
4221
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
4222
|
+
}
|
|
4136
4223
|
const reapplyWeighedDiscountProductUids = [];
|
|
4137
4224
|
const reapplyBookingDiscountProductUids = paramsList.reduce((acc, params) => {
|
|
4138
4225
|
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
@@ -4217,6 +4304,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4217
4304
|
throw new _virtualSettlement.VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
4218
4305
|
}
|
|
4219
4306
|
}
|
|
4307
|
+
if (normalizedProduct.num > targetProduct.num) {
|
|
4308
|
+
this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
|
|
4309
|
+
}
|
|
4220
4310
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4221
4311
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
4222
4312
|
const isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
@@ -5044,13 +5134,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5044
5134
|
if (lookup.startsWith('LOCAL_')) {
|
|
5045
5135
|
params.forceRemote = false;
|
|
5046
5136
|
}
|
|
5047
|
-
const res = await this.request
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
} : {})
|
|
5052
|
-
}, {
|
|
5053
|
-
osServer: true
|
|
5137
|
+
const res = await (0, _loadSalesOrderSnapshot.loadSalesOrderSnapshot)(this.request, {
|
|
5138
|
+
lookup,
|
|
5139
|
+
transport: 'os-server',
|
|
5140
|
+
forceRemote: params.forceRemote
|
|
5054
5141
|
});
|
|
5055
5142
|
if (res.code === 200) {
|
|
5056
5143
|
this.store.lastOrderInfo = res.data;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type PickupTimingSelectionMode = 'asap' | 'scheduled';
|
|
2
|
+
export type PickupTimingSource = 'asap' | 'schedule' | 'pos_manual';
|
|
3
|
+
export interface PickupTimingBookingInput {
|
|
4
|
+
mode: PickupTimingSelectionMode;
|
|
5
|
+
source: PickupTimingSource;
|
|
6
|
+
/** Store-local calendar date and minute; the caller validates availability. */
|
|
7
|
+
date: string;
|
|
8
|
+
time: string;
|
|
9
|
+
/** Absolute timestamp disambiguates a repeated local minute at a DST change. */
|
|
10
|
+
instant?: string;
|
|
11
|
+
timezone?: string;
|
|
12
|
+
frozen?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface PickupTimingBookingMetadata {
|
|
15
|
+
unique_identification_number: string;
|
|
16
|
+
is_fulfillment_timing: true;
|
|
17
|
+
fulfillment_timing: {
|
|
18
|
+
method: 'pick_up';
|
|
19
|
+
mode: PickupTimingSelectionMode;
|
|
20
|
+
source: PickupTimingSource;
|
|
21
|
+
instant?: string;
|
|
22
|
+
timezone?: string;
|
|
23
|
+
frozen?: boolean;
|
|
24
|
+
};
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export interface PickupTimingBooking {
|
|
28
|
+
schedule_id: number | string;
|
|
29
|
+
start_date: string;
|
|
30
|
+
end_date: string;
|
|
31
|
+
start_time: string;
|
|
32
|
+
end_time: string;
|
|
33
|
+
select_date: string;
|
|
34
|
+
duration: 0;
|
|
35
|
+
is_all: 0;
|
|
36
|
+
sub_type: 'minutes';
|
|
37
|
+
like_status: string;
|
|
38
|
+
resources: [];
|
|
39
|
+
metadata: PickupTimingBookingMetadata;
|
|
40
|
+
schedule_event_id?: number | string;
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}
|
|
43
|
+
/** The explicit marker is the only authority; unlinked ordinary bookings remain ordinary. */
|
|
44
|
+
export declare function isFulfillmentTimingBooking(booking: unknown): boolean;
|
|
45
|
+
/** Update an independent pickup appointment without changing its persisted row identity. */
|
|
46
|
+
export declare function buildPickupTimingBooking(input: PickupTimingBookingInput, existing?: Record<string, any> | null): PickupTimingBooking;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildPickupTimingBooking = buildPickupTimingBooking;
|
|
7
|
+
exports.isFulfillmentTimingBooking = isFulfillmentTimingBooking;
|
|
8
|
+
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
9
|
+
/** The explicit marker is the only authority; unlinked ordinary bookings remain ordinary. */
|
|
10
|
+
function isFulfillmentTimingBooking(booking) {
|
|
11
|
+
return booking?.metadata?.is_fulfillment_timing === true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Update an independent pickup appointment without changing its persisted row identity. */
|
|
15
|
+
function buildPickupTimingBooking(input, existing) {
|
|
16
|
+
const booking = {
|
|
17
|
+
...(existing || {})
|
|
18
|
+
};
|
|
19
|
+
const metadata = {
|
|
20
|
+
...(booking.metadata || {})
|
|
21
|
+
};
|
|
22
|
+
// A fulfillment appointment never becomes a product/resource/holder purchase line.
|
|
23
|
+
for (const key of ['product_uid', 'product', 'holder', 'holder_id', 'collect_pax', 'capacity']) {
|
|
24
|
+
delete booking[key];
|
|
25
|
+
delete metadata[key];
|
|
26
|
+
}
|
|
27
|
+
delete metadata.booking_uid;
|
|
28
|
+
return {
|
|
29
|
+
...booking,
|
|
30
|
+
schedule_id: booking.schedule_id || 0,
|
|
31
|
+
start_date: input.date,
|
|
32
|
+
end_date: input.date,
|
|
33
|
+
start_time: input.time,
|
|
34
|
+
end_time: input.time,
|
|
35
|
+
select_date: input.date,
|
|
36
|
+
duration: 0,
|
|
37
|
+
is_all: 0,
|
|
38
|
+
sub_type: 'minutes',
|
|
39
|
+
like_status: booking.like_status || 'common',
|
|
40
|
+
resources: [],
|
|
41
|
+
metadata: {
|
|
42
|
+
...metadata,
|
|
43
|
+
unique_identification_number: String(metadata.unique_identification_number || (0, _orderCollectionIdentity.createUuidV4)()),
|
|
44
|
+
is_fulfillment_timing: true,
|
|
45
|
+
fulfillment_timing: {
|
|
46
|
+
method: 'pick_up',
|
|
47
|
+
mode: input.mode,
|
|
48
|
+
source: input.source,
|
|
49
|
+
...(input.instant !== undefined ? {
|
|
50
|
+
instant: input.instant
|
|
51
|
+
} : {}),
|
|
52
|
+
...(input.timezone !== undefined ? {
|
|
53
|
+
timezone: input.timezone
|
|
54
|
+
} : {}),
|
|
55
|
+
...(input.frozen !== undefined ? {
|
|
56
|
+
frozen: input.frozen
|
|
57
|
+
} : {})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -7,9 +7,10 @@ import type { SubmitPayloadEnhancer } from './utils';
|
|
|
7
7
|
import type { PaymentItem } from '../Payment/types';
|
|
8
8
|
import type { ICustomer } from '../AccountList/types';
|
|
9
9
|
import type { OrderProductDiscountItem } from '../../server/modules/order/types';
|
|
10
|
+
import type { PickupTimingBooking, PickupTimingBookingInput } from './pickupTiming';
|
|
10
11
|
export type { OrderProductDiscountItem } from '../../server/modules/order/types';
|
|
11
12
|
export type PickupReferenceMode = 'counter_pickup' | 'table_service';
|
|
12
|
-
export type ShopServiceType = 'dine_in' | 'takeaway';
|
|
13
|
+
export type ShopServiceType = 'dine_in' | 'takeaway' | 'pick_up' | 'delivery';
|
|
13
14
|
export interface ShopServiceData {
|
|
14
15
|
pickup_reference_mode?: PickupReferenceMode;
|
|
15
16
|
service_type?: ShopServiceType | '';
|
|
@@ -516,7 +517,15 @@ export type OrderProductMergeDecisionResult = boolean | {
|
|
|
516
517
|
reason?: string;
|
|
517
518
|
[key: string]: any;
|
|
518
519
|
};
|
|
520
|
+
export interface OrderCartIntentCommitContext {
|
|
521
|
+
action: 'add_product' | 'update_product' | 'increase_quantity' | 'scan_promotion';
|
|
522
|
+
tempOrder: OrderTempOrder | null;
|
|
523
|
+
}
|
|
519
524
|
export interface OrderHooksConfig {
|
|
525
|
+
/** Optional customer-order guard; called synchronously before the first cart write. */
|
|
526
|
+
beforeCartIntentCommit?: (context: OrderCartIntentCommitContext) => void;
|
|
527
|
+
/** Captures tenant/business runtime identity for asynchronous cart intents. */
|
|
528
|
+
getCartIntentScope?: () => unknown;
|
|
520
529
|
onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
|
|
521
530
|
}
|
|
522
531
|
/**
|
|
@@ -863,6 +872,9 @@ export interface OrderModuleAPI {
|
|
|
863
872
|
updateTempOrderCustomer: (customer: UpdateTempOrderCustomerInput) => OrderSnapshot['customer'];
|
|
864
873
|
updateTempOrderPickupReferenceMode: (mode: PickupReferenceMode) => ShopServiceData;
|
|
865
874
|
updateTempOrderServiceType: (serviceType: ShopServiceType) => ShopServiceData;
|
|
875
|
+
getPickupTimingBooking: () => PickupTimingBooking | null;
|
|
876
|
+
setPickupTimingBooking: (input: PickupTimingBookingInput) => PickupTimingBooking;
|
|
877
|
+
clearPickupTimingBooking: () => void;
|
|
866
878
|
updateTempOrderBuzzer: (buzzer: string) => string;
|
|
867
879
|
updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
|
|
868
880
|
addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions) => Promise<OrderProduct[]>;
|
|
@@ -137,6 +137,7 @@ var _utils = require("../Holder/utils");
|
|
|
137
137
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
138
138
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
139
139
|
var _salesNotes = require("./salesNotes");
|
|
140
|
+
var _pickupTiming = require("./pickupTiming");
|
|
140
141
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
141
142
|
_dayjs.default.extend(_customParseFormat.default);
|
|
142
143
|
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
@@ -1299,7 +1300,7 @@ function normalizeSubmitProduct(product, formatOptions = {}) {
|
|
|
1299
1300
|
payment_price: formatOptions.virtualSettlementMode ? virtualPrice : submitProduct.payment_price ?? submitProduct.selling_price
|
|
1300
1301
|
};
|
|
1301
1302
|
}
|
|
1302
|
-
const SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder'];
|
|
1303
|
+
const SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder', 'is_fulfillment_timing', 'fulfillment_timing'];
|
|
1303
1304
|
function normalizeBookingIsAll(booking) {
|
|
1304
1305
|
return booking.is_all === true || booking.is_all === 1 || booking.is_all === '1' || booking.is_all === 'true' ? 1 : 0;
|
|
1305
1306
|
}
|
|
@@ -1318,7 +1319,9 @@ function normalizeSubmitBooking(booking) {
|
|
|
1318
1319
|
cleanMetadata[key] = rawMetadata[key];
|
|
1319
1320
|
}
|
|
1320
1321
|
}
|
|
1321
|
-
if (cleanMetadata.holder_id === undefined
|
|
1322
|
+
if (cleanMetadata.holder_id === undefined && !(0, _pickupTiming.isFulfillmentTimingBooking)(booking)) {
|
|
1323
|
+
cleanMetadata.holder_id = null;
|
|
1324
|
+
}
|
|
1322
1325
|
const bookingRecord = booking;
|
|
1323
1326
|
const startDate = bookingRecord.start_date;
|
|
1324
1327
|
const shouldRestoreSelectDate = bookingRecord.select_date === undefined || bookingRecord.select_date === null || bookingRecord.select_date === '';
|
|
@@ -1330,6 +1333,10 @@ function normalizeSubmitBooking(booking) {
|
|
|
1330
1333
|
} : {}),
|
|
1331
1334
|
is_all: normalizeBookingIsAll(bookingRecord),
|
|
1332
1335
|
sub_type: normalizeBookingSubType(bookingRecord),
|
|
1336
|
+
...((0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? {
|
|
1337
|
+
like_status: bookingRecord.like_status || 'common',
|
|
1338
|
+
schedule_id: bookingRecord.schedule_id || 0
|
|
1339
|
+
} : {}),
|
|
1333
1340
|
metadata: cleanMetadata
|
|
1334
1341
|
};
|
|
1335
1342
|
}
|
|
@@ -1415,6 +1422,7 @@ function hasBoundBookingResource(bookings) {
|
|
|
1415
1422
|
if (!Array.isArray(bookings)) return false;
|
|
1416
1423
|
return bookings.some(booking => {
|
|
1417
1424
|
if (!booking || typeof booking !== 'object') return false;
|
|
1425
|
+
if ((0, _pickupTiming.isFulfillmentTimingBooking)(booking)) return false;
|
|
1418
1426
|
if (Number(booking.parent_id) === 0) return false;
|
|
1419
1427
|
const resources = booking.resources;
|
|
1420
1428
|
if (!Array.isArray(resources)) return false;
|
|
@@ -1450,7 +1458,7 @@ function resolveSubmitOrderType(params) {
|
|
|
1450
1458
|
return 'table-order';
|
|
1451
1459
|
}
|
|
1452
1460
|
if (currentType) return currentType;
|
|
1453
|
-
if (Array.isArray(bookings) && bookings.
|
|
1461
|
+
if (Array.isArray(bookings) && bookings.some(booking => !(0, _pickupTiming.isFulfillmentTimingBooking)(booking))) {
|
|
1454
1462
|
return businessCode === 'dine_in' ? 'table-order' : 'appointment_booking';
|
|
1455
1463
|
}
|
|
1456
1464
|
return 'virtual';
|
|
@@ -1535,7 +1543,7 @@ function buildSubmitPayload(params) {
|
|
|
1535
1543
|
delivery_type: tempOrder.delivery_type || 'nil',
|
|
1536
1544
|
schedule_date: scheduleDate,
|
|
1537
1545
|
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
1538
|
-
bookings: (tempOrder.bookings || []).filter(booking => Number(booking.parent_id) !== 0).map(booking => normalizeSubmitBooking(booking)),
|
|
1546
|
+
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => normalizeSubmitBooking(booking)),
|
|
1539
1547
|
payments: tempOrder.payments || [],
|
|
1540
1548
|
relation_forms: tempOrder.relation_forms || [],
|
|
1541
1549
|
// contacts: tempOrder.contacts || [],
|