@pisell/pisellos 0.10.90 → 0.10.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +75 -52
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +18 -2
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- 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/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 +18 -2
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- 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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Product = Record<string, any>;
|
|
2
|
+
type Request = {
|
|
3
|
+
get: (url: string, data?: any, options?: any) => Promise<any>;
|
|
4
|
+
post: (url: string, data?: any, options?: any) => Promise<any>;
|
|
5
|
+
};
|
|
6
|
+
export type ScanOrderMenuAvailabilityErrorCode = 'SCAN_ORDER_MENU_UNAVAILABLE' | 'SCAN_ORDER_MENU_VALIDATION_FAILED';
|
|
7
|
+
export declare class ScanOrderMenuAvailabilityError extends Error {
|
|
8
|
+
readonly code: ScanOrderMenuAvailabilityErrorCode;
|
|
9
|
+
readonly productIds: number[];
|
|
10
|
+
constructor(code: ScanOrderMenuAvailabilityErrorCode, productIds?: number[]);
|
|
11
|
+
}
|
|
12
|
+
export type ScanOrderMenuAvailabilityValidator = (products: Product[], productSources?: Product[]) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Prepare fresh menu definitions without changing ProductList or the cart. The
|
|
15
|
+
* returned validator reads the shop's current time again at the submission boundary.
|
|
16
|
+
*/
|
|
17
|
+
export declare function prepareScanOrderMenuAvailability({ request, menuIds, timezone, products, productSources, }: {
|
|
18
|
+
request: Request;
|
|
19
|
+
menuIds: Array<number | string>;
|
|
20
|
+
timezone: string;
|
|
21
|
+
products: Product[];
|
|
22
|
+
productSources?: Product[];
|
|
23
|
+
}): Promise<ScanOrderMenuAvailabilityValidator>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ScanOrderMenuAvailabilityError = void 0;
|
|
7
|
+
exports.prepareScanOrderMenuAvailability = prepareScanOrderMenuAvailability;
|
|
8
|
+
var _utils = require("../ShopDiscount/utils");
|
|
9
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
class ScanOrderMenuAvailabilityError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
productIds;
|
|
14
|
+
constructor(code, productIds = []) {
|
|
15
|
+
super(code);
|
|
16
|
+
this.name = 'ScanOrderMenuAvailabilityError';
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.productIds = [...new Set(productIds)];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ScanOrderMenuAvailabilityError = ScanOrderMenuAvailabilityError;
|
|
22
|
+
const positiveId = value => {
|
|
23
|
+
const id = Number(value);
|
|
24
|
+
return Number.isInteger(id) && id > 0 ? id : undefined;
|
|
25
|
+
};
|
|
26
|
+
const productId = product => positiveId(product?.product_id ?? product?.id);
|
|
27
|
+
const fail = (ids = []) => {
|
|
28
|
+
throw new ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_VALIDATION_FAILED', ids);
|
|
29
|
+
};
|
|
30
|
+
function readList(response) {
|
|
31
|
+
if (!response || response.code !== undefined && Number(response.code) !== 200 || response.status === false || typeof response.status === 'number' && response.status >= 400 || response.success === false || !Array.isArray(response.data?.list)) fail();
|
|
32
|
+
return response.data.list;
|
|
33
|
+
}
|
|
34
|
+
function readIds(values) {
|
|
35
|
+
if (!Array.isArray(values)) return fail();
|
|
36
|
+
const ids = values.map(positiveId);
|
|
37
|
+
if (ids.some(id => id === undefined)) return fail();
|
|
38
|
+
return [...new Set(ids)];
|
|
39
|
+
}
|
|
40
|
+
function readMenu(record) {
|
|
41
|
+
const scope = record.partyroom_package?.type;
|
|
42
|
+
if (!['product_all', 'products', 'product_collection'].includes(scope)) return fail();
|
|
43
|
+
const items = record.partyroom_package?.products;
|
|
44
|
+
if (scope !== 'product_all' && !Array.isArray(items)) return fail();
|
|
45
|
+
return {
|
|
46
|
+
id: positiveId(record.form_record_id),
|
|
47
|
+
scheduleIds: readIds(record.schedule),
|
|
48
|
+
scope,
|
|
49
|
+
productIds: scope === 'products' ? readIds(items.map(item => item.product_id)) : [],
|
|
50
|
+
collectionIds: scope === 'product_collection' ? readIds(items.map(item => item.product_collection_id)) : []
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function validateSchedule(schedule) {
|
|
54
|
+
const validDate = value => typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value) && (0, _dayjs.default)(value).isValid() && (0, _dayjs.default)(value).format('YYYY-MM-DD') === value;
|
|
55
|
+
const validDateTime = value => typeof value === 'string' && /^\d{4}-\d{2}-\d{2}(?:[ T](?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?)?$/.test(value) && validDate(value.slice(0, 10)) && (0, _dayjs.default)(value).isValid();
|
|
56
|
+
const validTime = value => typeof value === 'string' && /^(?:(?:[01]\d|2[0-3]):[0-5]\d|24:00)$/.test(value);
|
|
57
|
+
if (!schedule || !['standard', 'time-slots', 'designation'].includes(schedule.type)) return fail();
|
|
58
|
+
if (schedule.type === 'designation') {
|
|
59
|
+
if (!Array.isArray(schedule.designation) || schedule.designation.some(item => !validDate(item?.start_date) || !validDate(item?.end_date) || !validTime(item?.start_time) || !validTime(item?.end_time))) return fail();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!validDateTime(schedule.start_time)) return fail();
|
|
63
|
+
if (schedule.type === 'standard' && !validDateTime(schedule.end_time)) return fail();
|
|
64
|
+
if (schedule.type === 'time-slots' && (!Array.isArray(schedule.time_slot) || schedule.time_slot.some(slot => !validTime(slot?.start_time) || !validTime(slot?.end_time)))) return fail();
|
|
65
|
+
if (schedule.repeat_type === 'none') return;
|
|
66
|
+
if (!['daily', 'weekly'].includes(schedule.repeat_type)) return fail();
|
|
67
|
+
const rule = schedule.repeat_rule;
|
|
68
|
+
if (!rule || !positiveId(rule.frequency) || !['never', 'date', 'occurrence'].includes(rule.end?.type) || rule.end.type === 'date' && !validDateTime(rule.end.end_date)) return fail();
|
|
69
|
+
for (const ranges of [rule.excluded_date, rule.included_date ?? []]) {
|
|
70
|
+
if (!Array.isArray(ranges) || ranges.some(range => !validDateTime(range?.start) || !validDateTime(range?.end))) return fail();
|
|
71
|
+
}
|
|
72
|
+
if (schedule.repeat_type === 'weekly' && (!Array.isArray(rule.frequency_date) || rule.frequency_date.some(day => typeof day !== 'number' || !Number.isInteger(day) || day < 0 || day > 6))) return fail();
|
|
73
|
+
}
|
|
74
|
+
function createShopClock(timezone) {
|
|
75
|
+
if (typeof timezone !== 'string' || !timezone.trim()) return fail();
|
|
76
|
+
const formatter = new Intl.DateTimeFormat('en-GB', {
|
|
77
|
+
timeZone: timezone.trim(),
|
|
78
|
+
year: 'numeric',
|
|
79
|
+
month: '2-digit',
|
|
80
|
+
day: '2-digit',
|
|
81
|
+
hour: '2-digit',
|
|
82
|
+
minute: '2-digit',
|
|
83
|
+
second: '2-digit',
|
|
84
|
+
hourCycle: 'h23'
|
|
85
|
+
});
|
|
86
|
+
return () => {
|
|
87
|
+
const parts = formatter.formatToParts(new Date());
|
|
88
|
+
const value = type => parts.find(part => part.type === type)?.value;
|
|
89
|
+
return `${value('year')}-${value('month')}-${value('day')} ${value('hour')}:${value('minute')}:${value('second')}`;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function collectSources(target, sources) {
|
|
93
|
+
for (const source of sources) {
|
|
94
|
+
const id = productId(source);
|
|
95
|
+
if (!id || !Array.isArray(source?.collection)) continue;
|
|
96
|
+
const ids = source.collection.map(item => positiveId(item?.id));
|
|
97
|
+
if (ids.every(value => value !== undefined)) {
|
|
98
|
+
target.set(id, [...new Set(ids)]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Prepare fresh menu definitions without changing ProductList or the cart. The
|
|
105
|
+
* returned validator reads the shop's current time again at the submission boundary.
|
|
106
|
+
*/
|
|
107
|
+
async function prepareScanOrderMenuAvailability({
|
|
108
|
+
request,
|
|
109
|
+
menuIds,
|
|
110
|
+
timezone,
|
|
111
|
+
products,
|
|
112
|
+
productSources = []
|
|
113
|
+
}) {
|
|
114
|
+
const initialIds = products.map(productId).filter(id => id !== undefined);
|
|
115
|
+
try {
|
|
116
|
+
const now = createShopClock(timezone);
|
|
117
|
+
const configuredIds = readIds(menuIds);
|
|
118
|
+
const [menuResponse, scheduleResponse] = await Promise.all([request.get('/form/data/v1', {
|
|
119
|
+
skip: 1,
|
|
120
|
+
num: 999,
|
|
121
|
+
code: 'menu_list'
|
|
122
|
+
}, {
|
|
123
|
+
useCache: false
|
|
124
|
+
}), request.get('/schedule', {
|
|
125
|
+
num: 999
|
|
126
|
+
}, {
|
|
127
|
+
useCache: false
|
|
128
|
+
})]);
|
|
129
|
+
const menuRecords = readList(menuResponse);
|
|
130
|
+
const scheduleRecords = readList(scheduleResponse);
|
|
131
|
+
const menuById = new Map(menuRecords.map(menu => [positiveId(menu.form_record_id), menu]));
|
|
132
|
+
const menus = configuredIds.map(id => {
|
|
133
|
+
const record = menuById.get(id);
|
|
134
|
+
return record ? readMenu(record) : fail();
|
|
135
|
+
});
|
|
136
|
+
const scheduleById = new Map(scheduleRecords.map(schedule => [positiveId(schedule.id), schedule]));
|
|
137
|
+
// Only configured menus and their schedules are required. Other pages in a
|
|
138
|
+
// larger catalog cannot affect this business's menu availability.
|
|
139
|
+
const referencedScheduleIds = menus.reduce((ids, menu) => ids.concat(menu.scheduleIds), []);
|
|
140
|
+
for (const id of new Set(referencedScheduleIds)) {
|
|
141
|
+
validateSchedule(scheduleById.get(id));
|
|
142
|
+
}
|
|
143
|
+
const hasCollectionMenu = menus.some(menu => menu.scope === 'product_collection');
|
|
144
|
+
const collectionsByProduct = new Map();
|
|
145
|
+
collectSources(collectionsByProduct, [...products, ...productSources]);
|
|
146
|
+
if (hasCollectionMenu) {
|
|
147
|
+
const missingIds = [...new Set(initialIds.filter(id => !collectionsByProduct.has(id)))];
|
|
148
|
+
if (missingIds.length) {
|
|
149
|
+
const response = await request.post('/product/query', {
|
|
150
|
+
ids: missingIds,
|
|
151
|
+
with: ['collection'],
|
|
152
|
+
open_quotation: 0,
|
|
153
|
+
open_bundle: 0,
|
|
154
|
+
skip: 1,
|
|
155
|
+
num: missingIds.length
|
|
156
|
+
}, {
|
|
157
|
+
useCache: false
|
|
158
|
+
});
|
|
159
|
+
collectSources(collectionsByProduct, readList(response));
|
|
160
|
+
const unresolved = missingIds.filter(id => !collectionsByProduct.has(id));
|
|
161
|
+
if (unresolved.length) fail(unresolved);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return (currentProducts, currentSources = []) => {
|
|
165
|
+
try {
|
|
166
|
+
const currentTime = now();
|
|
167
|
+
const collections = new Map(collectionsByProduct);
|
|
168
|
+
collectSources(collections, [...currentProducts, ...currentSources]);
|
|
169
|
+
const unavailable = [];
|
|
170
|
+
const insufficient = [];
|
|
171
|
+
for (const product of currentProducts) {
|
|
172
|
+
const id = productId(product);
|
|
173
|
+
if (!id) return fail();
|
|
174
|
+
const matchesDirectly = menu => menu.scope === 'product_all' || menu.scope === 'products' && menu.productIds.includes(id);
|
|
175
|
+
const isAvailable = menu => (0, _utils.getDateIsInSchedule)(currentTime, menu.scheduleIds.map(scheduleId => scheduleById.get(scheduleId)));
|
|
176
|
+
// A known valid direct relation is sufficient regardless of missing
|
|
177
|
+
// collection data on a rule product appended after preparation.
|
|
178
|
+
if (menus.some(menu => matchesDirectly(menu) && isAvailable(menu))) continue;
|
|
179
|
+
if (hasCollectionMenu && !collections.has(id)) {
|
|
180
|
+
insufficient.push(id);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const productCollections = collections.get(id) || [];
|
|
184
|
+
const associated = menus.filter(menu => matchesDirectly(menu) || menu.scope === 'product_collection' && menu.collectionIds.some(collectionId => productCollections.includes(collectionId)));
|
|
185
|
+
if (associated.some(isAvailable)) continue;
|
|
186
|
+
const systemItem = product.metadata?.item_rule_prefill === true || product.metadata?.is_rule === true;
|
|
187
|
+
if (associated.length === 0 && systemItem) continue;
|
|
188
|
+
unavailable.push(id);
|
|
189
|
+
}
|
|
190
|
+
if (insufficient.length) fail(insufficient);
|
|
191
|
+
if (unavailable.length) {
|
|
192
|
+
throw new ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_UNAVAILABLE', unavailable);
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (error instanceof ScanOrderMenuAvailabilityError) throw error;
|
|
196
|
+
return fail(currentProducts.map(productId).filter(id => id !== undefined));
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof ScanOrderMenuAvailabilityError) throw error;
|
|
201
|
+
return fail(initialIds);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, ScheduleModule } from '../../modules';
|
|
2
2
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
3
|
+
import type { OrderLocalizedText } from '../../modules/Order/types';
|
|
3
4
|
/**
|
|
4
5
|
* 扫码下单流程 hook
|
|
5
6
|
*/
|
|
@@ -43,6 +44,8 @@ export interface ScanOrderProductSku {
|
|
|
43
44
|
}
|
|
44
45
|
export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
45
46
|
order_detail_id: number | null;
|
|
47
|
+
/** 与 Order 一致的商品展示名称。 */
|
|
48
|
+
product_title?: OrderLocalizedText;
|
|
46
49
|
num: number;
|
|
47
50
|
/** Product 或当前 Variant 的生产编码 */
|
|
48
51
|
production_code?: string;
|
|
@@ -5,10 +5,12 @@ import type { AddProductDecideContext } from '../BookingTicket/utils/addProductD
|
|
|
5
5
|
import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig, type ResolvedSalesSettings } from '../../modules/OpenData';
|
|
6
6
|
import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
|
|
7
7
|
import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
8
|
-
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
9
|
-
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
8
|
+
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityRequirementSelection, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
9
|
+
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRange, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
10
10
|
import type { BusinessAvailability } from '../../modules/BusinessAvailability';
|
|
11
11
|
import { BookingTicket } from '../BookingTicket';
|
|
12
|
+
import type { BaseSalesSubmitSalesOrderParams } from '../BaseSales/types';
|
|
13
|
+
import { type PosReceiptAutoPrintPaymentStatus } from '../../utils/pos-receipt-auto-print';
|
|
12
14
|
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
13
15
|
export * from './types';
|
|
14
16
|
export * from './salesSettings';
|
|
@@ -97,7 +99,6 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
97
99
|
private allergyItemRuleConfigs;
|
|
98
100
|
private allergyItemRuleConfigsPromise;
|
|
99
101
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
100
|
-
private initializeUnifiedSalesRuntime;
|
|
101
102
|
protected getSubmitOrderSalesChannel(): string;
|
|
102
103
|
/** Only the explicit Kiosk Sales consumer entry enables this policy; POS stays unchanged. */
|
|
103
104
|
protected isBusinessAvailabilityEnabled(): boolean;
|
|
@@ -109,12 +110,30 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
109
110
|
protected getSubModuleHooks(moduleName: string): any;
|
|
110
111
|
private createAvailabilityFacadeError;
|
|
111
112
|
private getAvailabilityScopeDescriptor;
|
|
112
|
-
|
|
113
|
-
private
|
|
114
|
-
private
|
|
113
|
+
private usesDurationTimeGrid;
|
|
114
|
+
private getCurrentAvailabilityBusinessDate;
|
|
115
|
+
private getAvailabilityBusinessDateRange;
|
|
115
116
|
private normalizeAvailabilityIdList;
|
|
116
117
|
private normalizeAvailabilityStringList;
|
|
117
118
|
private normalizeAvailabilityPrepareDescriptor;
|
|
119
|
+
/**
|
|
120
|
+
* 列表直加没有经过 SKU availability flow,legacy cacheItem 的灵活时长可能落到
|
|
121
|
+
* 23:59。提交前用同一套营业排期补齐结束时间,保留已选开始时间、资源和 Holder。
|
|
122
|
+
* 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
|
|
123
|
+
*/
|
|
124
|
+
prepareDirectAddFlexibleBooking(cacheItem: any): Promise<any>;
|
|
125
|
+
/** Reuse an approved calendar cache; only the final commit may mutate the order. */
|
|
126
|
+
prepareDirectAddCalendarBooking(cacheItem: any, options?: {
|
|
127
|
+
bookingCount?: number;
|
|
128
|
+
availabilityCommitGuard?: () => void;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
cacheItem: any;
|
|
131
|
+
contextId: string;
|
|
132
|
+
candidate: ContextualProductTimeRange;
|
|
133
|
+
requirementSelections: AvailabilityRequirementSelection[];
|
|
134
|
+
partySize: number;
|
|
135
|
+
bookingCount: number;
|
|
136
|
+
} | null>;
|
|
118
137
|
private resolveAvailabilityPrepareDefaults;
|
|
119
138
|
private buildAvailabilityPrepareKey;
|
|
120
139
|
private clearAvailabilityRemoteResourceState;
|
|
@@ -131,9 +150,9 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
131
150
|
private cloneAvailabilityPrepareParams;
|
|
132
151
|
private getAvailabilityDurationCandidateAnchorAt;
|
|
133
152
|
private createAvailabilityContextRef;
|
|
134
|
-
|
|
135
|
-
private
|
|
136
|
-
private
|
|
153
|
+
/** Accept the v2 interval only within the POS order that recorded it. */
|
|
154
|
+
private resolveOrderRememberedTimes;
|
|
155
|
+
private assertRememberedOrderSession;
|
|
137
156
|
private emitAvailabilityDiagnostic;
|
|
138
157
|
private touchAvailabilityContext;
|
|
139
158
|
private touchAvailabilityProjection;
|
|
@@ -160,6 +179,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
160
179
|
* 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
|
|
161
180
|
*/
|
|
162
181
|
clearSessionStorageOrderSnapshot(): void;
|
|
182
|
+
/** 在 Kiosk 拉起支付设备前补齐订单号,同一订单重试复用已分配的号码。 */
|
|
183
|
+
ensureLocalOrderNumbersForCheckout(): Promise<void>;
|
|
163
184
|
/**
|
|
164
185
|
* PC/H5 及自助终端结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
|
|
165
186
|
* 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
|
|
@@ -204,6 +225,9 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
204
225
|
protected loadPickupTimingOpenData(_force: boolean): Promise<Record<string, unknown>>;
|
|
205
226
|
private resetAllergyItemRuleState;
|
|
206
227
|
private fetchAllergyItemRuleConfigs;
|
|
228
|
+
/** Required products currently apply only to the online venue-ticket entry. */
|
|
229
|
+
validateRequiredProducts(): Promise<void>;
|
|
230
|
+
submitSalesOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
207
231
|
private ensureAllergyItemRuleConfigsLoaded;
|
|
208
232
|
/**
|
|
209
233
|
* 评估当前渠道与商品是否命中 ALLERGY_CHECK。
|
|
@@ -213,6 +237,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
213
237
|
clearOpenDataCache(): void;
|
|
214
238
|
getInvoiceLayoutConfig(): Promise<InvoiceLayoutConfig>;
|
|
215
239
|
getInvoiceTemplateSettings(): Promise<InvoiceTemplateSettings>;
|
|
240
|
+
protected getPosReceiptAutoPrintPaymentStatuses(): PosReceiptAutoPrintPaymentStatus[] | undefined;
|
|
216
241
|
protected isInvoiceOpenDataCacheCurrent(): boolean;
|
|
217
242
|
/**
|
|
218
243
|
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
@@ -354,8 +379,15 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
354
379
|
private assertAvailabilityCommitWriteCAS;
|
|
355
380
|
private findProductLineByUid;
|
|
356
381
|
private findLinkedBooking;
|
|
357
|
-
|
|
382
|
+
removeBookingProductsOutsideStartDate(startDate: unknown): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
383
|
+
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
358
384
|
commitAvailabilitySelection(contextId: string, params: ContextualCommitAvailabilitySelectionParams): Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
|
|
359
385
|
private commitAvailabilitySelectionWithLock;
|
|
386
|
+
private initializeUnifiedSalesRuntime;
|
|
387
|
+
private isVenueKioskPlatform;
|
|
388
|
+
private supportsVenueSelectionSnapshot;
|
|
389
|
+
private getSolutionLogContext;
|
|
390
|
+
private writeSolutionLog;
|
|
391
|
+
private logSolutionFailure;
|
|
360
392
|
}
|
|
361
393
|
export declare const UnifiedBookingSales: typeof UnifiedBookingSalesImpl;
|