@pisell/pisellos 2.3.49 → 2.3.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +54 -25
- package/dist/modules/Order/types.d.ts +9 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +35 -3
- package/dist/modules/Payment/types.d.ts +0 -8
- package/dist/modules/Payment/walletpass.d.ts +1 -7
- package/dist/modules/Payment/walletpass.js +45 -155
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.js +47 -13
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.js +907 -793
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +0 -16
- package/dist/server/modules/order/index.js +776 -964
- package/dist/server/modules/order/types.d.ts +0 -14
- package/dist/server/modules/order/types.js +0 -6
- package/dist/solution/BaseSales/index.d.ts +8 -3
- package/dist/solution/BaseSales/index.js +64 -50
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -2
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1142 -739
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1891 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +39 -11
- package/dist/solution/VenueBooking/index.js +1167 -841
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +26 -10
- package/lib/modules/Order/types.d.ts +9 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +36 -5
- package/lib/modules/Payment/types.d.ts +0 -8
- package/lib/modules/Payment/walletpass.d.ts +1 -7
- package/lib/modules/Payment/walletpass.js +9 -107
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.js +33 -16
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +14 -0
- package/lib/server/index.js +72 -15
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +0 -16
- package/lib/server/modules/order/index.js +4 -140
- package/lib/server/modules/order/types.d.ts +0 -14
- package/lib/server/modules/order/types.js +0 -1
- package/lib/solution/BaseSales/index.d.ts +8 -3
- package/lib/solution/BaseSales/index.js +24 -14
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +10 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1084 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +39 -11
- package/lib/solution/VenueBooking/index.js +322 -110
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ __export(ScanOrder_exports, {
|
|
|
33
33
|
ScanOrderImpl: () => ScanOrderImpl
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(ScanOrder_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_BaseSales = require("../BaseSales");
|
|
37
37
|
var import_types = require("./types");
|
|
38
38
|
var import_Order = require("../../modules/Order");
|
|
39
39
|
var import_types2 = require("../../modules/Account/types");
|
|
@@ -42,7 +42,6 @@ var import_decimal = __toESM(require("decimal.js"));
|
|
|
42
42
|
var import_utils = require("./utils");
|
|
43
43
|
var import_types4 = require("../BookingByStep/types");
|
|
44
44
|
var import_ProductList = require("../../modules/ProductList");
|
|
45
|
-
var import_Schedule = require("../../modules/Schedule");
|
|
46
45
|
var import_getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
|
|
47
46
|
var import_utils2 = require("../../modules/Order/utils");
|
|
48
47
|
var import_dayjs = __toESM(require("dayjs"));
|
|
@@ -52,7 +51,7 @@ function isItemRewardProductDiscount(discount) {
|
|
|
52
51
|
var _a, _b;
|
|
53
52
|
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
54
53
|
}
|
|
55
|
-
var _ScanOrderImpl = class extends
|
|
54
|
+
var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
56
55
|
constructor(name, version) {
|
|
57
56
|
super(name, version);
|
|
58
57
|
this.defaultName = "scanOrder";
|
|
@@ -304,28 +303,22 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
304
303
|
}
|
|
305
304
|
}
|
|
306
305
|
}
|
|
306
|
+
getRegisteredModuleNames() {
|
|
307
|
+
return ["scanOrderLogger", "products", "order", "salesSummary", "schedule"];
|
|
308
|
+
}
|
|
309
|
+
createSubModule(moduleName) {
|
|
310
|
+
if (moduleName === "scanOrderLogger") {
|
|
311
|
+
return (0, import_types4.createModule)("scanOrderLogger", this.name);
|
|
312
|
+
}
|
|
313
|
+
return super.createSubModule(moduleName);
|
|
314
|
+
}
|
|
307
315
|
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
308
316
|
getCacheId() {
|
|
309
317
|
return this.cacheId;
|
|
310
318
|
}
|
|
311
|
-
async destroyRegisteredChildModules() {
|
|
312
|
-
const modules = [
|
|
313
|
-
this.store.schedule,
|
|
314
|
-
this.store.salesSummary,
|
|
315
|
-
this.store.order,
|
|
316
|
-
this.store.products,
|
|
317
|
-
this.store.scanOrderLogger
|
|
318
|
-
];
|
|
319
|
-
for (const mod of modules) {
|
|
320
|
-
if (mod && typeof mod.destroy === "function")
|
|
321
|
-
await Promise.resolve(mod.destroy());
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
319
|
async initialize(core, options = {}) {
|
|
325
|
-
var _a, _b, _c, _d, _e, _f;
|
|
320
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
326
321
|
this.logMethodStart("initialize");
|
|
327
|
-
this.core = core;
|
|
328
|
-
this.initializeOptions = options || {};
|
|
329
322
|
this.store = { ...this.store, ...options.store };
|
|
330
323
|
this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
|
|
331
324
|
this.store.status = "initializing";
|
|
@@ -341,71 +334,26 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
341
334
|
passed: null,
|
|
342
335
|
failures: []
|
|
343
336
|
};
|
|
344
|
-
|
|
345
|
-
this.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
this.logMethodError("initialize", "request plugin missing");
|
|
352
|
-
throw new Error("scanOrder解决方案需要 request 插件支持");
|
|
353
|
-
}
|
|
354
|
-
const moduleArr = [
|
|
355
|
-
"scanOrderLogger",
|
|
356
|
-
"products",
|
|
357
|
-
"order",
|
|
358
|
-
"salesSummary"
|
|
359
|
-
];
|
|
360
|
-
moduleArr.forEach((step) => {
|
|
361
|
-
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
362
|
-
const targetModule = (0, import_types4.createModule)(step, this.name);
|
|
363
|
-
if (targetModule) {
|
|
364
|
-
this.store[step] = targetModule;
|
|
365
|
-
const initialState = step === "salesSummary" ? {
|
|
366
|
-
summary: ((_b2 = (_a2 = this.store.order) == null ? void 0 : _a2.getTempOrder()) == null ? void 0 : _b2.summary) || (0, import_utils.createEmptySummary)()
|
|
367
|
-
} : {};
|
|
368
|
-
const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.scanOrderLoggerProvider) || "feishu";
|
|
369
|
-
const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.scanOrderLoggerConfig) || {
|
|
337
|
+
await super.initialize(core, options);
|
|
338
|
+
if (this.store.scanOrderLogger) {
|
|
339
|
+
this.store.scanOrderLogger.setProvider(
|
|
340
|
+
((_e = this.otherParams) == null ? void 0 : _e.scanOrderLoggerProvider) || "feishu"
|
|
341
|
+
);
|
|
342
|
+
this.store.scanOrderLogger.setProviderConfig(
|
|
343
|
+
((_f = this.otherParams) == null ? void 0 : _f.scanOrderLoggerConfig) || {
|
|
370
344
|
feishu: {
|
|
371
345
|
webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed",
|
|
372
346
|
errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f"
|
|
373
347
|
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
initialState,
|
|
377
|
-
otherParams: {
|
|
378
|
-
...this.otherParams,
|
|
379
|
-
fatherModule: this.name,
|
|
380
|
-
openCache: ((_e2 = this.otherParams) == null ? void 0 : _e2.cacheId) ? true : false,
|
|
381
|
-
cacheId: (_f2 = this.otherParams) == null ? void 0 : _f2.cacheId,
|
|
382
|
-
salesSummaryModuleName: `${this.name}_salesSummary`,
|
|
383
|
-
provider: loggerProvider,
|
|
384
|
-
providerConfig: loggerConfig,
|
|
385
|
-
context: this.getScanOrderLoggerContext()
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
} else {
|
|
389
|
-
this.logMethodError("initialize", `module ${step} missing`);
|
|
390
|
-
throw new Error(`模块 ${step} 不存在`);
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
if (this.store.scanOrderLogger) {
|
|
348
|
+
}
|
|
349
|
+
);
|
|
394
350
|
this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
|
|
395
351
|
}
|
|
396
|
-
const scheduleModule = new import_Schedule.ScheduleModule(`${this.name}_schedule`);
|
|
397
|
-
this.store.schedule = scheduleModule;
|
|
398
|
-
this.core.registerModule(scheduleModule, {
|
|
399
|
-
otherParams: {
|
|
400
|
-
...this.otherParams,
|
|
401
|
-
fatherModule: this.name
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
352
|
this.registerCustomerLoginListeners();
|
|
405
353
|
console.log("[ScanOrder] 初始化开始");
|
|
406
354
|
try {
|
|
407
|
-
await ((
|
|
408
|
-
(
|
|
355
|
+
await ((_g = this.store.order) == null ? void 0 : _g.recalculateSummary({ createIfMissing: false }));
|
|
356
|
+
(_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
|
|
409
357
|
await this.loadRuntimeConfigs();
|
|
410
358
|
if (this.store.schedule) {
|
|
411
359
|
try {
|
|
@@ -437,7 +385,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
437
385
|
this.logMethodStart("destroy");
|
|
438
386
|
this.clearLoginEffectListeners();
|
|
439
387
|
await this.core.effects.emit(import_types.ScanOrderHooks.onDestroy, {});
|
|
440
|
-
await this.destroyRegisteredChildModules();
|
|
441
388
|
super.destroy();
|
|
442
389
|
console.log("[ScanOrder] 已销毁");
|
|
443
390
|
this.logMethodSuccess("destroy");
|
|
@@ -537,18 +484,27 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
537
484
|
});
|
|
538
485
|
return result;
|
|
539
486
|
}
|
|
540
|
-
updateTempOrderNote(note) {
|
|
487
|
+
updateTempOrderNote(note, sync = false) {
|
|
541
488
|
this.logMethodStart("updateTempOrderNote", {
|
|
542
489
|
noteLength: String(note || "").length
|
|
543
490
|
});
|
|
544
491
|
try {
|
|
545
492
|
if (!this.store.order)
|
|
546
493
|
throw new Error("order 模块未初始化");
|
|
547
|
-
const result = this.store.order.updateTempOrderNote(note);
|
|
494
|
+
const result = this.store.order.updateTempOrderNote(note, sync);
|
|
495
|
+
if (result && typeof result.then === "function") {
|
|
496
|
+
return result.then((nextNote2) => {
|
|
497
|
+
this.logMethodSuccess("updateTempOrderNote", {
|
|
498
|
+
noteLength: nextNote2.length
|
|
499
|
+
});
|
|
500
|
+
return nextNote2;
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
const nextNote = result;
|
|
548
504
|
this.logMethodSuccess("updateTempOrderNote", {
|
|
549
|
-
noteLength:
|
|
505
|
+
noteLength: nextNote.length
|
|
550
506
|
});
|
|
551
|
-
return
|
|
507
|
+
return nextNote;
|
|
552
508
|
} catch (error) {
|
|
553
509
|
this.logMethodError("updateTempOrderNote", error);
|
|
554
510
|
throw error;
|
|
@@ -557,6 +513,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
557
513
|
// 存储 UI 层选择的取餐方式到 tempOrder.metadata.shop_service_data
|
|
558
514
|
// service_type 在扫码点餐场景固定为 dine_in
|
|
559
515
|
setPickupReferenceMode(mode) {
|
|
516
|
+
var _a;
|
|
560
517
|
this.logMethodStart("setPickupReferenceMode", { mode });
|
|
561
518
|
try {
|
|
562
519
|
if (!this.store.order)
|
|
@@ -566,7 +523,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
566
523
|
...tempOrder.metadata || {},
|
|
567
524
|
shop_service_data: {
|
|
568
525
|
...(tempOrder.metadata || {}).shop_service_data || {},
|
|
569
|
-
service_type: "dine_in",
|
|
526
|
+
service_type: ((_a = this.otherParams) == null ? void 0 : _a.businessCode) === "dine_in" ? "dine_in" : "",
|
|
570
527
|
pickup_reference_mode: mode
|
|
571
528
|
}
|
|
572
529
|
};
|
|
@@ -598,7 +555,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
598
555
|
throw error;
|
|
599
556
|
}
|
|
600
557
|
}
|
|
601
|
-
|
|
558
|
+
ensureScanOrderTempOrder() {
|
|
602
559
|
if (!this.store.order)
|
|
603
560
|
throw new Error("order 模块未初始化");
|
|
604
561
|
return this.store.order.ensureTempOrder();
|
|
@@ -823,6 +780,49 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
823
780
|
combined_resource: isCombined ? combined : null
|
|
824
781
|
};
|
|
825
782
|
}
|
|
783
|
+
async prepareRetailAvailability(params) {
|
|
784
|
+
var _a, _b;
|
|
785
|
+
const { tempOrder, hasOrderId, resourceId, reason } = params;
|
|
786
|
+
this.enabledReservationRuleProducts = [];
|
|
787
|
+
tempOrder.bookings = [];
|
|
788
|
+
tempOrder.order_id = null;
|
|
789
|
+
delete tempOrder.relation_id;
|
|
790
|
+
delete tempOrder.table_form_id;
|
|
791
|
+
delete tempOrder.resource_id;
|
|
792
|
+
delete tempOrder.table_number;
|
|
793
|
+
tempOrder.metadata = { ...tempOrder.metadata || {} };
|
|
794
|
+
delete tempOrder.metadata.table_occupancy_duration;
|
|
795
|
+
const resourceState = {
|
|
796
|
+
mode: "idle",
|
|
797
|
+
deskmate_valid: false,
|
|
798
|
+
allowSnack: false,
|
|
799
|
+
deskmateValid: false,
|
|
800
|
+
isExclusive: false,
|
|
801
|
+
isFull: false,
|
|
802
|
+
raw: null
|
|
803
|
+
};
|
|
804
|
+
this.store.resource = resourceState;
|
|
805
|
+
(_a = this.store.order) == null ? void 0 : _a.persistTempOrder();
|
|
806
|
+
await this.addNewOrder();
|
|
807
|
+
await this.setItemRuleRuntimeConfig({
|
|
808
|
+
serviceType: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
809
|
+
submissionIndex: hasOrderId ? 1 : 0,
|
|
810
|
+
historicalItems: []
|
|
811
|
+
});
|
|
812
|
+
const availabilityInfo = {
|
|
813
|
+
mode: "idle",
|
|
814
|
+
deskmate_valid: false
|
|
815
|
+
};
|
|
816
|
+
this.logMethodSuccess("checkResourceAvailable", {
|
|
817
|
+
resourceId,
|
|
818
|
+
mode: availabilityInfo.mode,
|
|
819
|
+
retailMode: true,
|
|
820
|
+
retailReason: reason,
|
|
821
|
+
relationId: resourceState.relationId,
|
|
822
|
+
persistedResourceId: resourceState.relationId
|
|
823
|
+
});
|
|
824
|
+
return availabilityInfo;
|
|
825
|
+
}
|
|
826
826
|
// ScanOrder 提交 payload enhancer:
|
|
827
827
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
828
828
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -832,23 +832,33 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
832
832
|
const ruleProduct = this.enabledReservationRuleProducts[0];
|
|
833
833
|
const resourceState = this.store.resource;
|
|
834
834
|
const resourceSelectType = resourceState == null ? void 0 : resourceState.resourceSelectType;
|
|
835
|
-
const
|
|
835
|
+
const resolveBookingCapacityValue = () => {
|
|
836
836
|
var _a;
|
|
837
837
|
if (resourceSelectType === "single") {
|
|
838
838
|
const raw = (_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.capacity;
|
|
839
839
|
const num = Number(raw);
|
|
840
840
|
if (Number.isFinite(num) && num > 0)
|
|
841
|
-
return num;
|
|
841
|
+
return Math.max(1, Math.floor(num));
|
|
842
842
|
return 1;
|
|
843
843
|
}
|
|
844
844
|
return 1;
|
|
845
845
|
};
|
|
846
846
|
return (payload, { bookingUuid, tempOrder }) => {
|
|
847
847
|
var _a, _b;
|
|
848
|
-
const resourceId =
|
|
848
|
+
const resourceId = String((resourceState == null ? void 0 : resourceState.relationId) ?? "").trim();
|
|
849
|
+
const hasReservationBookingContext = Boolean(
|
|
850
|
+
ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId
|
|
851
|
+
);
|
|
852
|
+
if (!hasReservationBookingContext) {
|
|
853
|
+
return {
|
|
854
|
+
...payload,
|
|
855
|
+
bookings: [],
|
|
856
|
+
products: [...payload.products || []]
|
|
857
|
+
};
|
|
858
|
+
}
|
|
849
859
|
const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
|
|
850
|
-
const
|
|
851
|
-
const
|
|
860
|
+
const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
|
|
861
|
+
const bookingCapacityValue = resolveBookingCapacityValue();
|
|
852
862
|
const pickOriginal = (value) => {
|
|
853
863
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
854
864
|
const original = value.original;
|
|
@@ -864,35 +874,42 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
864
874
|
main_field: mainField,
|
|
865
875
|
form_id: resourceState.tableFormId,
|
|
866
876
|
relation_id: resourceState.relationId ?? resourceId,
|
|
867
|
-
capacity:
|
|
877
|
+
capacity: bookingCapacityValue,
|
|
868
878
|
metadata: this.buildScanOrderResourceMetadata({
|
|
869
879
|
resourceState,
|
|
870
880
|
resourceName: mainField
|
|
871
881
|
})
|
|
872
882
|
} : void 0;
|
|
873
883
|
const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
|
|
874
|
-
const bookingCapacityValue = resourceCapacityValue;
|
|
875
884
|
const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
|
|
876
|
-
const nextBookings = (payload.bookings || []).map((booking, idx) =>
|
|
877
|
-
...booking
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
885
|
+
const nextBookings = (payload.bookings || []).map((booking, idx) => {
|
|
886
|
+
const metadata = { ...booking.metadata || {} };
|
|
887
|
+
if (hasExplicitCollectPax) {
|
|
888
|
+
metadata.collect_pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
|
|
889
|
+
} else {
|
|
890
|
+
delete metadata.collect_pax;
|
|
891
|
+
}
|
|
892
|
+
return {
|
|
893
|
+
...booking,
|
|
894
|
+
number: bookingCapacityValue,
|
|
895
|
+
appointment_status: "started",
|
|
896
|
+
metadata: {
|
|
897
|
+
...metadata,
|
|
898
|
+
...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
|
|
899
|
+
...resourceSelectType ? {
|
|
900
|
+
capacity: [
|
|
901
|
+
{
|
|
902
|
+
id: bookingCapacityDimensionId,
|
|
903
|
+
value: bookingCapacityValue,
|
|
904
|
+
name: ""
|
|
905
|
+
}
|
|
906
|
+
]
|
|
907
|
+
} : {}
|
|
908
|
+
},
|
|
909
|
+
...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
|
|
910
|
+
...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
|
|
911
|
+
};
|
|
912
|
+
});
|
|
896
913
|
const nextProducts = [...payload.products || []];
|
|
897
914
|
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
898
915
|
const sellingPrice = String(ruleProduct.price ?? "0.00");
|
|
@@ -921,8 +938,58 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
921
938
|
return { ...payload, bookings: nextBookings, products: nextProducts };
|
|
922
939
|
};
|
|
923
940
|
}
|
|
941
|
+
isScanOrderMoreMode(tempOrder) {
|
|
942
|
+
var _a, _b;
|
|
943
|
+
const mode = (_a = this.store.resource) == null ? void 0 : _a.mode;
|
|
944
|
+
return Boolean(
|
|
945
|
+
tempOrder.order_id && (mode === "additional_order" || mode === "additional_order_with_code" || ((_b = this.store.entryContext) == null ? void 0 : _b.mode) === "append")
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
async submitScanOrderMore(params) {
|
|
949
|
+
var _a, _b, _c, _d, _e;
|
|
950
|
+
if (!this.request) {
|
|
951
|
+
throw new Error("scanOrder解决方案需要 request 插件支持");
|
|
952
|
+
}
|
|
953
|
+
if (!this.store.order) {
|
|
954
|
+
throw new Error("scanOrder解决方案需要 order 模块支持");
|
|
955
|
+
}
|
|
956
|
+
const { tempOrder, enhancePayload } = params;
|
|
957
|
+
const latestSummary = await this.store.order.recalculateSummary({
|
|
958
|
+
createIfMissing: true
|
|
959
|
+
});
|
|
960
|
+
const payload = (0, import_utils2.buildSubmitPayload)({
|
|
961
|
+
tempOrder,
|
|
962
|
+
cacheId: this.cacheId,
|
|
963
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
964
|
+
businessCode: ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
965
|
+
channel: (_d = this.otherParams) == null ? void 0 : _d.channel,
|
|
966
|
+
type: (_e = this.otherParams) == null ? void 0 : _e.type,
|
|
967
|
+
summary: latestSummary,
|
|
968
|
+
enhance: enhancePayload
|
|
969
|
+
});
|
|
970
|
+
const products = (0, import_utils.filterProductsForScanOrderMore)(payload.products);
|
|
971
|
+
const orderId = tempOrder.order_id;
|
|
972
|
+
const result = await this.request.put(
|
|
973
|
+
`/order/order/product/${orderId}`,
|
|
974
|
+
{
|
|
975
|
+
products,
|
|
976
|
+
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
977
|
+
},
|
|
978
|
+
{ customToast: () => {
|
|
979
|
+
} }
|
|
980
|
+
);
|
|
981
|
+
if ((result == null ? void 0 : result.code) === 200 && !(result == null ? void 0 : result.data)) {
|
|
982
|
+
return {
|
|
983
|
+
...result,
|
|
984
|
+
data: {
|
|
985
|
+
order_id: orderId
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
return result;
|
|
990
|
+
}
|
|
924
991
|
async submitScanOrder() {
|
|
925
|
-
var _a, _b, _c
|
|
992
|
+
var _a, _b, _c;
|
|
926
993
|
this.logMethodStart("submitScanOrder");
|
|
927
994
|
try {
|
|
928
995
|
await this.validateBeforeSubmitByItemRule();
|
|
@@ -942,17 +1009,15 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
942
1009
|
}
|
|
943
1010
|
this.store.order.persistTempOrder();
|
|
944
1011
|
const enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
945
|
-
const result = await this.
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
channel: (_e = this.otherParams) == null ? void 0 : _e.channel,
|
|
950
|
-
type: (_f = this.otherParams) == null ? void 0 : _f.type,
|
|
1012
|
+
const result = this.isScanOrderMoreMode(tempOrderForSubmit) ? await this.submitScanOrderMore({
|
|
1013
|
+
tempOrder: tempOrderForSubmit,
|
|
1014
|
+
enhancePayload
|
|
1015
|
+
}) : await this.submitSalesOrder({
|
|
951
1016
|
enhancePayload
|
|
952
1017
|
});
|
|
953
1018
|
const tempOrder = this.store.order.getTempOrder();
|
|
954
1019
|
this.logMethodSuccess("submitScanOrder", {
|
|
955
|
-
productCount: ((
|
|
1020
|
+
productCount: ((_c = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _c.length) || 0
|
|
956
1021
|
});
|
|
957
1022
|
return result;
|
|
958
1023
|
} catch (error) {
|
|
@@ -1193,7 +1258,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1193
1258
|
return [];
|
|
1194
1259
|
}
|
|
1195
1260
|
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1196
|
-
tempOrder: this.
|
|
1261
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
1197
1262
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1198
1263
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1199
1264
|
});
|
|
@@ -1219,7 +1284,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1219
1284
|
if (!strategyConfigs.length)
|
|
1220
1285
|
return;
|
|
1221
1286
|
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1222
|
-
tempOrder: this.
|
|
1287
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
1223
1288
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1224
1289
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1225
1290
|
});
|
|
@@ -1229,7 +1294,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1229
1294
|
return;
|
|
1230
1295
|
}
|
|
1231
1296
|
const productSourceMap = await this.buildPrefillProductSourceMap();
|
|
1232
|
-
const tempOrder = this.
|
|
1297
|
+
const tempOrder = this.ensureScanOrderTempOrder();
|
|
1233
1298
|
let hasChanges = false;
|
|
1234
1299
|
for (const prefillItem of prefillItems) {
|
|
1235
1300
|
const productId = Number(prefillItem.product_id);
|
|
@@ -1329,7 +1394,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1329
1394
|
};
|
|
1330
1395
|
}
|
|
1331
1396
|
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1332
|
-
tempOrder: this.
|
|
1397
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
1333
1398
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1334
1399
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1335
1400
|
});
|
|
@@ -1479,8 +1544,8 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1479
1544
|
const matched = resources.find((r) => Number(r == null ? void 0 : r.id) === numericFormId);
|
|
1480
1545
|
return matched == null ? void 0 : matched.type;
|
|
1481
1546
|
}
|
|
1482
|
-
async
|
|
1483
|
-
var _a, _b, _c
|
|
1547
|
+
async fetchResourceOccupyDetailsByResourceId(resourceId) {
|
|
1548
|
+
var _a, _b, _c;
|
|
1484
1549
|
const formRecordId = Number(resourceId);
|
|
1485
1550
|
if (!Number.isFinite(formRecordId) || formRecordId <= 0) {
|
|
1486
1551
|
throw new Error(`[ScanOrder] 非法桌台 resourceId: ${resourceId}`);
|
|
@@ -1502,15 +1567,60 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1502
1567
|
if (!(response == null ? void 0 : response.status)) {
|
|
1503
1568
|
throw new Error((response == null ? void 0 : response.message) || "获取资源占用详情失败");
|
|
1504
1569
|
}
|
|
1505
|
-
return ((
|
|
1570
|
+
return ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.occupy_details) ?? [];
|
|
1571
|
+
}
|
|
1572
|
+
resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
|
|
1573
|
+
const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
|
|
1574
|
+
if (currentOrderId) {
|
|
1575
|
+
return {
|
|
1576
|
+
matched: true,
|
|
1577
|
+
order_id: currentOrderId
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
const orderListIds = (Array.isArray(detail == null ? void 0 : detail.order_list) ? (detail == null ? void 0 : detail.order_list) || [] : []).map((order) => (0, import_utils.toPositiveString)(order == null ? void 0 : order.id)).filter(Boolean);
|
|
1581
|
+
if (resourceSelectType !== "single") {
|
|
1582
|
+
return {
|
|
1583
|
+
matched: false,
|
|
1584
|
+
reason: "no_order"
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
if (!orderListIds.length) {
|
|
1588
|
+
return {
|
|
1589
|
+
matched: false,
|
|
1590
|
+
reason: "no_order"
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
if (!allowAddItems) {
|
|
1594
|
+
return {
|
|
1595
|
+
matched: false,
|
|
1596
|
+
reason: "add_items_disabled"
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
if (orderListIds.length === 1) {
|
|
1600
|
+
return {
|
|
1601
|
+
matched: true,
|
|
1602
|
+
order_id: orderListIds[0]
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
if (orderListIds.length > 1) {
|
|
1606
|
+
return {
|
|
1607
|
+
matched: false,
|
|
1608
|
+
reason: "multiple_orders"
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
return {
|
|
1612
|
+
matched: false,
|
|
1613
|
+
reason: "no_order"
|
|
1614
|
+
};
|
|
1506
1615
|
}
|
|
1507
1616
|
// 检测当前链接是否可用
|
|
1508
1617
|
// 通过 resource_id + 店铺配置
|
|
1509
1618
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
1510
|
-
async checkResourceAvailable(resourceId, hasOrderId) {
|
|
1511
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
1619
|
+
async checkResourceAvailable(resourceId, hasOrderId = false) {
|
|
1620
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1621
|
+
const normalizedResourceId = String(resourceId ?? "").trim();
|
|
1512
1622
|
this.logMethodStart("checkResourceAvailable", {
|
|
1513
|
-
resourceId
|
|
1623
|
+
resourceId: normalizedResourceId
|
|
1514
1624
|
});
|
|
1515
1625
|
try {
|
|
1516
1626
|
const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? "").trim();
|
|
@@ -1560,37 +1670,71 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1560
1670
|
if (outsideOperatingHours && closedBehaviorValue !== "show_menu_disabled") {
|
|
1561
1671
|
return makeShopClosed(closedMessage, closedBehaviorValue);
|
|
1562
1672
|
}
|
|
1563
|
-
const tempOrder = this.
|
|
1673
|
+
const tempOrder = this.ensureScanOrderTempOrder();
|
|
1564
1674
|
const reservationLinkIds = (0, import_utils.collectLinkProductIdsFromReservationRules)(
|
|
1565
1675
|
dineInConfig["fulfillment.enabled_resource_rules"]
|
|
1566
1676
|
);
|
|
1677
|
+
if (!normalizedResourceId || reservationLinkIds.length === 0) {
|
|
1678
|
+
return await this.prepareRetailAvailability({
|
|
1679
|
+
tempOrder,
|
|
1680
|
+
hasOrderId,
|
|
1681
|
+
resourceId: normalizedResourceId,
|
|
1682
|
+
reason: !normalizedResourceId ? "missing_resource_id" : "missing_enabled_resource_rules"
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1567
1685
|
let pendingRequestEntryPax;
|
|
1568
1686
|
let pendingRequestPaxMin;
|
|
1569
1687
|
let pendingRequestPaxMax;
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1688
|
+
tempOrder.metadata = { ...tempOrder.metadata || {} };
|
|
1689
|
+
delete tempOrder.metadata.table_occupancy_duration;
|
|
1690
|
+
const reservationProductList = new import_ProductList.ProductList(
|
|
1691
|
+
`${this.name}_reservationEnabledRules`,
|
|
1692
|
+
this.defaultVersion
|
|
1693
|
+
);
|
|
1694
|
+
await reservationProductList.initialize(this.core, {
|
|
1695
|
+
store: { list: [], selectProducts: [] },
|
|
1696
|
+
otherParams: {
|
|
1697
|
+
...this.otherParams,
|
|
1698
|
+
fatherModule: this.name,
|
|
1699
|
+
openCache: Boolean(this.cacheId),
|
|
1700
|
+
cacheId: this.cacheId
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1703
|
+
const scheduleDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
1704
|
+
const scheduleDatetime = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1705
|
+
const loaded = await reservationProductList.loadProducts({
|
|
1706
|
+
product_ids: reservationLinkIds,
|
|
1707
|
+
schedule_date: scheduleDate,
|
|
1708
|
+
schedule_datetime: scheduleDatetime,
|
|
1709
|
+
cacheId: this.cacheId
|
|
1710
|
+
});
|
|
1711
|
+
if (Array.isArray(loaded)) {
|
|
1712
|
+
const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
|
|
1713
|
+
loaded,
|
|
1714
|
+
normalizedResourceId
|
|
1578
1715
|
);
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1716
|
+
const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
|
|
1717
|
+
this.enabledReservationRuleProducts = ruleProductsForResource;
|
|
1718
|
+
const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
|
|
1719
|
+
if (occupancyMinutes !== void 0) {
|
|
1720
|
+
tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
|
|
1721
|
+
}
|
|
1722
|
+
if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
|
|
1723
|
+
pendingRequestEntryPax = 1;
|
|
1724
|
+
const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
|
|
1725
|
+
if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
|
|
1726
|
+
pendingRequestPaxMin = paxBounds.min;
|
|
1727
|
+
if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
|
|
1728
|
+
pendingRequestPaxMax = paxBounds.max;
|
|
1729
|
+
}
|
|
1730
|
+
} else {
|
|
1731
|
+
this.enabledReservationRuleProducts = [];
|
|
1732
|
+
const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
|
|
1733
|
+
this.logMethodError("loadReservationRuleProducts", error, {
|
|
1734
|
+
resourceId: normalizedResourceId,
|
|
1735
|
+
reservationLinkIds,
|
|
1736
|
+
scheduleDate,
|
|
1737
|
+
scheduleDatetime,
|
|
1594
1738
|
cacheId: this.cacheId
|
|
1595
1739
|
});
|
|
1596
1740
|
if (Array.isArray(loaded)) {
|
|
@@ -1609,8 +1753,8 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1609
1753
|
}
|
|
1610
1754
|
} else {
|
|
1611
1755
|
this.enabledReservationRuleProducts = [];
|
|
1612
|
-
const
|
|
1613
|
-
this.logMethodError("loadReservationRuleProducts",
|
|
1756
|
+
const error2 = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
|
|
1757
|
+
this.logMethodError("loadReservationRuleProducts", error2, {
|
|
1614
1758
|
resourceId,
|
|
1615
1759
|
reservationLinkIds,
|
|
1616
1760
|
scheduleDate,
|
|
@@ -1619,15 +1763,54 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1619
1763
|
});
|
|
1620
1764
|
}
|
|
1621
1765
|
}
|
|
1622
|
-
const
|
|
1766
|
+
const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
1767
|
+
const occupyDetail = occupyDetails[0] ?? null;
|
|
1623
1768
|
const resourceSelectType = this.resolveResourceSelectType(
|
|
1624
1769
|
(0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id)
|
|
1625
1770
|
);
|
|
1771
|
+
const allowAddItems = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.allow_add_items"]);
|
|
1772
|
+
const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(
|
|
1773
|
+
occupyDetail,
|
|
1774
|
+
resourceSelectType,
|
|
1775
|
+
allowAddItems
|
|
1776
|
+
);
|
|
1777
|
+
if (additionalOrderResult.reason === "multiple_orders") {
|
|
1778
|
+
const multipleOrdersState = {
|
|
1779
|
+
...this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId),
|
|
1780
|
+
mode: "multiple_orders"
|
|
1781
|
+
};
|
|
1782
|
+
this.store.resource = multipleOrdersState;
|
|
1783
|
+
const availabilityInfo2 = {
|
|
1784
|
+
mode: "multiple_orders",
|
|
1785
|
+
deskmate_valid: multipleOrdersState.deskmate_valid,
|
|
1786
|
+
relation_id: multipleOrdersState.relationId,
|
|
1787
|
+
table_form_id: multipleOrdersState.tableFormId,
|
|
1788
|
+
table_form_record: multipleOrdersState.table_form_record
|
|
1789
|
+
};
|
|
1790
|
+
this.logMethodSuccess("checkResourceAvailable", {
|
|
1791
|
+
resourceId: normalizedResourceId,
|
|
1792
|
+
mode: availabilityInfo2.mode,
|
|
1793
|
+
orderListCount: ((_e = occupyDetail == null ? void 0 : occupyDetail.order_list) == null ? void 0 : _e.length) || 0,
|
|
1794
|
+
resourceSelectType
|
|
1795
|
+
});
|
|
1796
|
+
return availabilityInfo2;
|
|
1797
|
+
}
|
|
1626
1798
|
const resourceState = this.normalizeResourceState(
|
|
1627
1799
|
occupyDetail,
|
|
1628
1800
|
resourceSelectType,
|
|
1629
1801
|
hasOrderId
|
|
1630
1802
|
);
|
|
1803
|
+
const additionalOrderId = additionalOrderResult.order_id;
|
|
1804
|
+
if (additionalOrderId) {
|
|
1805
|
+
resourceState.mode = "additional_order";
|
|
1806
|
+
resourceState.order_id = additionalOrderId;
|
|
1807
|
+
} else if (additionalOrderResult.reason === "add_items_disabled") {
|
|
1808
|
+
resourceState.mode = "resource_busy";
|
|
1809
|
+
resourceState.order_id = "0";
|
|
1810
|
+
} else if (resourceSelectType === "multiple" && resourceState.isFull) {
|
|
1811
|
+
resourceState.mode = "resource_busy";
|
|
1812
|
+
resourceState.order_id = "0";
|
|
1813
|
+
}
|
|
1631
1814
|
this.store.resource = resourceState;
|
|
1632
1815
|
if (pendingRequestEntryPax !== void 0) {
|
|
1633
1816
|
this.store.resource.requestEntryPax = pendingRequestEntryPax;
|
|
@@ -1645,36 +1828,22 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1645
1828
|
table_form_id: resourceState.tableFormId,
|
|
1646
1829
|
deskmate_valid: resourceState.deskmate_valid,
|
|
1647
1830
|
table_form_record: resourceState.table_form_record,
|
|
1648
|
-
policy: (
|
|
1649
|
-
partyroom_booking: (
|
|
1831
|
+
policy: (_f = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _f.policy,
|
|
1832
|
+
partyroom_booking: (_g = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _g.partyroom_booking,
|
|
1650
1833
|
...this.store.resource.requestEntryPax !== void 0 ? { requestEntryPax: this.store.resource.requestEntryPax } : {},
|
|
1651
1834
|
...this.store.resource.requestPaxMin !== void 0 ? { requestPaxMin: this.store.resource.requestPaxMin } : {},
|
|
1652
1835
|
...this.store.resource.requestPaxMax !== void 0 ? { requestPaxMax: this.store.resource.requestPaxMax } : {}
|
|
1653
1836
|
};
|
|
1654
|
-
tempOrder.relation_id = resourceId || ((_g = this.otherParams) == null ? void 0 : _g.relation_id);
|
|
1655
|
-
tempOrder.table_form_id = resourceState.tableFormId;
|
|
1656
|
-
tempOrder.resource_id = resourceId;
|
|
1657
1837
|
(_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
|
|
1658
1838
|
if (availabilityInfo.mode === "idle") {
|
|
1659
1839
|
await this.addNewOrder();
|
|
1660
1840
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
if (tempOrder.order_id) {
|
|
1665
|
-
const res = await ((_i = this.store.order) == null ? void 0 : _i.getSalesOrderByLookup({
|
|
1666
|
-
lookup: tempOrder.order_id
|
|
1667
|
-
}));
|
|
1668
|
-
const entryPaxNumber = (_m = (_l = (_k = (_j = res == null ? void 0 : res.data) == null ? void 0 : _j.bookings) == null ? void 0 : _k.find((p) => {
|
|
1669
|
-
var _a2;
|
|
1670
|
-
return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
|
|
1671
|
-
})) == null ? void 0 : _l.metadata) == null ? void 0 : _m.collect_pax;
|
|
1672
|
-
if (entryPaxNumber) {
|
|
1673
|
-
await this.setEntryPaxNumber(entryPaxNumber);
|
|
1674
|
-
}
|
|
1841
|
+
const isAdditionalOrderMode = availabilityInfo.mode === "additional_order" || availabilityInfo.mode === "additional_order_with_code";
|
|
1842
|
+
if (isAdditionalOrderMode) {
|
|
1843
|
+
tempOrder.order_id = additionalOrderId;
|
|
1675
1844
|
}
|
|
1676
|
-
const lastOrderInfo = (
|
|
1677
|
-
const historicalItems =
|
|
1845
|
+
const lastOrderInfo = (_j = (_i = this.store.order) == null ? void 0 : _i.getLastOrderInfo) == null ? void 0 : _j.call(_i);
|
|
1846
|
+
const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
|
|
1678
1847
|
if (typeof (p == null ? void 0 : p.product_id) !== "number")
|
|
1679
1848
|
return acc;
|
|
1680
1849
|
acc.push({
|
|
@@ -1685,8 +1854,8 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1685
1854
|
return acc;
|
|
1686
1855
|
}, []) : [];
|
|
1687
1856
|
await this.setItemRuleRuntimeConfig({
|
|
1688
|
-
serviceType: (
|
|
1689
|
-
submissionIndex:
|
|
1857
|
+
serviceType: (_k = this.otherParams) == null ? void 0 : _k.businessCode,
|
|
1858
|
+
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
1690
1859
|
historicalItems
|
|
1691
1860
|
});
|
|
1692
1861
|
if (outsideOperatingHours && closedBehaviorValue === "show_menu_disabled") {
|
|
@@ -1695,13 +1864,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1695
1864
|
availabilityInfo.closed_behavior = closedBehaviorValue;
|
|
1696
1865
|
}
|
|
1697
1866
|
this.logMethodSuccess("checkResourceAvailable", {
|
|
1698
|
-
resourceId,
|
|
1867
|
+
resourceId: normalizedResourceId,
|
|
1699
1868
|
mode: availabilityInfo.mode,
|
|
1700
1869
|
orderId: availabilityInfo.order_id,
|
|
1701
1870
|
relationId: availabilityInfo.relation_id,
|
|
1702
1871
|
tableFormId: availabilityInfo.table_form_id,
|
|
1703
|
-
persistedRelationId:
|
|
1704
|
-
persistedResourceId:
|
|
1872
|
+
persistedRelationId: (_l = this.store.resource) == null ? void 0 : _l.relationId,
|
|
1873
|
+
persistedResourceId: (_m = this.store.resource) == null ? void 0 : _m.relationId,
|
|
1705
1874
|
deskmateValid: availabilityInfo.deskmate_valid,
|
|
1706
1875
|
resourceSelectType: resourceState.resourceSelectType,
|
|
1707
1876
|
isExclusive: resourceState.isExclusive,
|
|
@@ -1710,11 +1879,29 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1710
1879
|
return availabilityInfo;
|
|
1711
1880
|
} catch (error) {
|
|
1712
1881
|
this.logMethodError("checkResourceAvailable", error.message, {
|
|
1713
|
-
resourceId
|
|
1882
|
+
resourceId: normalizedResourceId
|
|
1714
1883
|
});
|
|
1715
1884
|
throw error;
|
|
1716
1885
|
}
|
|
1717
1886
|
}
|
|
1887
|
+
// 恢复之前订单的数据,读取 entrypax
|
|
1888
|
+
async restorePreviousOrderData() {
|
|
1889
|
+
var _a, _b, _c, _d;
|
|
1890
|
+
const orderModule = this.store.order;
|
|
1891
|
+
if (!orderModule)
|
|
1892
|
+
return;
|
|
1893
|
+
const tempOrder = orderModule.ensureTempOrder();
|
|
1894
|
+
if (tempOrder.order_id) {
|
|
1895
|
+
const res = await orderModule.getOrderInfo(tempOrder.order_id);
|
|
1896
|
+
const entryPaxNumber = (_d = (_c = (_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.bookings) == null ? void 0 : _b.find((p) => {
|
|
1897
|
+
var _a2;
|
|
1898
|
+
return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
|
|
1899
|
+
})) == null ? void 0 : _c.metadata) == null ? void 0 : _d.collect_pax;
|
|
1900
|
+
if (entryPaxNumber) {
|
|
1901
|
+
await this.setEntryPaxNumber(entryPaxNumber);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1718
1905
|
// 如果是加单的情况,提供返回当前订单相关信息的能力
|
|
1719
1906
|
async getAdditionalOrderInfo() {
|
|
1720
1907
|
this.logMethodStart("getAdditionalOrderInfo");
|
|
@@ -1735,7 +1922,8 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1735
1922
|
async getProductList() {
|
|
1736
1923
|
var _a, _b;
|
|
1737
1924
|
this.logMethodStart("getProductList");
|
|
1738
|
-
const
|
|
1925
|
+
const associatedMenus = (_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"];
|
|
1926
|
+
const menu_list_ids = associatedMenus.map((n) => Number(n.value)) || [];
|
|
1739
1927
|
try {
|
|
1740
1928
|
if (!this.store.products)
|
|
1741
1929
|
throw new Error("products 模块未初始化");
|
|
@@ -1859,6 +2047,85 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1859
2047
|
getEntryPaxNumber() {
|
|
1860
2048
|
return this.store.entryPaxNumber;
|
|
1861
2049
|
}
|
|
2050
|
+
async syncAdditionalOrderFromResource(resourceId) {
|
|
2051
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2052
|
+
if (!this.store.order)
|
|
2053
|
+
throw new Error("order 模块未初始化");
|
|
2054
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
2055
|
+
const normalizedResourceId = String(
|
|
2056
|
+
resourceId ?? tempOrder.resource_id ?? ((_a = this.store.resource) == null ? void 0 : _a.relationId) ?? ((_b = this.store.resource) == null ? void 0 : _b.relation_id) ?? ""
|
|
2057
|
+
).trim();
|
|
2058
|
+
this.logMethodStart("syncAdditionalOrderFromResource", {
|
|
2059
|
+
resourceId: normalizedResourceId
|
|
2060
|
+
});
|
|
2061
|
+
if (!normalizedResourceId) {
|
|
2062
|
+
const result2 = {
|
|
2063
|
+
matched: false,
|
|
2064
|
+
reason: "missing_resource_id"
|
|
2065
|
+
};
|
|
2066
|
+
this.logMethodSuccess("syncAdditionalOrderFromResource", result2);
|
|
2067
|
+
return result2;
|
|
2068
|
+
}
|
|
2069
|
+
const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
2070
|
+
const occupyDetail = occupyDetails[0] ?? null;
|
|
2071
|
+
const resourceSelectType = ((_c = this.store.resource) == null ? void 0 : _c.resourceSelectType) || this.resolveResourceSelectType((0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id));
|
|
2072
|
+
const allowAddItems = (0, import_utils.toBoolean)(
|
|
2073
|
+
(_e = (_d = this.otherParams) == null ? void 0 : _d.dineInConfig) == null ? void 0 : _e["sale.allow_add_items"]
|
|
2074
|
+
);
|
|
2075
|
+
const result = this.resolveAdditionalOrderFromOccupyDetail(
|
|
2076
|
+
occupyDetail,
|
|
2077
|
+
resourceSelectType,
|
|
2078
|
+
allowAddItems
|
|
2079
|
+
);
|
|
2080
|
+
if (!result.matched || !result.order_id) {
|
|
2081
|
+
this.logMethodSuccess("syncAdditionalOrderFromResource", {
|
|
2082
|
+
...result,
|
|
2083
|
+
resourceId: normalizedResourceId,
|
|
2084
|
+
resourceSelectType,
|
|
2085
|
+
allowAddItems
|
|
2086
|
+
});
|
|
2087
|
+
return result;
|
|
2088
|
+
}
|
|
2089
|
+
tempOrder.order_id = result.order_id;
|
|
2090
|
+
tempOrder.resource_id = normalizedResourceId;
|
|
2091
|
+
tempOrder.relation_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
2092
|
+
tempOrder.table_form_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
|
|
2093
|
+
(_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
|
|
2094
|
+
this.logMethodSuccess("syncAdditionalOrderFromResource", {
|
|
2095
|
+
...result,
|
|
2096
|
+
resourceId: normalizedResourceId,
|
|
2097
|
+
resourceSelectType,
|
|
2098
|
+
allowAddItems
|
|
2099
|
+
});
|
|
2100
|
+
return result;
|
|
2101
|
+
}
|
|
2102
|
+
// 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
|
|
2103
|
+
// 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
|
|
2104
|
+
getReservationResourceSelectType() {
|
|
2105
|
+
var _a;
|
|
2106
|
+
this.logMethodStart("getReservationResourceSelectType");
|
|
2107
|
+
const resourceSelectType = (_a = this.store.resource) == null ? void 0 : _a.resourceSelectType;
|
|
2108
|
+
const result = {
|
|
2109
|
+
...resourceSelectType ? { resourceSelectType } : {},
|
|
2110
|
+
isSingleReservation: resourceSelectType === "single",
|
|
2111
|
+
isMultipleReservation: resourceSelectType === "multiple",
|
|
2112
|
+
isCapacityReservation: resourceSelectType === "capacity"
|
|
2113
|
+
};
|
|
2114
|
+
this.logMethodSuccess("getReservationResourceSelectType", result);
|
|
2115
|
+
return result;
|
|
2116
|
+
}
|
|
2117
|
+
// 判定后台是否开启允许加餐
|
|
2118
|
+
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2119
|
+
checkAllowAddItems() {
|
|
2120
|
+
var _a;
|
|
2121
|
+
this.logMethodStart("checkAllowAddItems");
|
|
2122
|
+
const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
|
|
2123
|
+
const result = {
|
|
2124
|
+
enabled: (0, import_utils.toBoolean)(dineInConfig["sale.allow_add_items"])
|
|
2125
|
+
};
|
|
2126
|
+
this.logMethodSuccess("checkAllowAddItems", result);
|
|
2127
|
+
return result;
|
|
2128
|
+
}
|
|
1862
2129
|
// 读取取餐/送餐开关
|
|
1863
2130
|
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
1864
2131
|
getFulfillmentModes() {
|