@pisell/pisellos 2.3.201 → 2.3.203
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/promotion/index.js +0 -9
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/menuAvailability.js +29 -10
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/menuAvailability.js +20 -8
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -444,6 +444,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
444
444
|
// The customer endpoint otherwise filters out future/variant members.
|
|
445
445
|
open_quotation: 0,
|
|
446
446
|
open_bundle: 1,
|
|
447
|
+
// Preserve the same deposit source data used by the existing sales flow.
|
|
448
|
+
open_deposit: 1,
|
|
447
449
|
with: _toConsumableArray(PRODUCT_QUERY_DATA_VARIANT_RELATIONS),
|
|
448
450
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
449
451
|
with_schedule: 1,
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -56,6 +56,10 @@ var productId = function productId(product) {
|
|
|
56
56
|
var _product$product_id;
|
|
57
57
|
return positiveId((_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id);
|
|
58
58
|
};
|
|
59
|
+
var isReservationRuleProduct = function isReservationRuleProduct(product) {
|
|
60
|
+
var _product$metadata;
|
|
61
|
+
return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_rule) === true;
|
|
62
|
+
};
|
|
59
63
|
var fail = function fail() {
|
|
60
64
|
var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
61
65
|
throw new ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_VALIDATION_FAILED', ids);
|
|
@@ -74,11 +78,14 @@ function readIds(values) {
|
|
|
74
78
|
return _toConsumableArray(new Set(ids));
|
|
75
79
|
}
|
|
76
80
|
function readMenu(record) {
|
|
77
|
-
var
|
|
78
|
-
var
|
|
81
|
+
var _config$filter;
|
|
82
|
+
var config = record.partyroom_package;
|
|
83
|
+
var scope = config === null || config === void 0 ? void 0 : config.type;
|
|
79
84
|
if (!['product_all', 'products', 'product_collection'].includes(scope)) return fail();
|
|
80
|
-
var items =
|
|
85
|
+
var items = config.products;
|
|
81
86
|
if (scope !== 'product_all' && !Array.isArray(items)) return fail();
|
|
87
|
+
var filter = Number((_config$filter = config.filter) !== null && _config$filter !== void 0 ? _config$filter : 0);
|
|
88
|
+
if (scope === 'product_all' && ![0, 1].includes(filter)) return fail();
|
|
82
89
|
return {
|
|
83
90
|
id: positiveId(record.form_record_id),
|
|
84
91
|
scheduleIds: readIds(record.schedule),
|
|
@@ -88,7 +95,10 @@ function readMenu(record) {
|
|
|
88
95
|
})) : [],
|
|
89
96
|
collectionIds: scope === 'product_collection' ? readIds(items.map(function (item) {
|
|
90
97
|
return item.product_collection_id;
|
|
91
|
-
})) : []
|
|
98
|
+
})) : [],
|
|
99
|
+
// The API resolves rule/rule_type into product_ids. For all-products menus
|
|
100
|
+
// these IDs are exclusions, and only apply while filtering is enabled.
|
|
101
|
+
excludedProductIds: scope === 'product_all' && filter === 1 ? readIds(config.product_ids) : []
|
|
92
102
|
};
|
|
93
103
|
}
|
|
94
104
|
function validateSchedule(schedule) {
|
|
@@ -190,7 +200,9 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
190
200
|
while (1) switch (_context.prev = _context.next) {
|
|
191
201
|
case 0:
|
|
192
202
|
request = _ref.request, menuIds = _ref.menuIds, timezone = _ref.timezone, products = _ref.products, _ref$productSources = _ref.productSources, productSources = _ref$productSources === void 0 ? [] : _ref$productSources;
|
|
193
|
-
initialIds = products.
|
|
203
|
+
initialIds = products.filter(function (product) {
|
|
204
|
+
return !isReservationRuleProduct(product);
|
|
205
|
+
}).map(productId).filter(function (id) {
|
|
194
206
|
return id !== undefined;
|
|
195
207
|
});
|
|
196
208
|
_context.prev = 2;
|
|
@@ -287,14 +299,17 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
287
299
|
_step3;
|
|
288
300
|
try {
|
|
289
301
|
var _loop = function _loop() {
|
|
290
|
-
var _product$
|
|
302
|
+
var _product$metadata2;
|
|
291
303
|
var product = _step3.value;
|
|
304
|
+
// Booking rule lines attach the order to a resource; they are not
|
|
305
|
+
// customer menu items, even when a menu explicitly mentions them.
|
|
306
|
+
if (isReservationRuleProduct(product)) return 0; // continue
|
|
292
307
|
var id = productId(product);
|
|
293
308
|
if (!id) return {
|
|
294
309
|
v: fail()
|
|
295
310
|
};
|
|
296
311
|
var matchesDirectly = function matchesDirectly(menu) {
|
|
297
|
-
return menu.scope === 'product_all' || menu.scope === 'products' && menu.productIds.includes(id);
|
|
312
|
+
return menu.scope === 'product_all' && !menu.excludedProductIds.includes(id) || menu.scope === 'products' && menu.productIds.includes(id);
|
|
298
313
|
};
|
|
299
314
|
var isAvailable = function isAvailable(menu) {
|
|
300
315
|
return getDateIsInSchedule(currentTime, menu.scheduleIds.map(function (scheduleId) {
|
|
@@ -302,7 +317,7 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
302
317
|
}));
|
|
303
318
|
};
|
|
304
319
|
// A known valid direct relation is sufficient regardless of missing
|
|
305
|
-
// collection data on a
|
|
320
|
+
// collection data on a product appended after preparation.
|
|
306
321
|
if (menus.some(function (menu) {
|
|
307
322
|
return matchesDirectly(menu) && isAvailable(menu);
|
|
308
323
|
})) return 0; // continue
|
|
@@ -317,8 +332,12 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
317
332
|
});
|
|
318
333
|
});
|
|
319
334
|
if (associated.some(isAvailable)) return 0; // continue
|
|
320
|
-
|
|
321
|
-
|
|
335
|
+
// Keep the fallback for unmapped retail prefills, but never let it
|
|
336
|
+
// override a menu's explicit product exclusion.
|
|
337
|
+
var explicitlyExcluded = menus.some(function (menu) {
|
|
338
|
+
return menu.excludedProductIds.includes(id);
|
|
339
|
+
});
|
|
340
|
+
if (associated.length === 0 && !explicitlyExcluded && ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.item_rule_prefill) === true) return 0; // continue
|
|
322
341
|
unavailable.push(id);
|
|
323
342
|
},
|
|
324
343
|
_ret;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -282,6 +282,8 @@ class ProductList extends _BaseModule.BaseModule {
|
|
|
282
282
|
// The customer endpoint otherwise filters out future/variant members.
|
|
283
283
|
open_quotation: 0,
|
|
284
284
|
open_bundle: 1,
|
|
285
|
+
// Preserve the same deposit source data used by the existing sales flow.
|
|
286
|
+
open_deposit: 1,
|
|
285
287
|
with: [..._clientDataVariants.PRODUCT_QUERY_DATA_VARIANT_RELATIONS],
|
|
286
288
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
287
289
|
with_schedule: 1,
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -24,6 +24,7 @@ const positiveId = value => {
|
|
|
24
24
|
return Number.isInteger(id) && id > 0 ? id : undefined;
|
|
25
25
|
};
|
|
26
26
|
const productId = product => positiveId(product?.product_id ?? product?.id);
|
|
27
|
+
const isReservationRuleProduct = product => product?.metadata?.is_rule === true;
|
|
27
28
|
const fail = (ids = []) => {
|
|
28
29
|
throw new ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_VALIDATION_FAILED', ids);
|
|
29
30
|
};
|
|
@@ -38,16 +39,22 @@ function readIds(values) {
|
|
|
38
39
|
return [...new Set(ids)];
|
|
39
40
|
}
|
|
40
41
|
function readMenu(record) {
|
|
41
|
-
const
|
|
42
|
+
const config = record.partyroom_package;
|
|
43
|
+
const scope = config?.type;
|
|
42
44
|
if (!['product_all', 'products', 'product_collection'].includes(scope)) return fail();
|
|
43
|
-
const items =
|
|
45
|
+
const items = config.products;
|
|
44
46
|
if (scope !== 'product_all' && !Array.isArray(items)) return fail();
|
|
47
|
+
const filter = Number(config.filter ?? 0);
|
|
48
|
+
if (scope === 'product_all' && ![0, 1].includes(filter)) return fail();
|
|
45
49
|
return {
|
|
46
50
|
id: positiveId(record.form_record_id),
|
|
47
51
|
scheduleIds: readIds(record.schedule),
|
|
48
52
|
scope,
|
|
49
53
|
productIds: scope === 'products' ? readIds(items.map(item => item.product_id)) : [],
|
|
50
|
-
collectionIds: scope === 'product_collection' ? readIds(items.map(item => item.product_collection_id)) : []
|
|
54
|
+
collectionIds: scope === 'product_collection' ? readIds(items.map(item => item.product_collection_id)) : [],
|
|
55
|
+
// The API resolves rule/rule_type into product_ids. For all-products menus
|
|
56
|
+
// these IDs are exclusions, and only apply while filtering is enabled.
|
|
57
|
+
excludedProductIds: scope === 'product_all' && filter === 1 ? readIds(config.product_ids) : []
|
|
51
58
|
};
|
|
52
59
|
}
|
|
53
60
|
function validateSchedule(schedule) {
|
|
@@ -111,7 +118,7 @@ async function prepareScanOrderMenuAvailability({
|
|
|
111
118
|
products,
|
|
112
119
|
productSources = []
|
|
113
120
|
}) {
|
|
114
|
-
const initialIds = products.map(productId).filter(id => id !== undefined);
|
|
121
|
+
const initialIds = products.filter(product => !isReservationRuleProduct(product)).map(productId).filter(id => id !== undefined);
|
|
115
122
|
try {
|
|
116
123
|
const now = createShopClock(timezone);
|
|
117
124
|
const configuredIds = readIds(menuIds);
|
|
@@ -169,12 +176,15 @@ async function prepareScanOrderMenuAvailability({
|
|
|
169
176
|
const unavailable = [];
|
|
170
177
|
const insufficient = [];
|
|
171
178
|
for (const product of currentProducts) {
|
|
179
|
+
// Booking rule lines attach the order to a resource; they are not
|
|
180
|
+
// customer menu items, even when a menu explicitly mentions them.
|
|
181
|
+
if (isReservationRuleProduct(product)) continue;
|
|
172
182
|
const id = productId(product);
|
|
173
183
|
if (!id) return fail();
|
|
174
|
-
const matchesDirectly = menu => menu.scope === 'product_all' || menu.scope === 'products' && menu.productIds.includes(id);
|
|
184
|
+
const matchesDirectly = menu => menu.scope === 'product_all' && !menu.excludedProductIds.includes(id) || menu.scope === 'products' && menu.productIds.includes(id);
|
|
175
185
|
const isAvailable = menu => (0, _utils.getDateIsInSchedule)(currentTime, menu.scheduleIds.map(scheduleId => scheduleById.get(scheduleId)));
|
|
176
186
|
// A known valid direct relation is sufficient regardless of missing
|
|
177
|
-
// collection data on a
|
|
187
|
+
// collection data on a product appended after preparation.
|
|
178
188
|
if (menus.some(menu => matchesDirectly(menu) && isAvailable(menu))) continue;
|
|
179
189
|
if (hasCollectionMenu && !collections.has(id)) {
|
|
180
190
|
insufficient.push(id);
|
|
@@ -183,8 +193,10 @@ async function prepareScanOrderMenuAvailability({
|
|
|
183
193
|
const productCollections = collections.get(id) || [];
|
|
184
194
|
const associated = menus.filter(menu => matchesDirectly(menu) || menu.scope === 'product_collection' && menu.collectionIds.some(collectionId => productCollections.includes(collectionId)));
|
|
185
195
|
if (associated.some(isAvailable)) continue;
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
// Keep the fallback for unmapped retail prefills, but never let it
|
|
197
|
+
// override a menu's explicit product exclusion.
|
|
198
|
+
const explicitlyExcluded = menus.some(menu => menu.excludedProductIds.includes(id));
|
|
199
|
+
if (associated.length === 0 && !explicitlyExcluded && product.metadata?.item_rule_prefill === true) continue;
|
|
188
200
|
unavailable.push(id);
|
|
189
201
|
}
|
|
190
202
|
if (insufficient.length) fail(insufficient);
|