@pisell/pisellos 0.10.90 → 0.10.93
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 +75 -52
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/index.d.ts +1 -1
- 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 +20 -4
- 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 +10 -0
- package/dist/solution/BookingTicket/index.js +686 -598
- 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 +8 -8
- 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 +29 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/index.d.ts +1 -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 +20 -4
- 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 +10 -0
- package/lib/solution/BookingTicket/index.js +57 -6
- 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 +8 -8
- 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
|
@@ -44,6 +44,7 @@ var _utils = require("../../modules/Order/utils");
|
|
|
44
44
|
var _contactInfo = require("../../modules/OpenData/contactInfo");
|
|
45
45
|
var _platform = require("../../utils/platform");
|
|
46
46
|
var _lodashEs = require("lodash-es");
|
|
47
|
+
var _types2 = require("../../server/modules/form/types");
|
|
47
48
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
48
49
|
const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents'];
|
|
49
50
|
const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
@@ -185,6 +186,16 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
185
186
|
return !channel || channel === 'system' ? 'pos' : channel;
|
|
186
187
|
}
|
|
187
188
|
|
|
189
|
+
/** 供销售展示层按 booking.resources[].form_id 读取当前多语言表单标题。 */
|
|
190
|
+
getFormTitleMap() {
|
|
191
|
+
return this.core?.server?.form?.getTitleMap?.() || {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** 表单定义由 Ably 更新后通知展示层刷新,不改动订单里的历史 metadata。 */
|
|
195
|
+
onFormTitlesChanged(callback) {
|
|
196
|
+
return this.core.effects.on(_types2.FormHooks.onChanged, callback);
|
|
197
|
+
}
|
|
198
|
+
|
|
188
199
|
/**
|
|
189
200
|
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
190
201
|
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
@@ -298,6 +309,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
298
309
|
async loadContactInfoOpenData() {
|
|
299
310
|
return this.store.openData ? this.getOpenData() : super.loadContactInfoOpenData();
|
|
300
311
|
}
|
|
312
|
+
async loadFulfillmentItemRuleOpenData() {
|
|
313
|
+
return this.store.openData ? this.getOpenData() : super.loadFulfillmentItemRuleOpenData();
|
|
314
|
+
}
|
|
301
315
|
async getInvoiceLayoutConfig() {
|
|
302
316
|
const openData = await this.loadOpenDataConfig();
|
|
303
317
|
if (!openData) return (0, _OpenData.getDefaultInvoiceLayoutConfig)();
|
|
@@ -374,9 +388,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
374
388
|
config: {
|
|
375
389
|
prefix,
|
|
376
390
|
deviceCode: deviceId,
|
|
377
|
-
|
|
378
|
-
padReceiptSequence: false,
|
|
391
|
+
padReceiptSequence: openDataConfig?.['sale.pad_with_leading_zeros'] === true,
|
|
379
392
|
receiptSequenceLength,
|
|
393
|
+
receiptSequenceMax: this.normalizeShortNumberMaximum(openDataConfig?.['sale.maximum_number']),
|
|
394
|
+
randomReceiptSequence: openDataConfig?.['sale.short_number_random'] === true,
|
|
380
395
|
resetReceiptSequenceDaily,
|
|
381
396
|
receiptSequenceResetTime: operatingDayBoundary?.time,
|
|
382
397
|
receiptSequenceStart,
|
|
@@ -392,6 +407,17 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
392
407
|
if (!Number.isInteger(numeric) || numeric <= 0) return fallback;
|
|
393
408
|
return numeric;
|
|
394
409
|
}
|
|
410
|
+
normalizeShortNumberMaximum(value) {
|
|
411
|
+
if (value === undefined || value === null || typeof value === 'string' && !value.trim()) return null;
|
|
412
|
+
if (typeof value !== 'number' && typeof value !== 'string') {
|
|
413
|
+
throw new Error('sale.maximum_number 必须是安全正整数或空值');
|
|
414
|
+
}
|
|
415
|
+
const numeric = Number(value);
|
|
416
|
+
if (!Number.isSafeInteger(numeric) || numeric <= 0) {
|
|
417
|
+
throw new Error('sale.maximum_number 必须是安全正整数或空值');
|
|
418
|
+
}
|
|
419
|
+
return numeric;
|
|
420
|
+
}
|
|
395
421
|
normalizeIdPrefix(value, fallback) {
|
|
396
422
|
if (value === undefined || value === null) return fallback;
|
|
397
423
|
const normalized = String(value).trim().toUpperCase();
|
|
@@ -1597,7 +1623,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1597
1623
|
resourcesOriginMap: state.resourcesOriginMap,
|
|
1598
1624
|
date,
|
|
1599
1625
|
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1600
|
-
...(extra || {})
|
|
1626
|
+
...(extra || {}),
|
|
1627
|
+
orderSessionId: this.getOrderSessionId() ?? undefined,
|
|
1628
|
+
isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
|
|
1629
|
+
platform: String(this.otherParams?.platform || '').trim().toLowerCase()
|
|
1601
1630
|
};
|
|
1602
1631
|
}
|
|
1603
1632
|
|
|
@@ -1689,7 +1718,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1689
1718
|
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1690
1719
|
customerId: orderCustomerId,
|
|
1691
1720
|
...(extra || {}),
|
|
1692
|
-
channel: this.getSubmitOrderSalesChannel()
|
|
1721
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
1722
|
+
orderSessionId: this.getOrderSessionId() ?? undefined,
|
|
1723
|
+
isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
|
|
1724
|
+
platform: String(this.otherParams?.platform || '').trim().toLowerCase()
|
|
1693
1725
|
};
|
|
1694
1726
|
}
|
|
1695
1727
|
|
|
@@ -1874,11 +1906,12 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1874
1906
|
};
|
|
1875
1907
|
const result = guardedBridge?.scanScope === 'product-voucher-collection' ? await (0, _applyProductVoucherCollectionScan.applyProductVoucherCollectionScan)({
|
|
1876
1908
|
...host,
|
|
1877
|
-
waitForCustomerDiscounts: () => this.orderCustomerDiscountRefreshInFlight || Promise.resolve(),
|
|
1878
1909
|
loadCustomerDiscounts: async () => {
|
|
1910
|
+
beforeScanCommit();
|
|
1879
1911
|
const customerId = Number(this.getOrderCustomer()?.customer_id || 0);
|
|
1880
1912
|
if (customerId <= 1) return [];
|
|
1881
1913
|
await this.refreshDiscountConfigAfterOrderCustomerChange(customerId);
|
|
1914
|
+
beforeScanCommit();
|
|
1882
1915
|
return this.getDiscountList();
|
|
1883
1916
|
}
|
|
1884
1917
|
}, formatted, guardedBridge) : await (0, _applyGlobalScan.applyGlobalScan)(host, formatted, guardedBridge);
|
|
@@ -2083,6 +2116,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2083
2116
|
type: 'WRISTBAND',
|
|
2084
2117
|
data: {
|
|
2085
2118
|
order_id: this.getOrderIdentity()?.orderId,
|
|
2119
|
+
...(params.voucher_times && {
|
|
2120
|
+
voucher_times: params.voucher_times
|
|
2121
|
+
}),
|
|
2086
2122
|
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
2087
2123
|
}
|
|
2088
2124
|
},
|
|
@@ -2130,6 +2166,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2130
2166
|
const write = this.replaceTempOrder({
|
|
2131
2167
|
...tempOrder,
|
|
2132
2168
|
vouchers: nextVouchers
|
|
2169
|
+
}, {
|
|
2170
|
+
preserveOrderSessionId: this.getOrderSessionId() || undefined
|
|
2133
2171
|
});
|
|
2134
2172
|
this.redeemStatusWrite = write;
|
|
2135
2173
|
try {
|
|
@@ -2235,7 +2273,20 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2235
2273
|
reason: 'order_changed'
|
|
2236
2274
|
});
|
|
2237
2275
|
}
|
|
2238
|
-
|
|
2276
|
+
// 从本次 checkout 已接受的快照取票面时间,避免打印接口短暂返回旧值。
|
|
2277
|
+
const voucherTimes = {};
|
|
2278
|
+
arrival.vouchers.forEach((voucher, index) => {
|
|
2279
|
+
if (voucher !== order.vouchers[index] && voucher.voucher_id != null && voucher.start_time && voucher.end_time) {
|
|
2280
|
+
voucherTimes[String(voucher.voucher_id)] = {
|
|
2281
|
+
start_time: voucher.start_time,
|
|
2282
|
+
end_time: voucher.end_time
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2286
|
+
return Object.keys(voucherTimes).length ? {
|
|
2287
|
+
...checkout,
|
|
2288
|
+
voucher_times: voucherTimes
|
|
2289
|
+
} : checkout;
|
|
2239
2290
|
};
|
|
2240
2291
|
const completion = this.arrivalQueue.then(updateArrival).catch(error => {
|
|
2241
2292
|
log('failed', {
|
|
@@ -208,7 +208,7 @@ export interface AddAddTimeProductsToBookingInput {
|
|
|
208
208
|
}
|
|
209
209
|
/** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
|
|
210
210
|
export interface GlobalScanHostBridge {
|
|
211
|
-
/** product-voucher handles voucher codes
|
|
211
|
+
/** product-voucher handles voucher codes; product-voucher-collection loads all vouchers for the scanned customer. */
|
|
212
212
|
scanScope?: 'all' | 'product-voucher' | 'product-voucher-collection';
|
|
213
213
|
/** A one-shot entry may outlive its page while requests are in flight. */
|
|
214
214
|
isCurrent?: () => boolean;
|
|
@@ -41,6 +41,8 @@ export declare function decideAfterDetail(cacheItem: any, ctx?: AddProductDecide
|
|
|
41
41
|
* @deprecated 请用 `decideAddProduct`;保留兼容:autoClose=true 仅表示可直接加车(action=add)。
|
|
42
42
|
*/
|
|
43
43
|
export interface AddProductRequiresDetailPayload {
|
|
44
|
+
/** Same prepared decision cache supplied to the Host; never a separate Flow preflight. */
|
|
45
|
+
preparedCacheItem?: any;
|
|
44
46
|
item: ProductData | Record<string, any>;
|
|
45
47
|
/** UI 需展示的子弹窗开关。 */
|
|
46
48
|
showConfig: {
|
|
@@ -65,7 +67,6 @@ export interface AddProductDecideContext extends BookingCalcContext {
|
|
|
65
67
|
type?: 'select' | 'detail';
|
|
66
68
|
quantity?: number;
|
|
67
69
|
customerId?: number | string;
|
|
68
|
-
channel?: string;
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* 统一补齐预约商品的运行态字段。
|
|
@@ -15,6 +15,7 @@ exports.prepareBookingCacheItem = prepareBookingCacheItem;
|
|
|
15
15
|
exports.transformDetailToProductAndBooking = transformDetailToProductAndBooking;
|
|
16
16
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
17
17
|
var _BookingContext = require("../../../modules/BookingContext");
|
|
18
|
+
var _resolveUniqueCartDetail = require("./resolveUniqueCartDetail");
|
|
18
19
|
var _transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
|
|
19
20
|
var _weighingProductSku = require("./weighingProductSku");
|
|
20
21
|
var _platform = require("../../../utils/platform");
|
|
@@ -43,6 +44,7 @@ function needsSpecDetailModal(item) {
|
|
|
43
44
|
* 第二段:预约商品是否仍需打开资源 / 时间编辑(自助终端强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
|
|
44
45
|
*/
|
|
45
46
|
function needsBookingEdit(cacheItem, ctx) {
|
|
47
|
+
if ((0, _BookingContext.getCalendarBookingRange)(cacheItem, ctx)) return (0, _BookingContext.calendarBookingNeedsInput)(cacheItem);
|
|
46
48
|
if (isNormalBookingProduct(cacheItem)) return false;
|
|
47
49
|
if ((0, _platform.isSelfServicePlatform)(ctx?.channel)) return true;
|
|
48
50
|
const isAutoAllocationOn = ctx?.isAutoAllocationOn || (() => true);
|
|
@@ -61,13 +63,26 @@ function buildRequiresBookingEditPayload(cacheItem, ctx) {
|
|
|
61
63
|
*/
|
|
62
64
|
function decideAddProduct(item, ctx) {
|
|
63
65
|
const derivedCtx = withDerivedBookingCtx(ctx);
|
|
64
|
-
|
|
66
|
+
const calendarRange = (0, _BookingContext.getCalendarBookingRange)(item, derivedCtx);
|
|
67
|
+
const uniqueValue = calendarRange ? (0, _resolveUniqueCartDetail.resolveUniqueCartDetailValue)(item) : null;
|
|
68
|
+
const selectedItem = uniqueValue ? {
|
|
69
|
+
...item,
|
|
70
|
+
cartDetailValue: uniqueValue,
|
|
71
|
+
isOpenDetailModal: false
|
|
72
|
+
} : item;
|
|
73
|
+
if (needsSpecDetailModal(selectedItem)) {
|
|
74
|
+
const preparedCacheItem = calendarRange ? prepareBookingCacheItem(buildCacheItemFromCartDetail(item, derivedCtx), derivedCtx) : undefined;
|
|
65
75
|
return {
|
|
66
76
|
action: 'requiresDetail',
|
|
67
|
-
payload:
|
|
77
|
+
payload: {
|
|
78
|
+
...buildRequiresDetailPayload(item, derivedCtx),
|
|
79
|
+
...(preparedCacheItem ? {
|
|
80
|
+
preparedCacheItem
|
|
81
|
+
} : {})
|
|
82
|
+
}
|
|
68
83
|
};
|
|
69
84
|
}
|
|
70
|
-
const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(
|
|
85
|
+
const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(selectedItem, derivedCtx), derivedCtx);
|
|
71
86
|
if (needsBookingEdit(cacheItem, derivedCtx)) {
|
|
72
87
|
return {
|
|
73
88
|
action: 'requiresBookingEdit',
|
|
@@ -147,7 +162,22 @@ function isMultiDayLike(cacheItem) {
|
|
|
147
162
|
* `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
|
|
148
163
|
*/
|
|
149
164
|
function prepareBookingCacheItem(cacheItem, ctx) {
|
|
150
|
-
if (
|
|
165
|
+
if ((0, _BookingContext.getCalendarBookingRange)(cacheItem, ctx)) {
|
|
166
|
+
if (cacheItem._data?.calendarBookingPreparationKey === (0, _BookingContext.calendarBookingPreparationKey)(cacheItem, ctx)) return cacheItem;
|
|
167
|
+
return (0, _BookingContext.getProductExtend)({
|
|
168
|
+
cacheItem,
|
|
169
|
+
ctx: ctx,
|
|
170
|
+
isDisabledTime: true
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (ctx?.bookingTimeRangeFromCalendar && (cacheItem.duration?.type === 'days' || cacheItem.duration_type === 'days' || cacheItem._extend?.sub_type === 'days')) {
|
|
174
|
+
ctx = {
|
|
175
|
+
...ctx,
|
|
176
|
+
bookingTimeRangeFromCalendar: undefined,
|
|
177
|
+
resourceIdFromCalendar: undefined
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
if (ctx?.rememberedTime === undefined && (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem))) {
|
|
151
181
|
return cacheItem;
|
|
152
182
|
}
|
|
153
183
|
return (0, _BookingContext.getProductExtend)({
|
|
@@ -24,27 +24,28 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
24
24
|
products: import("../../../modules/Order/types").OrderSubmitProduct[];
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
|
+
status: string;
|
|
27
28
|
metadata: Record<string, any>;
|
|
29
|
+
business_code?: string | undefined;
|
|
30
|
+
customer_id: number | null;
|
|
28
31
|
type: string;
|
|
29
|
-
note: string;
|
|
30
32
|
holder: Record<string, any> | null;
|
|
33
|
+
email: string;
|
|
34
|
+
phone: string;
|
|
35
|
+
note: string;
|
|
31
36
|
relation_forms: any[];
|
|
32
37
|
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
38
|
+
country_calling_code: string;
|
|
39
|
+
contacts_info: Record<string, any> | null;
|
|
33
40
|
order_id: number | null;
|
|
34
41
|
external_sale_number: string;
|
|
35
42
|
order_number: string | null;
|
|
36
43
|
shop_order_number: string | null;
|
|
37
44
|
shop_full_order_number: string | null;
|
|
38
|
-
business_code?: string | undefined;
|
|
39
45
|
sales_channel: string;
|
|
40
46
|
order_sales_channel: string;
|
|
41
|
-
status: string;
|
|
42
47
|
shipping_status: string;
|
|
43
|
-
customer_id: number | null;
|
|
44
48
|
customer_name: string;
|
|
45
|
-
country_calling_code: string;
|
|
46
|
-
phone: string;
|
|
47
|
-
email: string;
|
|
48
49
|
is_price_include_tax: number;
|
|
49
50
|
tax_title: string;
|
|
50
51
|
tax_country_code: string;
|
|
@@ -61,7 +62,6 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
61
62
|
schedule_date: string;
|
|
62
63
|
bookings: any[];
|
|
63
64
|
payments: any[];
|
|
64
|
-
contacts_info: Record<string, any> | null;
|
|
65
65
|
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
66
66
|
refunds?: any[] | undefined;
|
|
67
67
|
surcharges: any[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type RecordValue = Record<string, any>;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a whole SKU only when the original configuration proves one legal
|
|
4
|
+
* result. A default, a stock-filtered remainder, or missing detail is not proof
|
|
5
|
+
* of uniqueness. The input product and its existing selections stay untouched.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveUniqueCartDetailValue(product: RecordValue): RecordValue | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveUniqueCartDetailValue = resolveUniqueCartDetailValue;
|
|
7
|
+
const flag = value => value === true || value === 1 || value === '1';
|
|
8
|
+
const cleared = value => value === false || value === 0 || value === '0';
|
|
9
|
+
const enabled = item => item && !flag(item.disabled) && !cleared(item.is_enabled) && item.deleted_at == null;
|
|
10
|
+
const sellable = item => enabled(item) && (!flag(item.is_track) || flag(item.over_sold) || Number(item.stock_quantity) > 0);
|
|
11
|
+
const bound = (value, fallback = 0) => {
|
|
12
|
+
if (value == null || value === '') return fallback;
|
|
13
|
+
if (typeof value !== 'number' && typeof value !== 'string') return null;
|
|
14
|
+
const number = Number(value);
|
|
15
|
+
return Number.isInteger(number) && number >= 0 ? number : null;
|
|
16
|
+
};
|
|
17
|
+
const validId = value => (typeof value === 'number' || typeof value === 'string') && Number.isSafeInteger(Number(value)) && Number(value) > 0;
|
|
18
|
+
|
|
19
|
+
/** A choice is unique only if its complete allowed quantity interval is one value. */
|
|
20
|
+
function fixedQuantity(minimums, maximums) {
|
|
21
|
+
const min = Math.max(1, ...minimums);
|
|
22
|
+
const max = Math.min(...maximums.filter(value => value > 0), Infinity);
|
|
23
|
+
return min === max ? min : null;
|
|
24
|
+
}
|
|
25
|
+
function configuredGroups(product, key, countKey) {
|
|
26
|
+
const groups = product[key];
|
|
27
|
+
if (groups == null && product[countKey] == null) return null;
|
|
28
|
+
const count = bound(product[countKey]);
|
|
29
|
+
if (count == null || groups != null && !Array.isArray(groups)) return null;
|
|
30
|
+
if (count > 0 && (!Array.isArray(groups) || groups.length !== count)) return null;
|
|
31
|
+
return groups || [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a whole SKU only when the original configuration proves one legal
|
|
36
|
+
* result. A default, a stock-filtered remainder, or missing detail is not proof
|
|
37
|
+
* of uniqueness. The input product and its existing selections stay untouched.
|
|
38
|
+
*/
|
|
39
|
+
function resolveUniqueCartDetailValue(product) {
|
|
40
|
+
if (!product || !validId(product.id ?? product.product_id) || flag(product.open_sold_weight)) return null;
|
|
41
|
+
const productId = product.id ?? product.product_id;
|
|
42
|
+
const existing = product.cartDetailValue;
|
|
43
|
+
const hasConfiguredSku = flag(product.is_variant) || Number(product.variant_count) > 0 || Number(product.option_group_count) > 0 || Number(product.bundle_group_count) > 0 || product.option_group?.length > 0 || product.bundle_group?.length > 0 || product.bundle_groups?.length > 0 || product.variant_group?.length > 0;
|
|
44
|
+
if (existing && !hasConfiguredSku && !(existing.option?.length || existing.bundle?.length)) {
|
|
45
|
+
return {
|
|
46
|
+
...existing,
|
|
47
|
+
product_id: productId,
|
|
48
|
+
quantity: 1
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const knowsVariantShape = cleared(product.is_variant) || product.variant_count === 0 || product.variant_count === '0' || Array.isArray(product.variant) || Array.isArray(product.variant_group);
|
|
52
|
+
if (!knowsVariantShape) return null;
|
|
53
|
+
const optionGroups = configuredGroups(product, 'option_group', 'option_group_count');
|
|
54
|
+
const bundleKey = product.bundle_group != null ? 'bundle_group' : 'bundle_groups';
|
|
55
|
+
const bundleGroups = configuredGroups(product, bundleKey, 'bundle_group_count');
|
|
56
|
+
if (!optionGroups || !bundleGroups) return null;
|
|
57
|
+
const value = {
|
|
58
|
+
...(product.cartDetailValue || {}),
|
|
59
|
+
product_id: productId,
|
|
60
|
+
product_variant_id: 0,
|
|
61
|
+
option: [],
|
|
62
|
+
bundle: [],
|
|
63
|
+
quantity: 1
|
|
64
|
+
};
|
|
65
|
+
const hasVariant = flag(product.is_variant) || Number(product.variant_count) > 0 || Array.isArray(product.variant_group) && product.variant_group.length > 0 || Array.isArray(product.variant) && product.variant.length > 0;
|
|
66
|
+
if (hasVariant) {
|
|
67
|
+
if (!Array.isArray(product.variant) || product.variant.length !== 1 || Number(product.variant_count) > 0 && Number(product.variant_count) !== 1) return null;
|
|
68
|
+
const [variant] = product.variant;
|
|
69
|
+
if (!validId(variant?.id) || !sellable(variant)) return null;
|
|
70
|
+
value.product_variant_id = variant.id;
|
|
71
|
+
if (variant.price == null || variant.price === '' || !Number.isFinite(Number(variant.price)) || Number(variant.price) < 0) return null;
|
|
72
|
+
value.price = variant.price;
|
|
73
|
+
value.production_code = variant.production_code ?? variant.code ?? '';
|
|
74
|
+
}
|
|
75
|
+
for (const group of optionGroups) {
|
|
76
|
+
// Do not silently remove configured alternatives that are disabled or out of stock.
|
|
77
|
+
if (!validId(group?.id) || !enabled(group) || !Array.isArray(group.option_item) || group.option_item.length !== 1) return null;
|
|
78
|
+
const [item] = group.option_item;
|
|
79
|
+
if (!validId(item?.id) || !sellable(item)) return null;
|
|
80
|
+
const multiple = flag(group.is_multiple);
|
|
81
|
+
const groupMin = bound(group.min_quantity);
|
|
82
|
+
const groupMax = bound(group.max_quantity);
|
|
83
|
+
const itemMin = bound(item.min_quantity);
|
|
84
|
+
const itemMax = bound(item.max_quantity, 1);
|
|
85
|
+
if ([groupMin, groupMax, itemMin, itemMax].some(value => value == null)) return null;
|
|
86
|
+
const advanced = multiple && flag(group.metadata?.advanced_settings_enabled);
|
|
87
|
+
const minTypes = advanced ? bound(group.metadata?.option_types_config?.min) : 0;
|
|
88
|
+
const maxTypes = advanced ? bound(group.metadata?.option_types_config?.max) : 0;
|
|
89
|
+
if (minTypes == null || maxTypes == null || minTypes > 1 || maxTypes > 0 && maxTypes < minTypes) return null;
|
|
90
|
+
const required = multiple ? groupMin > 0 || minTypes > 0 : flag(group.required);
|
|
91
|
+
if (!required) return null;
|
|
92
|
+
const quantity = fixedQuantity([itemMin, ...(multiple ? [groupMin] : [])], [itemMax, ...(multiple ? [groupMax] : [])]);
|
|
93
|
+
if (!quantity) return null;
|
|
94
|
+
const price = item.price ?? item.add_price ?? 0;
|
|
95
|
+
value.option.push({
|
|
96
|
+
...item,
|
|
97
|
+
id: item.id,
|
|
98
|
+
product_option_item_id: item.id,
|
|
99
|
+
option_group_item_id: item.id,
|
|
100
|
+
option_group_id: group.id,
|
|
101
|
+
product_id: productId,
|
|
102
|
+
quantity,
|
|
103
|
+
num: quantity,
|
|
104
|
+
price,
|
|
105
|
+
original_price: price
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
for (const group of bundleGroups) {
|
|
109
|
+
if (!validId(group?.id) || !enabled(group) || !Array.isArray(group.bundle_item) || group.bundle_item.length !== 1) return null;
|
|
110
|
+
const [item] = group.bundle_item;
|
|
111
|
+
if (!validId(item?.id) || !validId(item?.bundle_product_id) || !sellable(item) || item.option_group?.length || item.variant_group?.length || item.variant?.length || item.bundle_group?.length || item.bundle_groups?.length || flag(item.is_variant) || flag(item.open_sold_weight) || Number(item.variant_count) > 0 || Number(item.option_group_count) > 0 || Number(item.bundle_group_count) > 0) return null;
|
|
112
|
+
const groupMin = bound(group.min_quantity);
|
|
113
|
+
const groupMax = bound(group.max_quantity);
|
|
114
|
+
const itemMin = bound(item.min_quantity);
|
|
115
|
+
const itemMax = bound(item.max_quantity);
|
|
116
|
+
if ([groupMin, groupMax, itemMin, itemMax].some(value => value == null) || groupMin <= 0) return null;
|
|
117
|
+
const quantity = fixedQuantity([groupMin, itemMin], [groupMax, itemMax]);
|
|
118
|
+
if (!quantity) return null;
|
|
119
|
+
value.bundle.push({
|
|
120
|
+
...item,
|
|
121
|
+
id: item.id,
|
|
122
|
+
group_id: group.id,
|
|
123
|
+
bundle_group_id: group.id,
|
|
124
|
+
_bundle_product_id: item.bundle_product_id,
|
|
125
|
+
quantity,
|
|
126
|
+
num: quantity,
|
|
127
|
+
option: []
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const key = [productId, value.product_variant_id, ...value.option.map(item => `o${item.option_group_id}:${item.id}:${item.quantity}`), ...value.bundle.map(item => `b${item.group_id}:${item.id}:${item.quantity}`), ...(value.session ? [`s${value.session.key ?? value.session.id ?? ''}`] : [])].join('_');
|
|
131
|
+
return {
|
|
132
|
+
...value,
|
|
133
|
+
key,
|
|
134
|
+
rowKey: key
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -289,18 +289,6 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
289
289
|
// batch-search 可能返回来源门店客户;先映射到当前门店,确保 Wallet
|
|
290
290
|
// 支付资产查询使用本店客户上下文。
|
|
291
291
|
const bindResult = await bindWalletPassCustomer();
|
|
292
|
-
// Voucher collection prioritizes goods coupons resolved from the wristband/order.
|
|
293
|
-
// Only this opt-in flow checks them before selecting a payment wallet asset.
|
|
294
|
-
const collectionPromotion = bridge?.scanScope === 'product-voucher-collection' && bridge.applyPromotionCode ? await bridge.applyPromotionCode(scanCode, getRealCustomerId(activeCustomer), {
|
|
295
|
-
suppressFailureNotification: true,
|
|
296
|
-
productVouchersOnly: true
|
|
297
|
-
}) : undefined;
|
|
298
|
-
if (collectionPromotion?.isAccepted ?? collectionPromotion?.isAvailable) {
|
|
299
|
-
return {
|
|
300
|
-
status: 'success',
|
|
301
|
-
kind: 'promotion'
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
292
|
const walletSelection = await trySelectWalletAsset();
|
|
305
293
|
if (walletSelection) return walletSelection;
|
|
306
294
|
if (!bridge?.applyPromotionCode) {
|
|
@@ -310,9 +298,9 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
310
298
|
};
|
|
311
299
|
}
|
|
312
300
|
const promotionCustomerId = getRealCustomerId(activeCustomer);
|
|
313
|
-
const promotionResult =
|
|
301
|
+
const promotionResult = bindResult.customerBound ? await bridge.applyPromotionCode(scanCode, promotionCustomerId, {
|
|
314
302
|
suppressFailureNotification: true
|
|
315
|
-
}) : await bridge.applyPromotionCode(scanCode, promotionCustomerId)
|
|
303
|
+
}) : await bridge.applyPromotionCode(scanCode, promotionCustomerId);
|
|
316
304
|
if (promotionResult?.isAccepted ?? promotionResult?.isAvailable) {
|
|
317
305
|
return {
|
|
318
306
|
status: 'success',
|
|
@@ -2,9 +2,7 @@ import type { GlobalScanHandleResult, GlobalScanHostBridge } from '../../types';
|
|
|
2
2
|
import { type GlobalScanApplyHost } from './applyGlobalScan';
|
|
3
3
|
import type { GlobalScanFormattedResult } from './formatGlobalScan';
|
|
4
4
|
export interface ProductVoucherCollectionScanHost extends GlobalScanApplyHost {
|
|
5
|
-
waitForCustomerDiscounts(): Promise<void>;
|
|
6
5
|
loadCustomerDiscounts(): Promise<Record<string, any>[]>;
|
|
7
6
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Never expand a wristband's result to other orders of the same customer. */
|
|
7
|
+
/** Resolve the scanned account, then collect all of that customer's vouchers. */
|
|
10
8
|
export declare function applyProductVoucherCollectionScan(host: ProductVoucherCollectionScanHost, formatted: GlobalScanFormattedResult, bridge: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
|
|
@@ -5,15 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.applyProductVoucherCollectionScan = applyProductVoucherCollectionScan;
|
|
7
7
|
var _applyGlobalScan = require("./applyGlobalScan");
|
|
8
|
-
/**
|
|
9
|
-
* Never expand a wristband's result to other orders of the same customer. */
|
|
8
|
+
/** Resolve the scanned account, then collect all of that customer's vouchers. */
|
|
10
9
|
async function applyProductVoucherCollectionScan(host, formatted, bridge) {
|
|
11
10
|
const assertCurrent = () => {
|
|
12
11
|
if (bridge.isCurrent?.() === false) {
|
|
13
12
|
throw new DOMException('Scan session ended', 'AbortError');
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
|
-
|
|
15
|
+
const isPass = formatted.searchType === 'walletPass';
|
|
16
|
+
// Order numbers and wristbands resolve through batch-search. Their returned
|
|
17
|
+
// passes identify the customer; they are not the collection's voucher list.
|
|
18
|
+
// Resolve source-shop IDs before reusing the wallet customer-binding flow.
|
|
19
|
+
const customerScan = isPass ? {
|
|
20
|
+
...formatted,
|
|
21
|
+
searchType: 'wallet',
|
|
22
|
+
customerId: formatted.customerId ?? formatted.data?.id ?? formatted.data?.customer_id,
|
|
23
|
+
isCrossShopWallet: true
|
|
24
|
+
} : formatted;
|
|
17
25
|
assertCurrent();
|
|
18
26
|
const result = await (0, _applyGlobalScan.applyGlobalScan)({
|
|
19
27
|
...host,
|
|
@@ -25,44 +33,19 @@ async function applyProductVoucherCollectionScan(host, formatted, bridge) {
|
|
|
25
33
|
assertCurrent();
|
|
26
34
|
return host.addProductToOrder(product, booking);
|
|
27
35
|
}
|
|
28
|
-
},
|
|
36
|
+
}, customerScan, {
|
|
29
37
|
...bridge,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// before adding scanned coupons so its response cannot overwrite them.
|
|
33
|
-
await host.waitForCustomerDiscounts();
|
|
34
|
-
assertCurrent();
|
|
35
|
-
const promotion = await bridge.applyPromotionCode(code, customerId, {
|
|
36
|
-
...options,
|
|
37
|
-
productVouchersOnly: true,
|
|
38
|
-
suppressFailureNotification: true
|
|
39
|
-
});
|
|
40
|
-
assertCurrent();
|
|
41
|
-
// An empty successful search is different from a swallowed request error.
|
|
42
|
-
if (!Array.isArray(promotion.scannedDiscountList)) {
|
|
43
|
-
throw new Error('Could not resolve scanned vouchers');
|
|
44
|
-
}
|
|
45
|
-
vouchers = promotion.scannedDiscountList;
|
|
46
|
-
return promotion;
|
|
47
|
-
})
|
|
38
|
+
// Without a switch bridge, do not return the previous customer's vouchers.
|
|
39
|
+
requestCustomerSwitch: bridge.requestCustomerSwitch ?? (async () => false)
|
|
48
40
|
});
|
|
49
41
|
assertCurrent();
|
|
50
|
-
if (
|
|
51
|
-
vouchers = await host.loadCustomerDiscounts();
|
|
42
|
+
if (customerScan.searchType === 'wallet' && result.status === 'success') {
|
|
43
|
+
const vouchers = await host.loadCustomerDiscounts();
|
|
52
44
|
assertCurrent();
|
|
53
45
|
return {
|
|
54
46
|
...result,
|
|
55
47
|
redemption: {
|
|
56
|
-
source: 'wallet',
|
|
57
|
-
vouchers
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (formatted.searchType === 'walletPass') {
|
|
62
|
-
return {
|
|
63
|
-
...result,
|
|
64
|
-
redemption: {
|
|
65
|
-
source: 'scan',
|
|
48
|
+
source: isPass ? 'scan' : 'wallet',
|
|
66
49
|
vouchers
|
|
67
50
|
}
|
|
68
51
|
};
|
|
@@ -146,6 +146,7 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
146
146
|
} : {})
|
|
147
147
|
};
|
|
148
148
|
shop.default_domain || (shop.default_domain = shopCore.default_domain);
|
|
149
|
+
shop.private_domain || (shop.private_domain = shopCore.private_domain);
|
|
149
150
|
shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
|
|
150
151
|
if (generation !== this.generation || this.disposed) throw new Error('Invoice request superseded');
|
|
151
152
|
const languageOptions = (0, _customerInvoiceLanguages.resolveCustomerInvoiceLanguages)(template.language, input.locale);
|
|
@@ -274,7 +274,7 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
274
274
|
} : {
|
|
275
275
|
external_sale_number: normalizedLookup
|
|
276
276
|
};
|
|
277
|
-
return this.request.post('/local/print-order', {
|
|
277
|
+
return this.request.post('/shop/local/print-order', {
|
|
278
278
|
...lookupPayload,
|
|
279
279
|
lookup_order_from_db: 1,
|
|
280
280
|
small_ticket_data_flag: 1,
|
|
@@ -100,6 +100,8 @@ export declare class ScanOrderImpl extends BaseSalesImpl implements Module {
|
|
|
100
100
|
private buildSubmitPayloadEnhancer;
|
|
101
101
|
private isScanOrderMoreMode;
|
|
102
102
|
private submitScanOrderMore;
|
|
103
|
+
/** Read both current and legacy cart snapshots without changing the product catalog. */
|
|
104
|
+
private getMenuAvailabilityProductSources;
|
|
103
105
|
submitScanOrder<T = any>(): Promise<T>;
|
|
104
106
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
105
107
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|