@pisell/pisellos 2.3.130 → 2.3.132
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/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/OpenData/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +5 -2
- package/dist/modules/Order/index.js +315 -241
- package/dist/modules/Order/types.d.ts +8 -0
- package/dist/solution/BaseSales/index.d.ts +4 -15
- package/dist/solution/BaseSales/index.js +151 -89
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +41 -13
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/dist/solution/UnifiedBookingSales/index.js +154 -75
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/dist/solution/VenueBooking/index.js +45 -44
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/OpenData/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +5 -2
- package/lib/modules/Order/index.js +62 -6
- package/lib/modules/Order/types.d.ts +8 -0
- package/lib/solution/BaseSales/index.d.ts +4 -15
- package/lib/solution/BaseSales/index.js +64 -24
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +37 -4
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/lib/solution/UnifiedBookingSales/index.js +54 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/solution/VenueBooking/index.js +9 -8
- package/package.json +1 -1
|
@@ -441,6 +441,29 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
441
441
|
this.otherParams = otherParams;
|
|
442
442
|
}
|
|
443
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
|
+
|
|
444
467
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
445
468
|
isOnlineStorePlatform() {
|
|
446
469
|
const platform = String(this.otherParams?.platform || '').trim().toLowerCase();
|
|
@@ -669,6 +692,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
669
692
|
});
|
|
670
693
|
}
|
|
671
694
|
async scanCode(code, customerId) {
|
|
695
|
+
const beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
|
|
672
696
|
if (this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
673
697
|
return {
|
|
674
698
|
type: 'clientCalc',
|
|
@@ -716,6 +740,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
716
740
|
}));
|
|
717
741
|
const currentSelected = this.getDiscountList().filter(n => n.isSelected);
|
|
718
742
|
if (currentSelected.length && currentSelected.some(n => withScanList.some(m => m.id === n.id))) {
|
|
743
|
+
beforeCommit();
|
|
719
744
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
720
745
|
return {
|
|
721
746
|
type: 'clientCalc',
|
|
@@ -749,6 +774,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
749
774
|
const normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
750
775
|
let resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
751
776
|
if (isAvailable && normalizedNewDiscountList) {
|
|
777
|
+
beforeCommit();
|
|
752
778
|
await this.store.discount?.setDiscountList(normalizedNewDiscountList);
|
|
753
779
|
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
754
780
|
this.applyDiscount({
|
|
@@ -757,6 +783,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
757
783
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
758
784
|
resolvedDiscountList = this.getDiscountList();
|
|
759
785
|
} else if (shouldRetainForLater) {
|
|
786
|
+
beforeCommit();
|
|
760
787
|
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
761
788
|
const retainedDiscounts = new Map(this.getDiscountList().map(discount => [String(discount.id), discount]));
|
|
762
789
|
evaluatedScannedDiscounts.forEach(discount => {
|
|
@@ -3463,7 +3490,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3463
3490
|
booking
|
|
3464
3491
|
}) : null;
|
|
3465
3492
|
const productToAdd = linked?.product || product;
|
|
3466
|
-
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
3467
3493
|
const disableMerge = options?.disableMerge === true;
|
|
3468
3494
|
const incomingFingerprint = disableMerge ? '' : (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(productToAdd), productToAdd.product_bundle);
|
|
3469
3495
|
const normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled((0, _utils.mergeOrderProductDisplayFields)(productToAdd, (0, _utils3.normalizeOrderProduct)(productToAdd)));
|
|
@@ -3525,6 +3551,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3525
3551
|
const matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3526
3552
|
const existedFingerprint = matchedProduct ? (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3527
3553
|
const commitProductLine = shouldMerge => {
|
|
3554
|
+
options?.beforeCommit?.();
|
|
3555
|
+
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
3528
3556
|
let committedProduct;
|
|
3529
3557
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3530
3558
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
@@ -3677,6 +3705,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3677
3705
|
*/
|
|
3678
3706
|
async addProductToOrder(product, booking, options) {
|
|
3679
3707
|
const tempOrder = this.ensureTempOrder();
|
|
3708
|
+
const beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
3680
3709
|
const salesNoteDrafts = (options?.salesNotes || []).map(draft => ({
|
|
3681
3710
|
note_type: String(draft.note_type || '').trim(),
|
|
3682
3711
|
text: {
|
|
@@ -3747,7 +3776,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3747
3776
|
}
|
|
3748
3777
|
const committedProduct = await this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
3749
3778
|
insertAtIndex,
|
|
3750
|
-
disableMerge: options?.disableMerge
|
|
3779
|
+
disableMerge: options?.disableMerge,
|
|
3780
|
+
beforeCommit
|
|
3751
3781
|
});
|
|
3752
3782
|
attachSalesNoteDrafts(committedProduct);
|
|
3753
3783
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
@@ -3755,14 +3785,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3755
3785
|
} else {
|
|
3756
3786
|
const committedProduct = await this.appendProductLineToTempOrder(tempOrder, product, (0, _lodashEs.cloneDeep)(booking), {
|
|
3757
3787
|
insertAtIndex,
|
|
3758
|
-
disableMerge: options?.disableMerge
|
|
3788
|
+
disableMerge: options?.disableMerge,
|
|
3789
|
+
beforeCommit
|
|
3759
3790
|
});
|
|
3760
3791
|
attachSalesNoteDrafts(committedProduct);
|
|
3761
3792
|
}
|
|
3762
3793
|
} else {
|
|
3763
3794
|
const committedProduct = await this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
3764
3795
|
insertAtIndex,
|
|
3765
|
-
disableMerge: options?.disableMerge
|
|
3796
|
+
disableMerge: options?.disableMerge,
|
|
3797
|
+
beforeCommit
|
|
3766
3798
|
});
|
|
3767
3799
|
attachSalesNoteDrafts(committedProduct);
|
|
3768
3800
|
}
|
|
@@ -3790,6 +3822,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3790
3822
|
async addProductsToOrder(items, options) {
|
|
3791
3823
|
const tempOrder = this.ensureTempOrder();
|
|
3792
3824
|
if (!Array.isArray(items) || items.length === 0) return tempOrder.products;
|
|
3825
|
+
const beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
3793
3826
|
for (const item of items || []) {
|
|
3794
3827
|
const {
|
|
3795
3828
|
product,
|
|
@@ -3802,13 +3835,17 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3802
3835
|
if (splitCount > 1) {
|
|
3803
3836
|
for (let i = 0; i < splitCount; i += 1) {
|
|
3804
3837
|
const splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
3805
|
-
const appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking
|
|
3838
|
+
const appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
3839
|
+
beforeCommit
|
|
3840
|
+
});
|
|
3806
3841
|
if (appendResult) await appendResult;
|
|
3807
3842
|
}
|
|
3808
3843
|
continue;
|
|
3809
3844
|
}
|
|
3810
3845
|
}
|
|
3811
|
-
const appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking
|
|
3846
|
+
const appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
3847
|
+
beforeCommit
|
|
3848
|
+
});
|
|
3812
3849
|
if (appendResult) await appendResult;
|
|
3813
3850
|
}
|
|
3814
3851
|
await this.finalizeProductOrderMutation(tempOrder, options);
|
|
@@ -3893,6 +3930,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3893
3930
|
};
|
|
3894
3931
|
});
|
|
3895
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
|
+
}
|
|
3896
3943
|
applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
3897
3944
|
const {
|
|
3898
3945
|
product_id,
|
|
@@ -4144,6 +4191,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4144
4191
|
}
|
|
4145
4192
|
async updateOrderProduct(params) {
|
|
4146
4193
|
const tempOrder = this.ensureTempOrder();
|
|
4194
|
+
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
4195
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
4196
|
+
}
|
|
4147
4197
|
const reapplyWeighedDiscountProductUids = [];
|
|
4148
4198
|
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
4149
4199
|
const promotionPayload = await this.evaluatePromotion();
|
|
@@ -4167,6 +4217,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4167
4217
|
if (!paramsList.length) {
|
|
4168
4218
|
return tempOrder.products;
|
|
4169
4219
|
}
|
|
4220
|
+
if (paramsList.some(params => this.isRestrictedCartProductUpdate(tempOrder, params))) {
|
|
4221
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
4222
|
+
}
|
|
4170
4223
|
const reapplyWeighedDiscountProductUids = [];
|
|
4171
4224
|
const reapplyBookingDiscountProductUids = paramsList.reduce((acc, params) => {
|
|
4172
4225
|
const updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
@@ -4251,6 +4304,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4251
4304
|
throw new _virtualSettlement.VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
4252
4305
|
}
|
|
4253
4306
|
}
|
|
4307
|
+
if (normalizedProduct.num > targetProduct.num) {
|
|
4308
|
+
this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
|
|
4309
|
+
}
|
|
4254
4310
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4255
4311
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
4256
4312
|
const isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
@@ -517,7 +517,15 @@ export type OrderProductMergeDecisionResult = boolean | {
|
|
|
517
517
|
reason?: string;
|
|
518
518
|
[key: string]: any;
|
|
519
519
|
};
|
|
520
|
+
export interface OrderCartIntentCommitContext {
|
|
521
|
+
action: 'add_product' | 'update_product' | 'increase_quantity' | 'scan_promotion';
|
|
522
|
+
tempOrder: OrderTempOrder | null;
|
|
523
|
+
}
|
|
520
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;
|
|
521
529
|
onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
|
|
522
530
|
}
|
|
523
531
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
-
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentOptions, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
|
|
3
|
+
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesSubmitSalesOrderParams, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentOptions, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
5
|
import { type PickupTimingBookingInput } from '../../modules/Order/pickupTiming';
|
|
6
6
|
import type { PickupTimingAvailability, PickupTimingSelection, PickupTimingValidationResult } from '../../modules/FulfillmentTiming';
|
|
@@ -339,13 +339,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
339
339
|
productList?: Record<string, any>[];
|
|
340
340
|
discountList?: Discount[];
|
|
341
341
|
}): Promise<void>;
|
|
342
|
-
submitScanOrder<T = any>(params?:
|
|
343
|
-
|
|
344
|
-
paymentStatus?: BaseSalesPaymentStatus;
|
|
345
|
-
smallTicketDataFlag?: number;
|
|
346
|
-
confirmPendingVoucherPayments?: boolean;
|
|
347
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
348
|
-
}): Promise<T>;
|
|
342
|
+
submitScanOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
343
|
+
private buildVirtualSettlementOrderData;
|
|
349
344
|
private buildVirtualSettlementSubmitData;
|
|
350
345
|
/**
|
|
351
346
|
* 提交当前 Sales 订单。
|
|
@@ -353,13 +348,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
353
348
|
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
354
349
|
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
355
350
|
*/
|
|
356
|
-
submitSalesOrder<T = any>(params?:
|
|
357
|
-
payments?: OrderPaymentSource[];
|
|
358
|
-
paymentStatus?: BaseSalesPaymentStatus;
|
|
359
|
-
smallTicketDataFlag?: number;
|
|
360
|
-
confirmPendingVoucherPayments?: boolean;
|
|
361
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
362
|
-
}): Promise<T>;
|
|
351
|
+
submitSalesOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
363
352
|
saveSalesOrderDraft<T = any>(params?: {
|
|
364
353
|
platform?: string;
|
|
365
354
|
businessCode?: string;
|
|
@@ -2484,7 +2484,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2484
2484
|
// Deprecated compatibility alias. New BaseSales callers should use submitSalesOrder.
|
|
2485
2485
|
return this.submitSalesOrder(params);
|
|
2486
2486
|
}
|
|
2487
|
-
|
|
2487
|
+
buildVirtualSettlementOrderData() {
|
|
2488
2488
|
if (!this.store.order) return null;
|
|
2489
2489
|
const tempOrder = this.store.order.getTempOrder();
|
|
2490
2490
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) return null;
|
|
@@ -2493,6 +2493,21 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2493
2493
|
if (!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0) {
|
|
2494
2494
|
throw new Error('Virtual currency settlement configuration is invalid.');
|
|
2495
2495
|
}
|
|
2496
|
+
return {
|
|
2497
|
+
snapshot,
|
|
2498
|
+
currencyProductId,
|
|
2499
|
+
currencyCode: String(tempOrder?.currency_code || ''),
|
|
2500
|
+
currencySymbol: String(tempOrder?.currency_symbol || ''),
|
|
2501
|
+
currencyFormat: String(tempOrder?.currency_format || 'symbol_first')
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2504
|
+
async buildVirtualSettlementSubmitData() {
|
|
2505
|
+
const settlement = this.buildVirtualSettlementOrderData();
|
|
2506
|
+
if (!settlement || !this.store.order) return null;
|
|
2507
|
+
const tempOrder = this.store.order.getTempOrder();
|
|
2508
|
+
const {
|
|
2509
|
+
currencyProductId
|
|
2510
|
+
} = settlement;
|
|
2496
2511
|
const summary = await this.store.order.recalculateSummary({
|
|
2497
2512
|
createIfMissing: true
|
|
2498
2513
|
});
|
|
@@ -2507,17 +2522,10 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2507
2522
|
});
|
|
2508
2523
|
}
|
|
2509
2524
|
const asset = this.store.order.getVirtualCurrencyList().find(item => Number(item?.product_id) === currencyProductId);
|
|
2510
|
-
const currencyCode = String(tempOrder?.currency_code || '');
|
|
2511
|
-
const currencySymbol = String(tempOrder?.currency_symbol || '');
|
|
2512
|
-
const currencyFormat = String(tempOrder?.currency_format || 'symbol_first');
|
|
2513
2525
|
if (amount.lte(0)) {
|
|
2514
2526
|
return {
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
currencyProductId,
|
|
2518
|
-
currencyCode,
|
|
2519
|
-
currencySymbol,
|
|
2520
|
-
currencyFormat
|
|
2527
|
+
...settlement,
|
|
2528
|
+
payments: []
|
|
2521
2529
|
};
|
|
2522
2530
|
}
|
|
2523
2531
|
if (!asset) {
|
|
@@ -2571,12 +2579,8 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2571
2579
|
};
|
|
2572
2580
|
}
|
|
2573
2581
|
return {
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
currencyProductId,
|
|
2577
|
-
currencyCode,
|
|
2578
|
-
currencySymbol,
|
|
2579
|
-
currencyFormat
|
|
2582
|
+
...settlement,
|
|
2583
|
+
payments: [payment]
|
|
2580
2584
|
};
|
|
2581
2585
|
}
|
|
2582
2586
|
|
|
@@ -2593,11 +2597,45 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2593
2597
|
if (this.isPickupTimingEnabled()) await this.preparePickupTimingForCheckout({
|
|
2594
2598
|
freeze: true
|
|
2595
2599
|
});
|
|
2596
|
-
const
|
|
2600
|
+
const isDeferredPayment = params?.paymentExecution === 'deferred';
|
|
2601
|
+
const virtualPaymentSettlement = isDeferredPayment ? null : await this.buildVirtualSettlementSubmitData();
|
|
2602
|
+
const virtualSettlement = isDeferredPayment ? this.buildVirtualSettlementOrderData() : virtualPaymentSettlement;
|
|
2597
2603
|
// this.store.order.persistTempOrder();
|
|
2598
|
-
const inferredPaymentStatus = this.getSubmitPaymentStatus(params?.paymentStatus);
|
|
2604
|
+
const inferredPaymentStatus = isDeferredPayment ? undefined : this.getSubmitPaymentStatus(params?.paymentStatus);
|
|
2599
2605
|
const smallTicketDataFlag = params?.smallTicketDataFlag ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2600
|
-
const
|
|
2606
|
+
const virtualSettlementEnhancePayload = virtualSettlement ? (payload, ctx) => {
|
|
2607
|
+
const callerPayload = params?.enhancePayload ? params.enhancePayload(payload, ctx) : payload;
|
|
2608
|
+
const currencySettlementConfig = callerPayload.metadata?.currency_settlement_config || {};
|
|
2609
|
+
return {
|
|
2610
|
+
...callerPayload,
|
|
2611
|
+
metadata: {
|
|
2612
|
+
...(callerPayload.metadata || {}),
|
|
2613
|
+
currency_settlement_config: {
|
|
2614
|
+
...currencySettlementConfig,
|
|
2615
|
+
settlement_type: 'virtual_currency',
|
|
2616
|
+
settlement_ids: [virtualSettlement.currencyProductId],
|
|
2617
|
+
currency_display_snapshot: (0, _lodashEs.cloneDeep)(currencySettlementConfig.currency_display_snapshot ?? (0, _virtualSettlement.buildCurrencyDisplaySnapshot)(virtualSettlement.snapshot))
|
|
2618
|
+
}
|
|
2619
|
+
},
|
|
2620
|
+
currency_code: virtualSettlement.currencyCode,
|
|
2621
|
+
currency_symbol: virtualSettlement.currencySymbol,
|
|
2622
|
+
currency_format: virtualSettlement.currencyFormat
|
|
2623
|
+
};
|
|
2624
|
+
} : params?.enhancePayload;
|
|
2625
|
+
const configuredEnhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(virtualSettlementEnhancePayload);
|
|
2626
|
+
// Apply this last so neither a stale draft status nor a caller enhancer can
|
|
2627
|
+
// turn deferred submission into payment. The live wallet selection is untouched.
|
|
2628
|
+
const enhancePayload = isDeferredPayment ? (payload, ctx) => {
|
|
2629
|
+
const enhancedPayload = configuredEnhancePayload ? configuredEnhancePayload(payload, ctx) : payload;
|
|
2630
|
+
const {
|
|
2631
|
+
payment_status: _paymentStatus,
|
|
2632
|
+
...orderPayload
|
|
2633
|
+
} = enhancedPayload;
|
|
2634
|
+
return {
|
|
2635
|
+
...orderPayload,
|
|
2636
|
+
payments: []
|
|
2637
|
+
};
|
|
2638
|
+
} : configuredEnhancePayload;
|
|
2601
2639
|
const submitParams = {
|
|
2602
2640
|
cacheId: this.cacheId,
|
|
2603
2641
|
platform: this.otherParams?.platform,
|
|
@@ -2605,8 +2643,10 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2605
2643
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2606
2644
|
type: this.otherParams?.type,
|
|
2607
2645
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken(),
|
|
2608
|
-
...(
|
|
2609
|
-
payments:
|
|
2646
|
+
...(isDeferredPayment ? {
|
|
2647
|
+
payments: []
|
|
2648
|
+
} : virtualPaymentSettlement ? {
|
|
2649
|
+
payments: virtualPaymentSettlement.payments
|
|
2610
2650
|
} : params?.payments !== undefined ? {
|
|
2611
2651
|
payments: params.payments
|
|
2612
2652
|
} : {}),
|
|
@@ -2616,7 +2656,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2616
2656
|
...(smallTicketDataFlag !== undefined ? {
|
|
2617
2657
|
smallTicketDataFlag
|
|
2618
2658
|
} : {}),
|
|
2619
|
-
...(virtualSettlement ? {
|
|
2659
|
+
...(isDeferredPayment || virtualSettlement ? {
|
|
2620
2660
|
confirmPendingVoucherPayments: false
|
|
2621
2661
|
} : params?.confirmPendingVoucherPayments !== undefined ? {
|
|
2622
2662
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
@@ -3981,7 +4021,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
3981
4021
|
async addProductToOrder(product, booking, options) {
|
|
3982
4022
|
try {
|
|
3983
4023
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3984
|
-
const products = await this.store.order.addProductToOrder(product, booking, options);
|
|
4024
|
+
const products = options === undefined ? await this.store.order.addProductToOrder(product, booking) : await this.store.order.addProductToOrder(product, booking, options);
|
|
3985
4025
|
// // 需要叠加
|
|
3986
4026
|
// if (this.hooks.onAddProductOverlay) {
|
|
3987
4027
|
// const res = this.hooks.onAddProductOverlay(是否叠加, product)
|
|
@@ -4070,7 +4110,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4070
4110
|
async removeProductsFromOrder(identities, options) {
|
|
4071
4111
|
try {
|
|
4072
4112
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
4073
|
-
return await this.store.order.removeProductsFromOrder(identities, options);
|
|
4113
|
+
return options === undefined ? await this.store.order.removeProductsFromOrder(identities) : await this.store.order.removeProductsFromOrder(identities, options);
|
|
4074
4114
|
} catch (error) {
|
|
4075
4115
|
throw error;
|
|
4076
4116
|
}
|
|
@@ -4,6 +4,8 @@ import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderCon
|
|
|
4
4
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
5
5
|
import type { QuotationCustomerScopeInfo } from '../../modules/Quotation/types';
|
|
6
6
|
import type { PaymentMethod } from '../../modules/Payment/types';
|
|
7
|
+
import type { OrderPaymentSource } from '../../modules/Order/types';
|
|
8
|
+
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
9
|
/**
|
|
8
10
|
* BaseSales 流程 hook 后缀。
|
|
9
11
|
* 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
|
|
@@ -27,6 +29,15 @@ export interface BaseSalesCashPaymentOptions {
|
|
|
27
29
|
/** 指定现金支付方式;省略时使用默认 CASHMANUAL。 */
|
|
28
30
|
paymentMethodId?: number | string;
|
|
29
31
|
}
|
|
32
|
+
export interface BaseSalesSubmitSalesOrderParams {
|
|
33
|
+
payments?: OrderPaymentSource[];
|
|
34
|
+
paymentStatus?: BaseSalesPaymentStatus;
|
|
35
|
+
smallTicketDataFlag?: number;
|
|
36
|
+
confirmPendingVoucherPayments?: boolean;
|
|
37
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
38
|
+
/** Create the order without executing payment; payment status comes from the server. */
|
|
39
|
+
paymentExecution?: 'deferred';
|
|
40
|
+
}
|
|
30
41
|
export interface BaseSalesCashPaymentConfig {
|
|
31
42
|
available: boolean;
|
|
32
43
|
paymentMethod?: PaymentMethod;
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 |
|
|
329
|
+
weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -346,7 +346,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
346
346
|
* 获取当前的客户搜索条件
|
|
347
347
|
* @returns 当前搜索条件
|
|
348
348
|
*/
|
|
349
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
349
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
350
350
|
/**
|
|
351
351
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
352
352
|
* @returns 客户状态
|
|
@@ -1672,6 +1672,30 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1672
1672
|
};
|
|
1673
1673
|
}
|
|
1674
1674
|
try {
|
|
1675
|
+
// Capture before lookup/UI awaits, so a result cannot land in a new cart.
|
|
1676
|
+
// Unscoped POS Order modules return a no-op guard.
|
|
1677
|
+
const beforeScanCommit = this.store.order.createCartIntentCommitGuard('add_product');
|
|
1678
|
+
const beforeScanDialog = this.store.order.createCartIntentCommitGuard('add_product');
|
|
1679
|
+
const guardCallback = callback => callback ? (...args) => {
|
|
1680
|
+
beforeScanCommit();
|
|
1681
|
+
return callback(...args);
|
|
1682
|
+
} : undefined;
|
|
1683
|
+
const guardedBridge = bridge ? {
|
|
1684
|
+
...bridge,
|
|
1685
|
+
confirmDetail: guardCallback(bridge.confirmDetail),
|
|
1686
|
+
confirmBookingEdit: guardCallback(bridge.confirmBookingEdit),
|
|
1687
|
+
applyPromotionCode: guardCallback(bridge.applyPromotionCode),
|
|
1688
|
+
openOrder: guardCallback(bridge.openOrder),
|
|
1689
|
+
requestCustomerSwitch: guardCallback(bridge.requestCustomerSwitch),
|
|
1690
|
+
openProductDetail: bridge.openProductDetail ? payload => {
|
|
1691
|
+
beforeScanDialog();
|
|
1692
|
+
return bridge.openProductDetail(payload);
|
|
1693
|
+
} : undefined,
|
|
1694
|
+
openBookingEdit: bridge.openBookingEdit ? payload => {
|
|
1695
|
+
beforeScanDialog();
|
|
1696
|
+
return bridge.openBookingEdit(payload);
|
|
1697
|
+
} : undefined
|
|
1698
|
+
} : undefined;
|
|
1675
1699
|
const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1676
1700
|
const scanCallback = (0, _handleScan.handleGlobalScan)(this.request, localSearch, this.getSubmitOrderSalesChannel());
|
|
1677
1701
|
const raw = await scanCallback({
|
|
@@ -1687,7 +1711,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1687
1711
|
};
|
|
1688
1712
|
}
|
|
1689
1713
|
const result = await (0, _applyGlobalScan.applyGlobalScan)({
|
|
1690
|
-
setOrderCustomer: customer =>
|
|
1714
|
+
setOrderCustomer: customer => {
|
|
1715
|
+
beforeScanCommit();
|
|
1716
|
+
this.setOrderCustomer(customer);
|
|
1717
|
+
},
|
|
1691
1718
|
getOrderCustomerSnapshot: () => this.getOrderCustomerSnapshot(),
|
|
1692
1719
|
resolveCustomerById: customerId => this.resolveCustomerById(customerId),
|
|
1693
1720
|
getBusinessCode: () => this.otherParams?.businessCode,
|
|
@@ -1695,10 +1722,16 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1695
1722
|
decideAddProduct: (item, options) => this.decideAddProduct(item, options),
|
|
1696
1723
|
decideAfterDetail: (cacheItem, options) => this.decideAfterDetail(cacheItem, options),
|
|
1697
1724
|
transformDetailToProductAndBooking: input => this.transformDetailToProductAndBooking(input),
|
|
1698
|
-
addProductToOrder: (product, booking) =>
|
|
1725
|
+
addProductToOrder: (product, booking) => {
|
|
1726
|
+
beforeScanCommit();
|
|
1727
|
+
return this.addProductToOrder(product, booking);
|
|
1728
|
+
},
|
|
1699
1729
|
refreshWalletAssets: params => this.refreshWalletAssets(params),
|
|
1700
|
-
scanWalletAsset: scanCode =>
|
|
1701
|
-
|
|
1730
|
+
scanWalletAsset: scanCode => {
|
|
1731
|
+
beforeScanCommit();
|
|
1732
|
+
return this.scanWalletAsset(scanCode);
|
|
1733
|
+
}
|
|
1734
|
+
}, formatted, guardedBridge);
|
|
1702
1735
|
bridge?.refresh?.();
|
|
1703
1736
|
return result;
|
|
1704
1737
|
} catch (error) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type BusinessAvailability } from '../../modules/BusinessAvailability';
|
|
2
|
+
import type { ScheduleModule } from '../../modules/Schedule';
|
|
3
|
+
interface BusinessAvailabilityHost {
|
|
4
|
+
loadOpenData: () => Promise<Record<string, unknown> | null>;
|
|
5
|
+
getSchedule: () => ScheduleModule | undefined;
|
|
6
|
+
getTimezone: () => string;
|
|
7
|
+
getScope: () => string;
|
|
8
|
+
now?: () => Date;
|
|
9
|
+
}
|
|
10
|
+
/** Read successful configuration once per business runtime; evaluate the clock on demand. */
|
|
11
|
+
export declare class BusinessAvailabilityController {
|
|
12
|
+
private readonly host;
|
|
13
|
+
private runtime?;
|
|
14
|
+
constructor(host: BusinessAvailabilityHost);
|
|
15
|
+
invalidate(): void;
|
|
16
|
+
private now;
|
|
17
|
+
private getRuntime;
|
|
18
|
+
private assertCurrent;
|
|
19
|
+
private loadConfig;
|
|
20
|
+
private loadSchedules;
|
|
21
|
+
private error;
|
|
22
|
+
/** Synchronous final cart-commit check; deliberately never starts a load. */
|
|
23
|
+
getCachedAvailability(): BusinessAvailability;
|
|
24
|
+
getAvailability(): Promise<BusinessAvailability>;
|
|
25
|
+
assertAvailable(): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BusinessAvailabilityController = void 0;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
var _BusinessAvailability = require("../../modules/BusinessAvailability");
|
|
9
|
+
async function withTimeout(request) {
|
|
10
|
+
let timer;
|
|
11
|
+
try {
|
|
12
|
+
return await Promise.race([request, new Promise((_, reject) => {
|
|
13
|
+
timer = setTimeout(() => reject(new Error('Unable to load business settings. Please try again.')), 30_000);
|
|
14
|
+
})]);
|
|
15
|
+
} finally {
|
|
16
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Read successful configuration once per business runtime; evaluate the clock on demand. */
|
|
21
|
+
class BusinessAvailabilityController {
|
|
22
|
+
runtime;
|
|
23
|
+
constructor(host) {
|
|
24
|
+
this.host = host;
|
|
25
|
+
}
|
|
26
|
+
invalidate() {
|
|
27
|
+
this.runtime = undefined;
|
|
28
|
+
}
|
|
29
|
+
now() {
|
|
30
|
+
return this.host.now?.() ?? new Date();
|
|
31
|
+
}
|
|
32
|
+
getRuntime() {
|
|
33
|
+
const scope = this.host.getScope();
|
|
34
|
+
if (this.runtime?.scope !== scope) this.runtime = {
|
|
35
|
+
scope
|
|
36
|
+
};
|
|
37
|
+
return this.runtime;
|
|
38
|
+
}
|
|
39
|
+
assertCurrent(runtime) {
|
|
40
|
+
if (this.runtime !== runtime || runtime.scope !== this.host.getScope()) {
|
|
41
|
+
throw new Error('Store settings changed. Please try again.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async loadConfig(runtime) {
|
|
45
|
+
if (runtime.config) return runtime.config;
|
|
46
|
+
if (!runtime.configRequest) {
|
|
47
|
+
runtime.configRequest = (async () => {
|
|
48
|
+
const data = await withTimeout(this.host.loadOpenData());
|
|
49
|
+
this.assertCurrent(runtime);
|
|
50
|
+
if (!data) throw new Error('Business settings are unavailable. Please try again.');
|
|
51
|
+
const config = (0, _lodashEs.cloneDeep)((0, _BusinessAvailability.normalizeBusinessAvailabilityConfig)(data));
|
|
52
|
+
runtime.config = config;
|
|
53
|
+
return config;
|
|
54
|
+
})();
|
|
55
|
+
}
|
|
56
|
+
const request = runtime.configRequest;
|
|
57
|
+
try {
|
|
58
|
+
return await request;
|
|
59
|
+
} finally {
|
|
60
|
+
if (runtime.configRequest === request) runtime.configRequest = undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async loadSchedules(runtime) {
|
|
64
|
+
if (runtime.schedules) return runtime.schedules;
|
|
65
|
+
if (!runtime.scheduleRequest) {
|
|
66
|
+
runtime.scheduleRequest = (async () => {
|
|
67
|
+
const schedule = this.host.getSchedule();
|
|
68
|
+
if (!schedule) throw new Error('Business operating-hours schedule is unavailable. Please try again.');
|
|
69
|
+
await withTimeout(schedule.loadAllSchedule({
|
|
70
|
+
useCache: true
|
|
71
|
+
}));
|
|
72
|
+
this.assertCurrent(runtime);
|
|
73
|
+
const schedules = (0, _lodashEs.cloneDeep)(schedule.getScheduleListByIds(runtime.config.scheduleIds) || []);
|
|
74
|
+
runtime.schedules = schedules;
|
|
75
|
+
return schedules;
|
|
76
|
+
})();
|
|
77
|
+
}
|
|
78
|
+
const request = runtime.scheduleRequest;
|
|
79
|
+
try {
|
|
80
|
+
return await request;
|
|
81
|
+
} finally {
|
|
82
|
+
if (runtime.scheduleRequest === request) runtime.scheduleRequest = undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
error(reason, runtime) {
|
|
86
|
+
return {
|
|
87
|
+
status: 'error',
|
|
88
|
+
behavior: 'hide_all',
|
|
89
|
+
message: null,
|
|
90
|
+
nextChangeAt: this.now().getTime() + 60_000,
|
|
91
|
+
requirePaymentOnSubmit: runtime?.config?.requirePaymentOnSubmit ?? true,
|
|
92
|
+
error: reason instanceof Error ? reason.message : 'Business settings are unavailable. Please try again.'
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Synchronous final cart-commit check; deliberately never starts a load. */
|
|
97
|
+
getCachedAvailability() {
|
|
98
|
+
const runtime = this.getRuntime();
|
|
99
|
+
try {
|
|
100
|
+
this.assertCurrent(runtime);
|
|
101
|
+
if (!runtime.config) throw new Error('Business settings are still loading. Please try again.');
|
|
102
|
+
return (0, _BusinessAvailability.computeBusinessAvailability)({
|
|
103
|
+
config: runtime.config,
|
|
104
|
+
schedules: runtime.schedules || [],
|
|
105
|
+
timezone: this.host.getTimezone(),
|
|
106
|
+
now: this.now()
|
|
107
|
+
});
|
|
108
|
+
} catch (reason) {
|
|
109
|
+
return this.error(reason, runtime);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async getAvailability() {
|
|
113
|
+
const runtime = this.getRuntime();
|
|
114
|
+
try {
|
|
115
|
+
const config = await this.loadConfig(runtime);
|
|
116
|
+
this.assertCurrent(runtime);
|
|
117
|
+
if (!config.paused && !config.invalidScheduleIds && config.scheduleIds.length) {
|
|
118
|
+
await this.loadSchedules(runtime);
|
|
119
|
+
}
|
|
120
|
+
this.assertCurrent(runtime);
|
|
121
|
+
return this.getCachedAvailability();
|
|
122
|
+
} catch (reason) {
|
|
123
|
+
return this.error(reason, runtime);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
assertAvailable() {
|
|
127
|
+
const availability = this.getCachedAvailability();
|
|
128
|
+
if (availability.status !== 'open') {
|
|
129
|
+
const error = new Error(availability.error || (availability.status === 'paused' ? 'Ordering is temporarily paused.' : 'Ordering is currently closed.'));
|
|
130
|
+
Object.assign(error, {
|
|
131
|
+
code: 'BUSINESS_UNAVAILABLE',
|
|
132
|
+
businessAvailability: availability
|
|
133
|
+
});
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.BusinessAvailabilityController = BusinessAvailabilityController;
|