@pisell/pisellos 2.2.322 → 2.2.324
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 +1 -0
- package/dist/index.js +1 -0
- package/dist/inventory/index.d.ts +92 -0
- package/dist/inventory/index.js +509 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- 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 +20 -1
- package/dist/modules/BookingContext/utils/productExtend.js +122 -29
- 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/Discount/index.js +1 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/salesSettings.d.ts +32 -0
- package/dist/modules/OpenData/salesSettings.js +80 -0
- package/dist/modules/OpenData/types.d.ts +16 -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 +54 -11
- package/dist/modules/Order/index.js +2699 -1411
- package/dist/modules/Order/types.d.ts +43 -5
- package/dist/modules/Order/types.js +4 -0
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
- package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +18 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +5 -0
- package/dist/modules/ProductList/clientDataVariants.js +6 -2
- package/dist/modules/ProductList/index.d.ts +2 -0
- package/dist/modules/ProductList/index.js +161 -51
- package/dist/modules/ResourcePlanner/planner.js +58 -2
- package/dist/modules/ResourcePlanner/types.d.ts +13 -0
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +58 -39
- 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 +5 -0
- package/dist/server/index.js +1312 -1154
- package/dist/server/modules/order/index.js +2 -1
- 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 +4 -0
- package/dist/shared/receipt/small-ticket.js +70 -12
- package/dist/solution/BaseSales/index.d.ts +40 -5
- package/dist/solution/BaseSales/index.js +1939 -1484
- 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 +16 -2
- package/dist/solution/BookingByStep/index.js +676 -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 +2 -2
- package/dist/solution/BookingTicket/index.js +249 -135
- package/dist/solution/BookingTicket/types.d.ts +14 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +39 -11
- 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/applyProductVoucherCollectionScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/dist/solution/OrderInvoicePreview/index.js +14 -8
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +166 -67
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/dist/solution/UnifiedBookingSales/index.js +3391 -1176
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/dist/solution/UnifiedBookingSales/types.js +7 -1
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +283 -0
- package/dist/utils/platform.d.ts +2 -0
- package/dist/utils/platform.js +6 -0
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/inventory/index.d.ts +92 -0
- package/lib/inventory/index.js +287 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- 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 +20 -1
- package/lib/modules/BookingContext/utils/productExtend.js +96 -7
- 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/Discount/index.js +1 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/salesSettings.d.ts +32 -0
- package/lib/modules/OpenData/salesSettings.js +70 -0
- package/lib/modules/OpenData/types.d.ts +16 -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 +54 -11
- package/lib/modules/Order/index.js +659 -80
- package/lib/modules/Order/types.d.ts +43 -5
- package/lib/modules/Order/types.js +2 -0
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
- package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +19 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +5 -0
- package/lib/modules/ProductList/clientDataVariants.js +6 -2
- package/lib/modules/ProductList/index.d.ts +2 -0
- package/lib/modules/ProductList/index.js +74 -0
- package/lib/modules/ResourcePlanner/planner.js +52 -1
- package/lib/modules/ResourcePlanner/types.d.ts +13 -0
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +25 -9
- 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 +5 -0
- package/lib/server/index.js +124 -16
- package/lib/server/modules/order/index.js +2 -1
- 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 +4 -0
- package/lib/shared/receipt/small-ticket.js +63 -8
- package/lib/solution/BaseSales/index.d.ts +40 -5
- package/lib/solution/BaseSales/index.js +296 -43
- 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 +16 -2
- package/lib/solution/BookingByStep/index.js +222 -14
- 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 +2 -2
- package/lib/solution/BookingTicket/index.js +47 -4
- package/lib/solution/BookingTicket/types.d.ts +14 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +37 -6
- 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/applyProductVoucherCollectionScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/lib/solution/OrderInvoicePreview/index.js +7 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +72 -2
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/lib/solution/UnifiedBookingSales/index.js +1339 -74
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/lib/solution/UnifiedBookingSales/types.js +4 -1
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +155 -0
- package/lib/utils/platform.d.ts +2 -0
- package/lib/utils/platform.js +7 -0
- 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
|
@@ -7,7 +7,7 @@ exports.checkSessionProductLeadTime = checkSessionProductLeadTime;
|
|
|
7
7
|
exports.checkTwoResourcesIntersection = checkTwoResourcesIntersection;
|
|
8
8
|
exports.filterResourcesByFormItem = filterResourcesByFormItem;
|
|
9
9
|
exports.filterScheduleByDateRange = filterScheduleByDateRange;
|
|
10
|
-
exports.getResourcesByProduct = exports.getResourcesByIds = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
|
|
10
|
+
exports.getResourcesByProduct = exports.getResourcesByIds = exports.getPeakConcurrentPax = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
|
|
11
11
|
exports.getResourcesIdsByProduct = getResourcesIdsByProduct;
|
|
12
12
|
exports.mergeSubResourcesTimeSlices = exports.isConflict = exports.getTimesIntersection = exports.getTimeSlicesByResources = exports.getTimeSlicesByResource = void 0;
|
|
13
13
|
exports.sortCombinedResources = sortCombinedResources;
|
|
@@ -20,18 +20,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
/** 计算目标区间内的最大同时占用人数;事件去重由调用方负责。 */
|
|
24
|
+
const getPeakConcurrentPax = (eventList, timeSlice) => {
|
|
25
|
+
const start = (0, _dayjs.default)(timeSlice.start_at).valueOf();
|
|
26
|
+
const end = (0, _dayjs.default)(timeSlice.end_at).valueOf();
|
|
27
|
+
const changes = new Map();
|
|
28
|
+
for (const event of eventList || []) {
|
|
29
|
+
const eventStart = Math.max(start, (0, _dayjs.default)(event.start_at).valueOf());
|
|
30
|
+
const eventEnd = Math.min(end, (0, _dayjs.default)(event.end_at).valueOf());
|
|
31
|
+
if (!(eventStart < eventEnd)) continue;
|
|
32
|
+
const pax = Number(event.pax);
|
|
33
|
+
changes.set(eventStart, (changes.get(eventStart) ?? 0) + pax);
|
|
34
|
+
changes.set(eventEnd, (changes.get(eventEnd) ?? 0) - pax);
|
|
35
|
+
}
|
|
36
|
+
let current = 0;
|
|
37
|
+
let peak = 0;
|
|
38
|
+
// 同一时刻合并增减量,保持 [start, end) 语义,首尾相接不叠加。
|
|
39
|
+
for (const [, change] of [...changes].sort(([a], [b]) => a - b)) {
|
|
40
|
+
current += change;
|
|
41
|
+
peak = Math.max(peak, current);
|
|
42
|
+
}
|
|
43
|
+
return peak;
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
/**
|
|
@@ -42,6 +51,7 @@ const getUseableEventCount = (eventList, current) => {
|
|
|
42
51
|
* @return {*}
|
|
43
52
|
* @Author: zhiwei.Wang
|
|
44
53
|
*/
|
|
54
|
+
exports.getPeakConcurrentPax = getPeakConcurrentPax;
|
|
45
55
|
const isConflict = (event, current) => {
|
|
46
56
|
const eventStart = (0, _dayjs.default)(event.start_at);
|
|
47
57
|
const eventEnd = (0, _dayjs.default)(event.end_at);
|
|
@@ -132,8 +142,8 @@ const checkCapacity = ({
|
|
|
132
142
|
});
|
|
133
143
|
});
|
|
134
144
|
|
|
135
|
-
//
|
|
136
|
-
|
|
145
|
+
// 多人预约按同时占用峰值扣减,不能把先后到访的所有人数相加。
|
|
146
|
+
const conflictCount = resource.resourceType === 'single' ? conflict.reduce((remaining, event) => remaining - event.pax, resource.capacity || 0) : (resource.capacity || 0) - getPeakConcurrentPax(conflict, timeSlice);
|
|
137
147
|
|
|
138
148
|
// 同一时间段内只能进行一个预约,无论容量是否已满。
|
|
139
149
|
if (resource.resourceType === 'single') {
|
|
@@ -447,7 +447,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
447
447
|
/**
|
|
448
448
|
* 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
|
|
449
449
|
*/
|
|
450
|
-
|
|
450
|
+
protected buildBookingCalcContext(extra?: Partial<BookingCalcContext>): BookingCalcContext;
|
|
451
451
|
/**
|
|
452
452
|
* 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
|
|
453
453
|
* `extraResources` 用于把拖入未绑定的资源也展示出来。
|
|
@@ -480,7 +480,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
480
480
|
/**
|
|
481
481
|
* 拼装 addProductDecision 通用上下文(从 store 自取)。
|
|
482
482
|
*/
|
|
483
|
-
|
|
483
|
+
protected buildAddProductCtx(extra?: Partial<AddProductDecideContext>): AddProductDecideContext;
|
|
484
484
|
/**
|
|
485
485
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
486
486
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
@@ -30,6 +30,7 @@ var _handleScan = require("./utils/scan/handleScan");
|
|
|
30
30
|
var _scanCache = _interopRequireDefault(require("./utils/scan/scanCache"));
|
|
31
31
|
var _formatGlobalScan = require("./utils/scan/formatGlobalScan");
|
|
32
32
|
var _applyGlobalScan = require("./utils/scan/applyGlobalScan");
|
|
33
|
+
var _applyProductVoucherCollectionScan = require("./utils/scan/applyProductVoucherCollectionScan");
|
|
33
34
|
var _cartView = require("./utils/cartView");
|
|
34
35
|
var _addProductDecision = require("./utils/addProductDecision");
|
|
35
36
|
var _buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
|
|
@@ -1620,7 +1621,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1620
1621
|
resourcesOriginMap: state.resourcesOriginMap,
|
|
1621
1622
|
date,
|
|
1622
1623
|
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1623
|
-
...(extra || {})
|
|
1624
|
+
...(extra || {}),
|
|
1625
|
+
orderSessionId: this.getOrderSessionId() ?? undefined,
|
|
1626
|
+
isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
|
|
1627
|
+
platform: String(this.otherParams?.platform || '').trim().toLowerCase()
|
|
1624
1628
|
};
|
|
1625
1629
|
}
|
|
1626
1630
|
|
|
@@ -1712,7 +1716,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1712
1716
|
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1713
1717
|
customerId: orderCustomerId,
|
|
1714
1718
|
...(extra || {}),
|
|
1715
|
-
channel: this.getSubmitOrderSalesChannel()
|
|
1719
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
1720
|
+
orderSessionId: this.getOrderSessionId() ?? undefined,
|
|
1721
|
+
isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
|
|
1722
|
+
platform: String(this.otherParams?.platform || '').trim().toLowerCase()
|
|
1716
1723
|
};
|
|
1717
1724
|
}
|
|
1718
1725
|
|
|
@@ -1845,6 +1852,20 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1845
1852
|
return bridge.openBookingEdit(payload);
|
|
1846
1853
|
} : undefined
|
|
1847
1854
|
} : undefined;
|
|
1855
|
+
if (guardedBridge?.scanScope === 'product-voucher') {
|
|
1856
|
+
if (!guardedBridge.applyPromotionCode) return {
|
|
1857
|
+
status: 'failed',
|
|
1858
|
+
reason: 'no_bridge'
|
|
1859
|
+
};
|
|
1860
|
+
const promotion = await guardedBridge.applyPromotionCode(trimmed);
|
|
1861
|
+
return promotion.isAccepted ?? promotion.isAvailable ? {
|
|
1862
|
+
status: 'success',
|
|
1863
|
+
kind: 'promotion'
|
|
1864
|
+
} : {
|
|
1865
|
+
status: 'failed',
|
|
1866
|
+
reason: 'not_found'
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1848
1869
|
const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1849
1870
|
const scanCallback = (0, _handleScan.handleGlobalScan)(this.request, localSearch, this.getSubmitOrderSalesChannel());
|
|
1850
1871
|
const raw = await scanCallback({
|
|
@@ -1859,7 +1880,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1859
1880
|
reason: 'not_found'
|
|
1860
1881
|
};
|
|
1861
1882
|
}
|
|
1862
|
-
const
|
|
1883
|
+
const host = {
|
|
1863
1884
|
setOrderCustomer: customer => {
|
|
1864
1885
|
beforeScanCommit();
|
|
1865
1886
|
this.setOrderCustomer(customer);
|
|
@@ -1880,10 +1901,30 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1880
1901
|
beforeScanCommit();
|
|
1881
1902
|
return this.scanWalletAsset(scanCode);
|
|
1882
1903
|
}
|
|
1883
|
-
}
|
|
1904
|
+
};
|
|
1905
|
+
const result = guardedBridge?.scanScope === 'product-voucher-collection' ? await (0, _applyProductVoucherCollectionScan.applyProductVoucherCollectionScan)({
|
|
1906
|
+
...host,
|
|
1907
|
+
loadCustomerDiscounts: async () => {
|
|
1908
|
+
beforeScanCommit();
|
|
1909
|
+
const customerId = Number(this.getOrderCustomer()?.customer_id || 0);
|
|
1910
|
+
if (customerId <= 1) return [];
|
|
1911
|
+
await this.refreshDiscountConfigAfterOrderCustomerChange(customerId);
|
|
1912
|
+
beforeScanCommit();
|
|
1913
|
+
return this.getDiscountList();
|
|
1914
|
+
}
|
|
1915
|
+
}, formatted, guardedBridge) : await (0, _applyGlobalScan.applyGlobalScan)(host, formatted, guardedBridge);
|
|
1884
1916
|
bridge?.refresh?.();
|
|
1885
1917
|
return result;
|
|
1886
1918
|
} catch (error) {
|
|
1919
|
+
if (bridge?.scanScope === 'product-voucher-collection') {
|
|
1920
|
+
if (bridge.isCurrent?.() === false) return {
|
|
1921
|
+
status: 'cancelled'
|
|
1922
|
+
};
|
|
1923
|
+
return {
|
|
1924
|
+
status: 'failed',
|
|
1925
|
+
reason: 'entry_resolution_failed'
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1887
1928
|
console.error('[BookingTicket] handleGlobalScanCode failed', error);
|
|
1888
1929
|
bridge?.onNotify?.('fail', 'pisell2.text.scan-global-failed');
|
|
1889
1930
|
return {
|
|
@@ -2112,6 +2153,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2112
2153
|
await this.replaceTempOrder({
|
|
2113
2154
|
...tempOrder,
|
|
2114
2155
|
vouchers: nextVouchers
|
|
2156
|
+
}, {
|
|
2157
|
+
preserveOrderSessionId: this.getOrderSessionId() || undefined
|
|
2115
2158
|
});
|
|
2116
2159
|
}
|
|
2117
2160
|
this.core.effects.emit(`${this.name}:onVouchersChange`, {});
|
|
@@ -208,6 +208,10 @@ export interface AddAddTimeProductsToBookingInput {
|
|
|
208
208
|
}
|
|
209
209
|
/** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
|
|
210
210
|
export interface GlobalScanHostBridge {
|
|
211
|
+
/** product-voucher handles voucher codes; product-voucher-collection loads all vouchers for the scanned customer. */
|
|
212
|
+
scanScope?: 'all' | 'product-voucher' | 'product-voucher-collection';
|
|
213
|
+
/** A one-shot entry may outlive its page while requests are in flight. */
|
|
214
|
+
isCurrent?: () => boolean;
|
|
211
215
|
openProductDetail?: (payload: Record<string, any>) => Promise<any | null>;
|
|
212
216
|
openBookingEdit?: (payload: Record<string, any>) => Promise<any | null>;
|
|
213
217
|
confirmDetail?: (input: {
|
|
@@ -232,11 +236,13 @@ export interface GlobalScanHostBridge {
|
|
|
232
236
|
*/
|
|
233
237
|
applyPromotionCode?: (code: string, customerId?: number, options?: {
|
|
234
238
|
suppressFailureNotification?: boolean;
|
|
239
|
+
productVouchersOnly?: boolean;
|
|
235
240
|
}) => Promise<{
|
|
236
241
|
isAvailable?: boolean;
|
|
237
242
|
isAccepted?: boolean;
|
|
238
243
|
type?: string;
|
|
239
244
|
unavailableReason?: string;
|
|
245
|
+
scannedDiscountList?: Record<string, any>[];
|
|
240
246
|
}>;
|
|
241
247
|
/** 当前订单已有其他客户时,由宿主复用客户组件完成确认及切换。 */
|
|
242
248
|
requestCustomerSwitch?: (customer: ICustomer) => Promise<boolean | null>;
|
|
@@ -244,7 +250,7 @@ export interface GlobalScanHostBridge {
|
|
|
244
250
|
refresh?: () => void;
|
|
245
251
|
}
|
|
246
252
|
/** handleGlobalScanCode 结构化返回 */
|
|
247
|
-
export type GlobalScanHandleResult = {
|
|
253
|
+
export type GlobalScanHandleResult = ({
|
|
248
254
|
status: 'success';
|
|
249
255
|
kind: 'customer' | 'products' | 'promotion';
|
|
250
256
|
meta?: {
|
|
@@ -257,5 +263,11 @@ export type GlobalScanHandleResult = {
|
|
|
257
263
|
status: 'cancelled';
|
|
258
264
|
} | {
|
|
259
265
|
status: 'failed';
|
|
260
|
-
reason: 'empty_code' | 'not_found' | 'invalid_data' | 'no_bridge';
|
|
266
|
+
reason: 'empty_code' | 'not_found' | 'invalid_data' | 'no_bridge' | 'entry_resolution_failed';
|
|
267
|
+
}) & {
|
|
268
|
+
/** product-voucher-collection returns voucher candidates; the caller decides how to use them. */
|
|
269
|
+
redemption?: {
|
|
270
|
+
source: 'wallet' | 'scan';
|
|
271
|
+
vouchers: Record<string, any>[];
|
|
272
|
+
};
|
|
261
273
|
};
|
|
@@ -5,7 +5,7 @@ import type { OrderProduct, OrderProductIdentity, AddProductBookingInput } from
|
|
|
5
5
|
* cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
|
|
6
6
|
*
|
|
7
7
|
* 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
|
|
8
|
-
* 2. `requiresBookingEdit`:资源 /
|
|
8
|
+
* 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(自助终端强制进入;其他渠道由 `getIsAutoClose` 决定)
|
|
9
9
|
* 3. `add`:两关均通过,直接 transform + 加车
|
|
10
10
|
*/
|
|
11
11
|
export type AddProductDecision = {
|
|
@@ -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: {
|
|
@@ -15,14 +15,16 @@ 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");
|
|
21
|
+
var _platform = require("../../../utils/platform");
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
23
|
/**
|
|
22
24
|
* cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
|
|
23
25
|
*
|
|
24
26
|
* 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
|
|
25
|
-
* 2. `requiresBookingEdit`:资源 /
|
|
27
|
+
* 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(自助终端强制进入;其他渠道由 `getIsAutoClose` 决定)
|
|
26
28
|
* 3. `add`:两关均通过,直接 transform + 加车
|
|
27
29
|
*/
|
|
28
30
|
|
|
@@ -39,11 +41,12 @@ function needsSpecDetailModal(item) {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
|
-
* 第二段:预约商品是否仍需打开资源 /
|
|
44
|
+
* 第二段:预约商品是否仍需打开资源 / 时间编辑(自助终端强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
|
|
43
45
|
*/
|
|
44
46
|
function needsBookingEdit(cacheItem, ctx) {
|
|
47
|
+
if ((0, _BookingContext.getCalendarBookingRange)(cacheItem, ctx)) return (0, _BookingContext.calendarBookingNeedsInput)(cacheItem);
|
|
45
48
|
if (isNormalBookingProduct(cacheItem)) return false;
|
|
46
|
-
if (ctx?.channel
|
|
49
|
+
if ((0, _platform.isSelfServicePlatform)(ctx?.channel)) return true;
|
|
47
50
|
const isAutoAllocationOn = ctx?.isAutoAllocationOn || (() => true);
|
|
48
51
|
return !(0, _BookingContext.getIsAutoClose)(cacheItem, isAutoAllocationOn);
|
|
49
52
|
}
|
|
@@ -60,13 +63,26 @@ function buildRequiresBookingEditPayload(cacheItem, ctx) {
|
|
|
60
63
|
*/
|
|
61
64
|
function decideAddProduct(item, ctx) {
|
|
62
65
|
const derivedCtx = withDerivedBookingCtx(ctx);
|
|
63
|
-
|
|
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;
|
|
64
75
|
return {
|
|
65
76
|
action: 'requiresDetail',
|
|
66
|
-
payload:
|
|
77
|
+
payload: {
|
|
78
|
+
...buildRequiresDetailPayload(item, derivedCtx),
|
|
79
|
+
...(preparedCacheItem ? {
|
|
80
|
+
preparedCacheItem
|
|
81
|
+
} : {})
|
|
82
|
+
}
|
|
67
83
|
};
|
|
68
84
|
}
|
|
69
|
-
const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(
|
|
85
|
+
const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(selectedItem, derivedCtx), derivedCtx);
|
|
70
86
|
if (needsBookingEdit(cacheItem, derivedCtx)) {
|
|
71
87
|
return {
|
|
72
88
|
action: 'requiresBookingEdit',
|
|
@@ -146,6 +162,21 @@ function isMultiDayLike(cacheItem) {
|
|
|
146
162
|
* `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
|
|
147
163
|
*/
|
|
148
164
|
function prepareBookingCacheItem(cacheItem, ctx) {
|
|
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
|
+
}
|
|
149
180
|
if (ctx?.rememberedTime === undefined && (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem))) {
|
|
150
181
|
return cacheItem;
|
|
151
182
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GlobalScanHandleResult, GlobalScanHostBridge } from '../../types';
|
|
2
|
+
import { type GlobalScanApplyHost } from './applyGlobalScan';
|
|
3
|
+
import type { GlobalScanFormattedResult } from './formatGlobalScan';
|
|
4
|
+
export interface ProductVoucherCollectionScanHost extends GlobalScanApplyHost {
|
|
5
|
+
loadCustomerDiscounts(): Promise<Record<string, any>[]>;
|
|
6
|
+
}
|
|
7
|
+
/** Resolve the scanned account, then collect all of that customer's vouchers. */
|
|
8
|
+
export declare function applyProductVoucherCollectionScan(host: ProductVoucherCollectionScanHost, formatted: GlobalScanFormattedResult, bridge: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyProductVoucherCollectionScan = applyProductVoucherCollectionScan;
|
|
7
|
+
var _applyGlobalScan = require("./applyGlobalScan");
|
|
8
|
+
/** Resolve the scanned account, then collect all of that customer's vouchers. */
|
|
9
|
+
async function applyProductVoucherCollectionScan(host, formatted, bridge) {
|
|
10
|
+
const assertCurrent = () => {
|
|
11
|
+
if (bridge.isCurrent?.() === false) {
|
|
12
|
+
throw new DOMException('Scan session ended', 'AbortError');
|
|
13
|
+
}
|
|
14
|
+
};
|
|
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;
|
|
25
|
+
assertCurrent();
|
|
26
|
+
const result = await (0, _applyGlobalScan.applyGlobalScan)({
|
|
27
|
+
...host,
|
|
28
|
+
setOrderCustomer: customer => {
|
|
29
|
+
assertCurrent();
|
|
30
|
+
host.setOrderCustomer(customer);
|
|
31
|
+
},
|
|
32
|
+
addProductToOrder: (product, booking) => {
|
|
33
|
+
assertCurrent();
|
|
34
|
+
return host.addProductToOrder(product, booking);
|
|
35
|
+
}
|
|
36
|
+
}, customerScan, {
|
|
37
|
+
...bridge,
|
|
38
|
+
// Without a switch bridge, do not return the previous customer's vouchers.
|
|
39
|
+
requestCustomerSwitch: bridge.requestCustomerSwitch ?? (async () => false)
|
|
40
|
+
});
|
|
41
|
+
assertCurrent();
|
|
42
|
+
if (customerScan.searchType === 'wallet' && result.status === 'success') {
|
|
43
|
+
const vouchers = await host.loadCustomerDiscounts();
|
|
44
|
+
assertCurrent();
|
|
45
|
+
return {
|
|
46
|
+
...result,
|
|
47
|
+
redemption: {
|
|
48
|
+
source: isPass ? 'scan' : 'wallet',
|
|
49
|
+
vouchers
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
@@ -10,6 +10,7 @@ exports.searchWalletPass = exports.searchWallet = exports.searchProduct = export
|
|
|
10
10
|
const searchWalletPass = async (request, code) => {
|
|
11
11
|
const params = {
|
|
12
12
|
code,
|
|
13
|
+
resolve_ticket_order: 1,
|
|
13
14
|
translate_flag: 1,
|
|
14
15
|
// 翻译识别码名称 0:不翻译 1:翻译
|
|
15
16
|
relation_product: 1,
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.handleUniversalScan = exports.handleGlobalScan = exports.handleCustomerScan = void 0;
|
|
7
7
|
var _cloudSearch = require("./cloudSearch");
|
|
8
8
|
var _scanCache = _interopRequireDefault(require("./scanCache"));
|
|
9
|
+
var _platform = require("../../../../utils/platform");
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
11
|
/**
|
|
11
12
|
* Promise.any 的替代实现
|
|
@@ -107,7 +108,7 @@ const handleGlobalScan = (request, localSearch, channel) => {
|
|
|
107
108
|
if (value.startsWith('WL')) {
|
|
108
109
|
requestList = [(0, _cloudSearch.searchWallet)(request, value)];
|
|
109
110
|
} else {
|
|
110
|
-
requestList = [...(channel
|
|
111
|
+
requestList = [...((0, _platform.isSelfServicePlatform)(channel) ? [] : [(0, _cloudSearch.searchOrder)(request, value)]), (0, _cloudSearch.searchWalletPass)(request, value), (0, _cloudSearch.searchWallet)(request, value), (0, _cloudSearch.searchProduct)(request, value)];
|
|
111
112
|
}
|
|
112
113
|
return requestList;
|
|
113
114
|
};
|
|
@@ -130,9 +130,12 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
130
130
|
const task = (async () => {
|
|
131
131
|
const [snapshot, context, template] = await Promise.all([this.loadSource(input), this.loadContext(input), (0, _loadCustomerInvoiceLayout.loadCustomerInvoiceTemplate)(this.request, input)]);
|
|
132
132
|
const source = (0, _loadPaymentMethods.withPaymentMethodNames)(snapshot, context.methods);
|
|
133
|
-
const
|
|
133
|
+
const appPlugin = this.core.getPlugin('app');
|
|
134
|
+
const getData = appPlugin?.getData?.();
|
|
134
135
|
if (getData?.('shop_id') != null && String(getData('shop_id')) !== String(input.shopId)) throw new Error('Invoice shop changed');
|
|
135
136
|
const coreData = getData?.('core');
|
|
137
|
+
const hostApp = appPlugin?.getApp?.();
|
|
138
|
+
const shopCore = hostApp?.models?.getStore?.().getDataByModel?.('core', 'core') || hostApp?.data?.store?.getStore?.().getDataByModel?.('core', 'core') || coreData?.core || coreData || {};
|
|
136
139
|
const shop = {
|
|
137
140
|
...(coreData?.core?.shop || coreData?.shop || {}),
|
|
138
141
|
...(getData?.('shop_info') || {}),
|
|
@@ -142,6 +145,9 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
142
145
|
tax_country_code: getData('tax_country_code')
|
|
143
146
|
} : {})
|
|
144
147
|
};
|
|
148
|
+
shop.default_domain || (shop.default_domain = shopCore.default_domain);
|
|
149
|
+
shop.private_domain || (shop.private_domain = shopCore.private_domain);
|
|
150
|
+
shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
|
|
145
151
|
if (generation !== this.generation || this.disposed) throw new Error('Invoice request superseded');
|
|
146
152
|
const languageOptions = (0, _customerInvoiceLanguages.resolveCustomerInvoiceLanguages)(template.language, input.locale);
|
|
147
153
|
const remembered = this.languageSelection?.code;
|
|
@@ -101,6 +101,8 @@ export declare class ScanOrderImpl extends BaseSalesImpl implements Module {
|
|
|
101
101
|
private buildSubmitPayloadEnhancer;
|
|
102
102
|
private isScanOrderMoreMode;
|
|
103
103
|
private submitScanOrderMore;
|
|
104
|
+
/** Read both current and legacy cart snapshots without changing the product catalog. */
|
|
105
|
+
private getMenuAvailabilityProductSources;
|
|
104
106
|
submitScanOrder<T = any>(): Promise<T>;
|
|
105
107
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
106
108
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|